TitleBar Icon not showing ?!


#1

Hi guys,

I'm having difficulty showing the icon on the TitleBar.

I used this method to modify the TitleBar and everything is ok except for the icon which is not showing anywhere.

Maybe I'm doing something bad and that's why, but anyway take a look at my code  :

This is the LookAndFeel Class I created :


class MainLookAndFeel : public LookAndFeel_V3
        {
        public:
            void drawDocumentWindowTitleBar(DocumentWindow & d, Graphics & g, int w, int h, int titleSpaceX,
                int titleSpaceW, const Image *icon, bool drawTitleTextOnLeft) override
            {
                g.fillAll(Colours::black.brighter(0.15f));
                
                drawTitleTextOnLeft = false;
                
                
                Rectangle<int> t;
                String nameO;
                nameO = "MELODIA";
                
                g.setFont(Font("Segoe Print", 26.0f, Font::bold));
                t.setSize(d.getWidth(), d.getTitleBarHeight());
                g.setColour(Colours::white);
                
                g.drawFittedText(nameO, t, Justification::centred, 1, 1.0f);
                
                if (icon)
                {
                    g.drawImage(ImageFileFormat::loadFrom(File("C:\\Users\\Geri\\Documents\\Melodia Player\\Melodia_Logo.png")), 0, 0, d.getTitleBarHeight() - 2, d.getTitleBarHeight() - 2, 0, 0, d.getTitleBarHeight() - 2, d.getTitleBarHeight() - 2, false);
                
                }
                
            }
        };

I would appreciate the help.

Thank's. :)

 

EDIT : I did some changes and the icon appeared now but I'm not sure if the image is set as an icon or just like an image.

g.drawImage(ImageFileFormat::loadFrom(File("C:\\Users\\Geri\\Documents\\Melodia Player\\Melodia_Logo.png")), 5, 0, d.getTitleBarHeight() - 5, d.getTitleBarHeight() - 5, 0, 0, 48, 48, false);