BMenu: scroll marked item into view when menu has scrollers attached.
Signed-off-by: Axel Dörfler <[email protected]>
This commit is contained in:
committed by
Axel Dörfler
parent
4e78098e7c
commit
4898c615d6
@@ -40,6 +40,7 @@ public:
|
|||||||
bool HasScrollers() const;
|
bool HasScrollers() const;
|
||||||
bool CheckForScrolling(const BPoint& cursor);
|
bool CheckForScrolling(const BPoint& cursor);
|
||||||
bool TryScrollBy(const float& step);
|
bool TryScrollBy(const float& step);
|
||||||
|
bool TryScrollTo(const float& where);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _Scroll(const BPoint& cursor);
|
bool _Scroll(const BPoint& cursor);
|
||||||
|
|||||||
@@ -2871,6 +2871,20 @@ BMenu::_UpdateWindowViewSize(const bool &move)
|
|||||||
}
|
}
|
||||||
|
|
||||||
window->AttachScrollers();
|
window->AttachScrollers();
|
||||||
|
|
||||||
|
BMenuItem* selectedItem = FindMarked();
|
||||||
|
if (selectedItem != NULL && fLayout == B_ITEMS_IN_COLUMN) {
|
||||||
|
// scroll to the selected item
|
||||||
|
if (Supermenu() == NULL) {
|
||||||
|
window->TryScrollTo(selectedItem->Frame().top);
|
||||||
|
} else {
|
||||||
|
BPoint point = selectedItem->Frame().LeftTop();
|
||||||
|
BPoint superpoint = Superitem()->Frame().LeftTop();
|
||||||
|
Supermenu()->ConvertToScreen(&superpoint);
|
||||||
|
ConvertToScreen(&point);
|
||||||
|
window->TryScrollTo(point.y - superpoint.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_CacheFontInfo();
|
_CacheFontInfo();
|
||||||
|
|||||||
@@ -412,6 +412,17 @@ BMenuWindow::TryScrollBy(const float& step)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BMenuWindow::TryScrollTo(const float& where)
|
||||||
|
{
|
||||||
|
if (!fMenuFrame || !fUpperScroller || !fLowerScroller)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_ScrollBy(where - fValue);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BMenuWindow::_Scroll(const BPoint& where)
|
BMenuWindow::_Scroll(const BPoint& where)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user