From ab61875fe6516506540feb858c7c60b555233c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 23 May 2006 10:52:44 +0000 Subject: [PATCH] TMDescView is now resized to preferred before computing other views positions fixed bug #599 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17563 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../devices/keyboard/TMWindow.cpp | 63 +++++++++++-------- .../input_server/devices/keyboard/TMWindow.h | 1 + 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/add-ons/input_server/devices/keyboard/TMWindow.cpp b/src/add-ons/input_server/devices/keyboard/TMWindow.cpp index ccdac6b871..11d7b7d11e 100644 --- a/src/add-ons/input_server/devices/keyboard/TMWindow.cpp +++ b/src/add-ons/input_server/devices/keyboard/TMWindow.cpp @@ -131,32 +131,8 @@ TMView::TMView(BRect bounds, const char* name, uint32 resizeFlags, uint32 flags, border_style border) : BBox(bounds, name, resizeFlags, flags | B_PULSE_NEEDED, border) { - BRect rect = bounds; - rect.InsetBy(12, 12); - rect.right -= B_V_SCROLL_BAR_WIDTH; - rect.bottom = rect.top + TMListItem::MinimalHeight() * 8 + 6; - BFont font = be_plain_font; - - fListView = new BListView(rect, "teams", B_SINGLE_SELECTION_LIST, - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); - fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM)); - - BScrollView *scrollView = new BScrollView("scroll_teams", fListView, - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM, 0, false, true, B_FANCY_BORDER); - AddChild(scrollView); - - rect.left = 10; - rect.top = rect.bottom + 10; - rect.bottom = rect.top + 20; - rect.right = rect.left + font.StringWidth("Kill Application") + 20; - - fKillButton = new BButton(rect, "kill", "Kill Application", - new BMessage(TM_KILL_APPLICATION), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); - AddChild(fKillButton); - fKillButton->SetEnabled(false); - - rect = bounds; + BRect rect = bounds; rect.right -= 10; rect.left = rect.right - font.StringWidth("Cancel") - 40; rect.bottom -= 14; @@ -183,10 +159,37 @@ TMView::TMView(BRect bounds, const char* name, uint32 resizeFlags, rect.left += 4; rect.bottom = rect.top - 8; - rect.top = fKillButton->Frame().bottom + 8; + rect.top = rect.bottom - 30; rect.right = bounds.right - 10; fDescView = new TMDescView(rect, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); AddChild(fDescView); + fDescView->ResizeToPreferred(); + + rect = fDescView->Frame(); + rect.left = 10; + rect.right = rect.left + font.StringWidth("Kill Application") + 20; + rect.bottom = rect.top - 8; + rect.top = rect.bottom - 20; + + fKillButton = new BButton(rect, "kill", "Kill Application", + new BMessage(TM_KILL_APPLICATION), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); + AddChild(fKillButton); + fKillButton->SetEnabled(false); + + rect = bounds; + rect.InsetBy(12, 12); + rect.right -= B_V_SCROLL_BAR_WIDTH; + rect.bottom = fKillButton->Frame().top - 10; + + fListView = new BListView(rect, "teams", B_SINGLE_SELECTION_LIST, + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); + fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM)); + + BScrollView *scrollView = new BScrollView("scroll_teams", fListView, + B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM, 0, false, true, B_FANCY_BORDER); + AddChild(scrollView); + + } @@ -327,6 +330,14 @@ TMView::GetPreferredSize(float *_width, float *_height) } +void +TMDescView::ResizeToPreferred() +{ + float bottom = Bounds().bottom; + BView::ResizeToPreferred(); + MoveBy(0, bottom - Bounds().bottom); +} + // #pragma mark - diff --git a/src/add-ons/input_server/devices/keyboard/TMWindow.h b/src/add-ons/input_server/devices/keyboard/TMWindow.h index 4a864a8104..a215f0e80c 100644 --- a/src/add-ons/input_server/devices/keyboard/TMWindow.h +++ b/src/add-ons/input_server/devices/keyboard/TMWindow.h @@ -58,6 +58,7 @@ class TMDescView : public BBox { virtual void Draw(BRect bounds); virtual void GetPreferredSize(float *_width, float *_height); + virtual void ResizeToPreferred(); void SetItem(TMListItem *item); TMListItem *Item() { return fItem; }