Easy feature: drawPopupMenuBackground fails to pass pointer to associated PopupMenu

Which makes it tricky to have different backgrounds for different menus! Can a pointer thrown in?

edit: I realise I can’t have a pointer to the PopupMenu object itself as it may have been deleted, but a pointer to the specific window would be useful :). We’ve got some really sexy looking menus with semi-transparent blurred backgrounds working. But I have a horrible hack at the mo to identify which blurred background to draw.

1 Like

Would access to the PopupMenu::options or PopupMenu::Options::targetComponent help?

That was promised to come soon here:

I think I need access to the actual Component for the menu as well. But those would be a great start. Just a Component & on the background painting call would be fine :slight_smile:

1 Like

I’d second this, and add that it would be really helpful if a const reference to the PopupMenu::Options field (or the targetComponent*) was also available in LookAndFeel::preparePopupMenuWindow(Component& c). That method’s only implementation is a stub in juce::LookAndFeel_V2, so that wouldn’t affect much, but would make it possible to alter the layout, etc. in response to the context.

For example, I’ve been trying to make a popup menu that renders like a CallOutBox/BubbleComponent (slightly rounded corners and with an arrow back to target) and it has been a slog. I can do things like shift the window over via preparePopupMenu, but without access to the options, I don’t know where it is in relation to its target.

I’m realizing now that PopupMenu::Options probably couldn’t be passed to drawPopupMenuBackground at present because it’s also being used by BurgerMenuComponent.

It could have an overload added with PopupMenu::Options, though, with PopupMenu using that version, and BurgerMenuComponent using the current one. Calls to the method with Options in existing LAFs could simply delegate to the method without Options.