<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Custom Title Bar for Standalone]]></title><description><![CDATA[<p dir="auto">Let us use look and feel on the title bar.</p>
<p dir="auto">This will further push the unified look across the platforms.</p>
<p dir="auto">In JUCE, it's just this, for example:</p>
<pre><code>MainWindow (juce::String name)
           : DocumentWindow (name,
                             juce::Colour(0xff222222),
                             DocumentWindow::closeButton | DocumentWindow::minimiseButton)
       {
           setUsingNativeTitleBar (false);
</code></pre>
<p dir="auto">This will only show the minimize and close buttons, and disable the native title bar.</p>
<p dir="auto">Then for look and feel it's this (probably messy as hell given how this is from my first JUCE project but you get the gist, I'm sure).</p>
<pre><code>class CustomLookAndFeel : public juce::LookAndFeel_V4
{
public:

    void drawDocumentWindowTitleBar(juce::DocumentWindow&amp; window,
        juce::Graphics&amp; g,
        int w, int h,
        int titleSpaceX, int titleSpaceW,
        const juce::Image* icon,
        bool drawTitleTextOnLeft) override
    {
        // Fill the title bar background
        g.fillAll(juce::Colour(0xff222222));

        // Create a Typeface from the binary data
        juce::Typeface::Ptr typeface = juce::Typeface::createSystemTypefaceFor(GlobalFontData::Controls, GlobalFontData::ControlsSize);

        // Create a Font from the Typeface
        juce::Font font(typeface);

        // Use the font
        g.setFont(font.withPointHeight(18.0f));

        g.setColour(juce::Colours::white); // Choose an appropriate text color

        // Retrieve the title of the window
        juce::String title = window.getName();

        // Set the area where the title will be drawn
        juce::Rectangle&lt;int&gt; textArea(0, 0, window.getWidth(), h);

        // Draw the title text
        g.drawText(title, textArea, juce::Justification::centred, true);

        // Temporarily draw the text area for debugging
        //g.setColour(juce::Colours::red);
        //g.drawRect(textArea); 
    }

    // Style the close button here, then create a new instance of it in the createDocumentWindowButton() method
    class CustomCloseButton : public juce::Button, private juce::Timer
    {
    public:
        CustomCloseButton(const juce::String&amp; buttonName) : Button(buttonName)
        {
            startTimerHz(60); // Start the timer to update the color 60 times per second
        }

        void paintButton(juce::Graphics&amp; g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
        {
            g.setColour(currentBackground);
            g.fillRect(0, 0, 40, 40); // Draw the background square
            g.setColour(currentColour);
            g.setFont(juce::Font("Arial", "Regular", 22.0f));
            g.drawText("X", getLocalBounds(), juce::Justification::centred, true);
        }

        void timerCallback() override
        {
            // Update the color
            currentColour = currentColour.interpolatedWith(targetColour, 0.2f);
            currentBackground = currentBackground.interpolatedWith(targetBackground, 0.2f);
            repaint();
        }

        void mouseEnter(const juce::MouseEvent&amp;) override
        {
            targetColour = juce::Colour(0xffd2d2d2); // Highlighted color
            targetBackground = juce::Colour(0x10ffffff); // Highlighted color
        }

        void mouseExit(const juce::MouseEvent&amp;) override
        {
            targetColour = juce::Colour(0xffbababa); // Mouse off color
            targetBackground = juce::Colour(0x0000000); // Mouse off color
        }

        void mouseDown(const juce::MouseEvent&amp; event) override
        {
            targetColour = juce::Colour(0xffe9e9e9); // Down color
            targetBackground = juce::Colour(0x20ffffff); // Down color
            Button::mouseDown(event); // Pass the event to the parent class
        }

        void mouseUp(const juce::MouseEvent&amp; event) override
        {
            targetColour = juce::Colour(0xffd2d2d2); // Highlighted color
            targetBackground = juce::Colour(0x10ffffff); // Highlighted color
            Button::mouseUp(event); // Pass the event to the parent class
        }

    private:
        juce::Colour currentColour = juce::Colour(0xffbababa); // Initial color
        juce::Colour targetColour = juce::Colour(0xffbababa); // Initial target color
        juce::Colour currentBackground = juce::Colour(0x00000000); // Initial background color
        juce::Colour targetBackground = juce::Colour(0x00000000); // Initial target background color
    };


    // Style the minimize button here, then create a new instance of it in the createDocumentWindowButton() method
    class CustomMinimizeButton : public juce::Button, private juce::Timer
    {
    public:
        CustomMinimizeButton(const juce::String&amp; buttonName) : Button(buttonName)
        {
            startTimerHz(60); // Start the timer to update the color 60 times per second
        }

        void paintButton(juce::Graphics&amp; g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
        {
            g.setColour(currentBackground);
            g.fillRect(0, 0, 40, 40); // Draw the background square
            g.setColour(currentColour);
            g.setFont(juce::Font("Arial", "Regular", 22.0f));
            g.drawText("/", getLocalBounds(), juce::Justification::centred, true);
        }

        void timerCallback() override
        {
            // Update the color
            currentColour = currentColour.interpolatedWith(targetColour, 0.2f);
            currentBackground = currentBackground.interpolatedWith(targetBackground, 0.2f);
            repaint();
        }

        void mouseEnter(const juce::MouseEvent&amp;) override
        {
            targetColour = juce::Colour(0xffd2d2d2); // Highlighted color
            targetBackground = juce::Colour(0x10ffffff); // Highlighted color
        }

        void mouseExit(const juce::MouseEvent&amp;) override
        {
            targetColour = juce::Colour(0xffbababa); // Mouse off color
            targetBackground = juce::Colour(0x0000000); // Mouse off color
        }

        void mouseDown(const juce::MouseEvent&amp; event) override
        {
            targetColour = juce::Colour(0xffe9e9e9); // Down color
            targetBackground = juce::Colour(0x20ffffff); // Down color
            Button::mouseDown(event); // Pass the event to the parent class
        }

        void mouseUp(const juce::MouseEvent&amp; event) override
        {
            targetColour = juce::Colour(0xffd2d2d2); // Highlighted color
            targetBackground = juce::Colour(0x10ffffff); // Highlighted color
            Button::mouseUp(event); // Pass the event to the parent class
        }

    private:
        juce::Colour currentColour = juce::Colour(0xffbababa); // Initial color
        juce::Colour targetColour = juce::Colour(0xffbababa); // Initial target color
        juce::Colour currentBackground = juce::Colour(0x00000000); // Initial background color
        juce::Colour targetBackground = juce::Colour(0x00000000); // Initial target background color
    };


    juce::Button* createDocumentWindowButton(int buttonType) override
    {
        // Here you can create your custom buttons. You can check the buttonType to determine which button to create.

        if (buttonType == juce::DocumentWindow::minimiseButton)
        {
            return new CustomMinimizeButton("minimize");
        }
        else if (buttonType == juce::DocumentWindow::maximiseButton)
        {
            // Create your custom maximize button
        }
        else if (buttonType == juce::DocumentWindow::closeButton)
        {
            return new CustomCloseButton("close");
        }

        // Call the base class implementation if you want to keep the default look and feel
        return LookAndFeel_V4::createDocumentWindowButton(buttonType);
    }

};
</code></pre>
<p dir="auto">In HISE, it would be <code>drawTitleBar</code>, register a function to a LAF object and then call something like Content.setTitleBarLookAndFeel (LAF). How would previewing it go, though? Probably a floating tile?</p>
]]></description><link>https://forum.hise.audio/topic/9128/custom-title-bar-for-standalone</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 13:27:19 GMT</lastBuildDate><atom:link href="https://forum.hise.audio/topic/9128.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Feb 2024 21:10:23 GMT</pubDate><ttl>60</ttl></channel></rss>