mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
PopupMenu: Use early return in ensureItemComponentIsVisible()
This commit is contained in:
parent
9b226f93f4
commit
41a6ed37e4
1 changed files with 26 additions and 28 deletions
|
|
@ -1093,20 +1093,20 @@ struct MenuWindow final : public Component
|
||||||
|
|
||||||
void ensureItemComponentIsVisible (const ItemComponent& itemComp, int wantedY)
|
void ensureItemComponentIsVisible (const ItemComponent& itemComp, int wantedY)
|
||||||
{
|
{
|
||||||
if (windowPos.getHeight() > PopupMenuSettings::scrollZone * 4)
|
if (windowPos.getHeight() <= PopupMenuSettings::scrollZone * 4
|
||||||
|
|| (wantedY <= 0 && 0 <= itemComp.getY() && itemComp.getBottom() <= windowPos.getHeight()))
|
||||||
{
|
{
|
||||||
auto currentY = itemComp.getY();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (wantedY > 0 || currentY < 0 || itemComp.getBottom() > windowPos.getHeight())
|
|
||||||
{
|
|
||||||
if (wantedY < 0)
|
if (wantedY < 0)
|
||||||
wantedY = jlimit (PopupMenuSettings::scrollZone,
|
wantedY = jlimit (PopupMenuSettings::scrollZone,
|
||||||
jmax (PopupMenuSettings::scrollZone,
|
jmax (PopupMenuSettings::scrollZone,
|
||||||
windowPos.getHeight() - (PopupMenuSettings::scrollZone + itemComp.getHeight())),
|
windowPos.getHeight() - (PopupMenuSettings::scrollZone + itemComp.getHeight())),
|
||||||
currentY);
|
itemComp.getY());
|
||||||
|
|
||||||
auto parentArea = getParentArea (windowPos.getPosition(), options.getParentComponent()) / scaleFactor;
|
auto parentArea = getParentArea (windowPos.getPosition(), options.getParentComponent()) / scaleFactor;
|
||||||
auto deltaY = wantedY - currentY;
|
auto deltaY = wantedY - itemComp.getY();
|
||||||
|
|
||||||
windowPos.setSize (jmin (windowPos.getWidth(), parentArea.getWidth()),
|
windowPos.setSize (jmin (windowPos.getWidth(), parentArea.getWidth()),
|
||||||
jmin (windowPos.getHeight(), parentArea.getHeight()));
|
jmin (windowPos.getHeight(), parentArea.getHeight()));
|
||||||
|
|
@ -1122,8 +1122,6 @@ struct MenuWindow final : public Component
|
||||||
|
|
||||||
updateYPositions();
|
updateYPositions();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void resizeToBestWindowPos()
|
void resizeToBestWindowPos()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue