DrawableButton inset


#1

DrawableButton is currently driving me up the wall!

I’m making a simple button with a triangle to control pop-out sections of a GUI; when the section is closed, the button shows a right or down facing triangle to indicate that it will expand, and a left or up facing triangle to show it will pull in.

But the indent thing is really bugging me! I can’t be arsed recompiling juce this minute, so though i’d make a request til i can. Can we set this please?

Right now, i can’t get the horizontal and vertical versions to behave the same.

As the horizontal-pointing one is narrower, the inset forces the graphic to be small. i like that it’s not so close to the edge. But the vertical pointing one goes right to the edges as there’s a fixed vertical inset of 4 (whereas horizontal inset is width/4).

[EDIT] i’m using it with the ‘on button background mode’ because that’s how i want it. Also, when it’s on the ‘fitted’ mode, the colours (toggled off specifically) don’t work[/EDIT]


#2

Found the fix for the ‘fitted’ mode…
[i’m happy to use that for now, i can’t be arsed tinkering with the rest of it :hihi:]

I’ve changed the following…
juce_drawableButton.cpp

184: //        if (getToggleState())
185:           g.fillAll (getBackgroundColour());

getBackgroundColour returns the correct colour for the state (which it checks itself), so the check here caused it to not bother with the ‘off’ state.


#3

Ta for that fix - I think you’re right about that.

And looking at that inset code, it does seem a bit strange. It should probably be changed to something along these lines:

[code] if (style == ImageOnButtonBackground)
{
const int insetX = getWidth() / 4;
const int insetY = getHeight() / 4;

    imageSpace.setBounds (insetX, insetY, getWidth() - insetX * 2, getHeight() - insetY * 2);

    getLookAndFeel().drawButtonBackground (g, *this,
                                           getBackgroundColour(),
                                           isMouseOverButton,
                                           isButtonDown);
}[/code]

#4