HaikuDepot: Fixed scroll range in ratings view
* 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.
This commit is contained in:
parent
139bc0df15
commit
840cac7415
|
@ -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,
|
||||
|
|
|
@ -789,12 +789,24 @@ protected:
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue