More widgets please!


#1

It would be nice to have access to more widgets in the Jucer; for example, I’d like to be able to create different types of buttons (text button with graphic and text, button that is only an image.


#2

I just added imagebuttons to it recently…


#3

Do you mean File->New Button?


#4

No, I mean “create a new ImageButton”.


#5

I must have an older version.

I built 1.45 and I also downloaded it from the download page. Is this change only in SVN?

Edit: Downloaded from SVN and there it is.


#6

Jules,

This is a pretty old post but you said above that you implemented ImageButton to address (among other things) the text button with graphic and text issue (not being able to simply combine text over an image in a button).

But text option is not available for ImageButton, is it ?

I mean doing something like imageButton.setText("blablabla") will do nothing, right ?


#7

It's a ridiculously old post, I've no idea what state the library was in back in 2007!

Maybe the DrawableButton would do what you need?


#8

Ha ha ! I'm not asking what the library was in 2007, but what it is like now. I thought maybe I was missing something with ImageButton class.

Sorry for the confusion. I guess your answer means that in order to use a button with text and a graphics background your best choice remains a DrawableButton. Thanks for that.

 


#9

... except that for DrawableButtons the text label will be below the image, not merged on top of it....


#10

... or you can do what I did and use TextButtons, overriding the drawButtonBackground LookAndFeel method, e.g.

void BCMLookAndFeel::drawButtonBackground
(
    Graphics& g,
    Button& button,
    const Colour& backgroundColour,
    bool isMouseOverButton,
    bool isButtonDown
)
{
    bool toggleState = button.getToggleState();

    if (textButtonUp.isValid() && textButtonDown.isValid() && textButtonOverDown.isValid() && textButtonOverUp.isValid())
    {
        Image buttonImage;
        
        if (isMouseOverButton)
        {
            if (isButtonDown || toggleState)
                buttonImage = textButtonOverDown;
            else
                buttonImage = textButtonOverUp;
        }
        else
        {
            if (isButtonDown || toggleState)
                buttonImage = textButtonDown;
            else
                buttonImage = textButtonUp;
        }
           
        g.drawImage(buttonImage, 0, 0, buttonImage.getWidth(), buttonImage.getHeight(), 0, 0, buttonImage.getWidth(), buttonImage.getHeight());
    }
    else
        LookAndFeel_V3::drawButtonBackground(g, button, backgroundColour, isMouseOverButton, isButtonDown);
}

#11

Thank you w_ellis.

I ended up doing something similar using a transparent TextButton over a DrawableImage. But your solution is more elegant.


#12