HaikuDepot: Let BScrollView handle resizing the scrollbar bounds.
This way, it will also resize the views properly when the scrollbars are larger. Fixes part of #16408.
This commit is contained in:
parent
a06b52bee8
commit
494bd14713
@ -619,7 +619,7 @@ FeaturedPackagesView::FeaturedPackagesView()
|
||||
fPackagesView = new StackedFeaturedPackagesView();
|
||||
|
||||
fScrollView = new BScrollView("featured packages scroll view",
|
||||
fPackagesView, B_FOLLOW_ALL_SIDES, 0, false, true, B_FANCY_BORDER);
|
||||
fPackagesView, 0, false, true, B_FANCY_BORDER);
|
||||
|
||||
BLayoutBuilder::Group<>(this)
|
||||
.Add(fScrollView, 1.0f);
|
||||
@ -682,37 +682,11 @@ FeaturedPackagesView::DoLayout()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FeaturedPackagesView::FrameResized(float width, float height)
|
||||
{
|
||||
BView::FrameResized(width, height);
|
||||
_AdjustViews();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FeaturedPackagesView::_AdjustViews()
|
||||
{
|
||||
BScrollBar* scrollBar = fScrollView->ScrollBar(B_VERTICAL);
|
||||
BSize scrollViewSize = fScrollView->Frame().Size();
|
||||
float width = scrollViewSize.Width() - (B_V_SCROLL_BAR_WIDTH + 4.0f);
|
||||
// +2 for border; both sides
|
||||
float height = scrollViewSize.Height() - 4.0;
|
||||
// +2 for border; top and bottom
|
||||
|
||||
fPackagesView->ResizeTo(width, height);
|
||||
|
||||
if (fPackagesView->IsEmpty()) {
|
||||
scrollBar->SetRange(0, 0);
|
||||
scrollBar->SetProportion(1);
|
||||
}
|
||||
else {
|
||||
float packagesHeight = fPackagesView->PreferredSize().Height();
|
||||
float packagesActualHeight = fmaxf(packagesHeight, height);
|
||||
scrollBar->SetRange(0, packagesActualHeight - scrollViewSize.Height());
|
||||
scrollBar->SetProportion(
|
||||
scrollViewSize.Height() / packagesActualHeight);
|
||||
}
|
||||
fScrollView->FrameResized(fScrollView->Frame().Width(),
|
||||
fScrollView->Frame().Height());
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
FeaturedPackagesView();
|
||||
virtual ~FeaturedPackagesView();
|
||||
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void DoLayout();
|
||||
|
||||
void AddPackage(const PackageInfoRef& package);
|
||||
|
Loading…
Reference in New Issue
Block a user