1
0
Fork 0
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:
reuk 2025-08-18 13:01:25 +01:00
parent 33a735dfd8
commit 9b226f93f4
No known key found for this signature in database

View file

@ -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);
}
}