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:
@@ -619,7 +619,7 @@ FeaturedPackagesView::FeaturedPackagesView()
|
|||||||
fPackagesView = new StackedFeaturedPackagesView();
|
fPackagesView = new StackedFeaturedPackagesView();
|
||||||
|
|
||||||
fScrollView = new BScrollView("featured packages scroll view",
|
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)
|
BLayoutBuilder::Group<>(this)
|
||||||
.Add(fScrollView, 1.0f);
|
.Add(fScrollView, 1.0f);
|
||||||
@@ -682,37 +682,11 @@ FeaturedPackagesView::DoLayout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
FeaturedPackagesView::FrameResized(float width, float height)
|
|
||||||
{
|
|
||||||
BView::FrameResized(width, height);
|
|
||||||
_AdjustViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FeaturedPackagesView::_AdjustViews()
|
FeaturedPackagesView::_AdjustViews()
|
||||||
{
|
{
|
||||||
BScrollBar* scrollBar = fScrollView->ScrollBar(B_VERTICAL);
|
fScrollView->FrameResized(fScrollView->Frame().Width(),
|
||||||
BSize scrollViewSize = fScrollView->Frame().Size();
|
fScrollView->Frame().Height());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public:
|
|||||||
FeaturedPackagesView();
|
FeaturedPackagesView();
|
||||||
virtual ~FeaturedPackagesView();
|
virtual ~FeaturedPackagesView();
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
virtual void DoLayout();
|
virtual void DoLayout();
|
||||||
|
|
||||||
void AddPackage(const PackageInfoRef& package);
|
void AddPackage(const PackageInfoRef& package);
|
||||||
|
|||||||
Reference in New Issue
Block a user