Only use the scrollview if it is needed (to avoid the problem of a useless

disabled scrollbar.)

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@562 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
leavengood
2012-07-03 15:45:31 +02:00
committed by Alexandre Deckner
parent 36badc2d94
commit 927bc248a3
@@ -374,12 +374,18 @@ BDefaultChoiceView::ShowChoices(BAutoCompleter::CompletionStyle* completer)
); );
} }
BScrollView *scrollView = new BScrollView("", fListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER); BScrollView *scrollView = NULL;
if (count > fMaxVisibleChoices) {
scrollView = new BScrollView("", fListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER);
}
fWindow = new BWindow(BRect(0, 0, 100, 100), "", B_BORDERED_WINDOW_LOOK, fWindow = new BWindow(BRect(0, 0, 100, 100), "", B_BORDERED_WINDOW_LOOK,
B_NORMAL_WINDOW_FEEL, B_NOT_MOVABLE | B_WILL_ACCEPT_FIRST_CLICK B_NORMAL_WINDOW_FEEL, B_NOT_MOVABLE | B_WILL_ACCEPT_FIRST_CLICK
| B_AVOID_FOCUS | B_ASYNCHRONOUS_CONTROLS); | B_AVOID_FOCUS | B_ASYNCHRONOUS_CONTROLS);
if (scrollView != NULL)
fWindow->AddChild(scrollView); fWindow->AddChild(scrollView);
else
fWindow->AddChild(fListView);
int32 visibleCount = min_c(count, fMaxVisibleChoices); int32 visibleCount = min_c(count, fMaxVisibleChoices);
float listHeight = fListView->ItemFrame(visibleCount - 1).bottom + 1; float listHeight = fListView->ItemFrame(visibleCount - 1).bottom + 1;
@@ -393,6 +399,7 @@ BDefaultChoiceView::ShowChoices(BAutoCompleter::CompletionStyle* completer)
else else
listRect.OffsetTo(pvRect.left, pvRect.top - listHeight); listRect.OffsetTo(pvRect.left, pvRect.top - listHeight);
if (scrollView != NULL) {
// Moving here to cut off the scrollbar top // Moving here to cut off the scrollbar top
scrollView->MoveTo(0, -1); scrollView->MoveTo(0, -1);
// Adding the 1 and 2 to cut-off the scroll-bar top, right and bottom // Adding the 1 and 2 to cut-off the scroll-bar top, right and bottom
@@ -400,6 +407,10 @@ BDefaultChoiceView::ShowChoices(BAutoCompleter::CompletionStyle* completer)
// Move here to compensate for the above // Move here to compensate for the above
fListView->MoveTo(0, 1); fListView->MoveTo(0, 1);
fListView->ResizeTo(listRect.Width() - B_V_SCROLL_BAR_WIDTH, listRect.Height()); fListView->ResizeTo(listRect.Width() - B_V_SCROLL_BAR_WIDTH, listRect.Height());
} else {
fListView->MoveTo(0, 0);
fListView->ResizeTo(listRect.Width(), listRect.Height());
}
fWindow->MoveTo(listRect.left, listRect.top); fWindow->MoveTo(listRect.left, listRect.top);
fWindow->ResizeTo(listRect.Width(), listRect.Height()); fWindow->ResizeTo(listRect.Width(), listRect.Height());
fWindow->Show(); fWindow->Show();