mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +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())
|
||||
{
|
||||
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();
|
||||
ensureItemComponentIsVisible (*item, isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1);
|
||||
|
||||
break;
|
||||
}
|
||||
auto y = targetPosition.getY() - windowPos.getY();
|
||||
ensureItemComponentIsVisible (**iter, isPositiveAndBelow (y, windowPos.getHeight()) ? y : -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue