White background of popup menu

Hello forum

Beeing new to Juce and C++ in general im not so sure about my question, but anyhow, here i go:

(using the latest tip: julianstorer-JUCE-2.0.32-52-g5b33ab5)

In function paint of juce_PopMenu.cpp, line 295, is the condition “if(isOpaque())” wich results in drawing a white “basecoat” to any popup menu with NON-transparent PopupMenu::backgroundColourId setting, while it doesn’t whe the background color has transparency.

Why should this be done?

I wanted to write a custom look&feel wich has, don’t ask me why, rounded corners for the popup menu of a combo box, wich i could only realize by give up PopupMenu::backgroundColourId.

Maybe i’m completely missunderstanding something, but in my opinion, this should be the other way round, (!isOpaque()), to prevent unreadeable, transparent popup menues.

Can anyone give me a hint?
Thanks.

juce_PopMenu.cpp

[code] void paint (Graphics& g)
{
if (isOpaque())
g.fillAll (Colours::white);

    getLookAndFeel().drawPopupMenuBackground (g, getWidth(), getHeight());
}[/code]
1 Like

Use setOpaque(false) on your component.
isOpaque is not related to the colour alpha.

thank you!

Hmm… i tried to implement that sugestion, but i’m stocked again.

In my case, i need to access the popup menu of a combo box and put setOpaque to true.
And i would like to do this from within my custom LookAndFeel without changing the behavior of all popups. Only the ones within a combo box should be affected.

It seems to me, that the PopupMenu is not passed as an argument in any virtual ComboBox function in LookAndFeel, so i could get a handle to it.
My attempts like “combo_box.getChildComponent(0)->setOpaque(true);” inside drawComboBox function ended in “broken graphics” of the ComboBox.

Of course i could do a “custom ComboBox” and solve it that way, but I like to avoid this. And i still don’t really get the idea behind this hard coded white rectangular background. In my opinion, it could be just dropped and managed within LookAndFeel…

So let me know, if i’m wrong with that and failed to notice something!

So far my workaround by setting PopupMenu::backgroundColourId to an alpha of zero and hard code the background color for my rounded rectangular shape in drawPopupMenuBackground works.

G.

btw: Juce makes even an audio post guy, who just started with c++, writing little cross plattform apps. And they work. And its fun. Deep respect…

1 Like