PopupMenu fonts using LookAndFeel


#1

On my way to implement a LookAndFeel for popup menu, I succeded in drawing a red background for popup menu, but I could not find a way to change the font, when apparently the method is the strictly the same !

in .h :

[code]class My_Look_And_Feel : public Component,
public LookAndFeel
{
public:
//==============================================================================
My_Look_And_Feel ();
~My_Look_And_Feel();

//==============================================================================
//[UserMethods]     -- You can add your own custom methods in this section.
void drawPopupMenuBackground (Graphics &g, int width, int height);
const Font getMenuBarFont (MenuBarComponent &menuBar,int  itemIndex, const String &  itemText);
//[/UserMethods]

void paint (Graphics& g);
void resized();

juce_UseDebuggingNewOperator

private:

My_Look_And_Feel (const My_Look_And_Feel&);
const My_Look_And_Feel& operator= (const My_Look_And_Feel&);

};[/code]

And in the cpp file :

[code]void My_Look_And_Feel::drawPopupMenuBackground (Graphics &g, int width, int height)
{
g.fillAll (Colours::red);
} <<<<< this one gets called

const Font My_Look_And_Feel::getMenuBarFont(MenuBarComponent &menuBar, int itemIndex, const String & itemText)
{
Font myFont;
myFont.setSizeAndStyle((float)(6),0,1.0f,0.0f);
myFont.setItalic(true);
myFont.setBold(true);
return myFont;
} <<<<< this one never gets called[/code]

It must be some syntax problem, I really don’t have any clue, the getMenuBarFont seems to never be called, what am I doing wrong ?

Nicolas


#2

const Font My_Look_And_Feel::getPopupMenuFont()


#3

DOH…doh…dohh…

I should sleep more , thanks !

Nicolas


#4

Hey! Is there a way to change the font size of an PopupMenu item responsively? The LnF method does not know about the PopupMenu object, neither the editor window size… It just looks strange that everything is smoothly responsive in my GUI except of the dropdowns… Thanks in advance!


#5

Add a public method in your LnF to set the font size… and if your GUI changes size… set the font size and trigger a repaint.

Rail