PopupMenuWindow draw issue


#1

Hi all,
I have a little problem with the pop-up menu. I want to reimplement the drawPopupMenuBackground with my own look-and-feel and do something like a fillRoundedrectangle to draw a rounded corner PopupMenuWindow.
I’ve tried it but the corner of the window stay black.
I’ve looked into the juce_PopupMenu class and saw that the PopupMenuWindow is opaque and so that’s why the corner are black.
I tried to set transparent and fall line 185 of juce_DropShadower.cpp.

jassert (owner->isOpaque()); // doesn't work properly for semi-transparent comps!
I understood that’s the wrong way.
So here is my question:
Is is possible to have a PopupMenuWindow (partially) transparent (in order to draw it with rounded corners)?
Or is there any other solution to do this?

Thanks

Kevin


#2

It’s a bit tricky with the current implementation. I guess it’d require some additions to the lookandfeel that let you specify whether a menu has a drop-shadow, and then you could disable it.


#3

Not sure I have understood exactly what to do (specially how to “specify whether a menu has a drop-shadow”) , but I will have a look at the DropShadower class and try to do something with it.

Thx

Kevin


#4

The drop shadow you see on standard menu is made of small “transparent windows” (4 IIRC) that are independant from the menu component.
They simply monitor every change in size or position of the menu and then, re-adjust to the new size and position.

If you want to make rounded corner menu, you’ll have to either:

  • Change the drop shadow code to be made of more pieces (4 (sides) + 4 for the corners)
  • Or, a lot simpler, disable the drop shadow at all.

The answer from Jules is simply an option for the second case.


#5

Hi all,
thanks for your help.
I tried what you said me (disable the DropShadow for the popup menu) but the problem persists.
Maybe we were misunderstanding, probably due to my bad english and also because I don’t master very much all the Juce framework. :?
I gonna be a little bit more explicit. I reimplemented the LookAndFeel::drawPopupMenuBackground method like this.

void MyLookAndFeel::drawPopupMenuBackground (Graphics& g, int width, int height) { const Colour background (findColour (PopupMenu::backgroundColourId)); g.setColour (background); g.fillRoundedRectangle (0, 0, width, height,10); }
The result is not exactly what I expected. I get the rounded rect filled but the rest of the normal rectangle (the space which is not drawn in a rounded rectangle) is painted black where I want it to be transparent. I hope you understood me :).

Thanks for your help

Kevin


#6

But I think you answered your own question - the menu comp has to have setOpaque (false) called if you want it to be non-rectangular.


#7

Oh yes. I got it. I forgot to setOpaque(false) the PopUpMenuWindow. :lol:.
Now it works without the drop shadow. I’ll try to do something like X-Ryl669 tell me to get it with the drop shadow.
Maybe I’ll come again to ask some questions. :wink:

Thanks for all


#8

I’m back for the next question :?

Is there any way to setOpaque(false) the PopupMenuWindow without acking the juce_PopupMenu.cpp because I don’t want to do this.
The only idea I have is to copy the whole code of this class in a new one called MyPopupMenu , add it to my project sources and set the flag to false. I know it’s not a good way but I don’t have any other.

If I can inherit from PopupMenuWindow the problem will not exists but I can’t.

I have the same problem with several classes in JUCE, AlertWindow for instance where I wanted to add my own button.

Thanks

Kevin


#9

Well, that’d need to go into the lookandfeel. Actually, I might start a sticky thread to keep track of all these small l+f requests, as they come up pretty often.


#10

I don’t know how to set the PopupMenuWindow with the LookAndFeel because this class is “unknow” by the l&f. But I will investigate in this way.

I think your idea to start a sticky thread for the l&f requests is very good (and very helpful so)

thanks