Tooltip window too small


#1

I’m trying to work out how to increase the size of my tooltip window (without hacking into JUCE!)

I wonder if its something to do with the font I’m using…?

35

Is there a way of setting the size of the TooltipWindow? Calling setSize seems to have no effect. I guess it works it out from the font+text size.


#2

Reducing the font size seems to get the text to fit, however, it then becomes tiny.

My L&F code:

    void drawTooltip (Graphics& g, const String& text, int width, int height) override
    {
        Rectangle<int> bounds (width, height);
        const auto cornerSize = 5.0f;

        g.setColour (findColour (TooltipWindow::backgroundColourId));
        g.fillRoundedRectangle (bounds.toFloat(), cornerSize);

        g.setColour (findColour (TooltipWindow::outlineColourId));
        g.drawRoundedRectangle (bounds.toFloat().reduced (0.5f, 0.5f), cornerSize, 1.0f);

        layoutTooltipText (text, findColour (TooltipWindow::textColourId))
                .draw (g, Rectangle<float> ((float) width, (float) height));
    }

    static TextLayout layoutTooltipText (const String& text, Colour colour) noexcept
    {
        const float tooltipFontSize = 15.0f;
        const int maxToolTipWidth = 400;

        AttributedString s;
        s.setJustification (Justification::centred);
        s.append (text, Font (tooltipFontSize), colour);

        TextLayout tl;
        tl.createLayoutWithBalancedLineLengths (s, (float) maxToolTipWidth);
        return tl;
    }

#3

LookAndFeel_V2::getTooltipBounds()

https://www.juce.com/doc/classLookAndFeel__V2#a6af715d801db915d661e103603a2e721

Rail


#4

Aha, yes, missed that, sorted cheers :+1: