Skip to content

Commit

Permalink
HaikuDepot: Fixed scroll range in ratings view
Browse files Browse the repository at this point in the history
 * Due to HasHeightForWidth TextViews, the MinSize() of
   the layout has a different meaning. The reliable source
   for the actual needed height of the layout seems to be the
   Frame().bottom of the last BLayoutItem.
  • Loading branch information
stippi committed Aug 14, 2013
1 parent 139bc0d commit 840cac7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/apps/haiku-depot/MainWindow.cpp
Expand Up @@ -314,7 +314,14 @@ MainWindow::_InitDummyModel()
"will need to recompile your filters.");
sequitur.AddUserRating(
UserRating(UserInfo("pete"), 4.5f,
"I can weave a web of sound!", "en", "2.1.0")
"I can weave a web of sound! And it connects to PatchBay. Check "
"it out, I can wholeheartly recommend this app!! This rating "
"comment is of course only so long, because the new TextView "
"layout needs some testing. Oh, and did I mention it works with "
"custom installed sound fonts? Reading through this comment I find "
"that I did not until now. Hopefully there are enough lines now to "
"please the programmer with the text layouting and scrolling of "
"long ratings!", "en", "2.1.0")
);
sequitur.AddUserRating(
UserRating(UserInfo("stippi"), 3.5f,
Expand Down
22 changes: 17 additions & 5 deletions src/apps/haiku-depot/PackageInfoView.cpp
Expand Up @@ -789,12 +789,24 @@ class RatingContainerView : public BGroupView {
{
BGroupView::DoLayout();
if (BScrollBar* scrollBar = ScrollBar(B_VERTICAL)) {
BSize minSize = BGroupView::MinSize();
float height = Bounds().Height();
float max = minSize.height - height;
BRect layoutArea = GroupLayout()->LayoutArea();
float layoutHeight = layoutArea.Height();
// Min size is not reliable with HasHeightForWidth() children,
// since it does not reflect how thos children are currently
// laid out, but what their theoretical minimum size would be.

BLayoutItem* lastItem = GroupLayout()->ItemAt(
GroupLayout()->CountItems() - 1);
if (lastItem != NULL) {
layoutHeight = lastItem->Frame().bottom;
}

float viewHeight = Bounds().Height();

float max = layoutHeight- viewHeight;
scrollBar->SetRange(0, max);
if (minSize.height > 0)
scrollBar->SetProportion(height / minSize.height);
if (layoutHeight > 0)
scrollBar->SetProportion(viewHeight / layoutHeight);
else
scrollBar->SetProportion(1);
}
Expand Down

0 comments on commit 840cac7

Please sign in to comment.