mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
PopupMenu: Replace raw loop with find_if
This commit is contained in:
parent
33a735dfd8
commit
9b226f93f4
1 changed files with 13 additions and 13 deletions
|
|
@ -424,23 +424,23 @@ struct MenuWindow final : public Component
|
||||||
|
|
||||||
if (auto visibleID = options.getItemThatMustBeVisible())
|
if (auto visibleID = options.getItemThatMustBeVisible())
|
||||||
{
|
{
|
||||||
for (auto* item : items)
|
const auto iter = std::find_if (items.begin(), items.end(), [&] (auto* item)
|
||||||
{
|
{
|
||||||
if (item->item.itemID == visibleID)
|
return item->item.itemID == visibleID;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (iter != items.end())
|
||||||
|
{
|
||||||
|
const auto targetPosition = [&]
|
||||||
{
|
{
|
||||||
const auto targetPosition = [&]
|
if (auto* pc = options.getParentComponent())
|
||||||
{
|
return pc->getLocalPoint (nullptr, targetArea.getTopLeft());
|
||||||
if (auto* pc = options.getParentComponent())
|
|
||||||
return pc->getLocalPoint (nullptr, targetArea.getTopLeft());
|
|
||||||
|
|
||||||
return targetArea.getTopLeft();
|
return targetArea.getTopLeft();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
auto y = targetPosition.getY() - windowPos.getY();
|
auto y = targetPosition.getY() - windowPos.getY();
|
||||||
ensureItemComponentIsVisible (*item, isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1);
|
ensureItemComponentIsVisible (**iter, isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1);
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue