1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

PopupMenu: Use correct LookAndFeel when computing parent component

This commit is contained in:
reuk 2022-11-30 12:29:34 +00:00
parent 8d4b3774b2
commit e5fc50908e
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -324,12 +324,16 @@ private:
//==============================================================================
struct MenuWindow : public Component
{
MenuWindow (const PopupMenu& menu, MenuWindow* parentWindow,
Options opts, bool alignToRectangle, bool shouldDismissOnMouseUp,
ApplicationCommandManager** manager, float parentScaleFactor = 1.0f)
MenuWindow (const PopupMenu& menu,
MenuWindow* parentWindow,
Options opts,
bool alignToRectangle,
bool shouldDismissOnMouseUp,
ApplicationCommandManager** manager,
float parentScaleFactor = 1.0f)
: Component ("menu"),
parent (parentWindow),
options (opts.withParentComponent (getLookAndFeel().getParentComponentForMenuOptions (opts))),
options (opts.withParentComponent (findLookAndFeel (menu, parentWindow)->getParentComponentForMenuOptions (opts))),
managerOfChosenCommand (manager),
componentAttachedTo (options.getTargetComponent()),
dismissOnMouseUp (shouldDismissOnMouseUp),
@ -343,8 +347,7 @@ struct MenuWindow : public Component
setAlwaysOnTop (true);
setFocusContainerType (FocusContainerType::focusContainer);
setLookAndFeel (parent != nullptr ? &(parent->getLookAndFeel())
: menu.lookAndFeel.get());
setLookAndFeel (findLookAndFeel (menu, parentWindow));
auto& lf = getLookAndFeel();
@ -1291,6 +1294,17 @@ struct MenuWindow : public Component
}));
}
LookAndFeel* findLookAndFeel (const PopupMenu& menu, MenuWindow* parentWindow) const
{
if (parentWindow != nullptr)
return &(parentWindow->getLookAndFeel());
if (auto* lnf = menu.lookAndFeel.get())
return lnf;
return &getLookAndFeel();
}
//==============================================================================
MenuWindow* parent;
const Options options;