Help with drawableButton drawable justification

i try to set up a drawableButton with different sized drawables for the different states ( shiny light around the on state image).
problem is that the drawables are always drawn in the upper left corner of the button area. i need them centred, otherwise the button ‘jumps around’ when activated. I had a look into the class inside the juce code and it seems when using ImageRaw there is no justification possible.

the doc says:
"This leaves it up to the caller to make sure the images are the correct size and position for the button. "

but the drawable class hast no methods to set it’s bounds. only way i can think of at the moment is the drawWithin method, but this is not called when using ImageRaw.

so how do i have to proceed if i need a drawableButton with centred, but not resized drawables?

any hints welcome! :wink:
comboy

1 Like

You’d have to set their positions so that they’re relative to each other in the positions you want them to be, and so that they’re centred within the size of the button that you’re using.

yes - but how do i do it?

http://www.rawmaterialsoftware.com/juce/api/classDrawable-members.html

i can’t find any setPosition member or similar for the drawables

1 Like

Well, you’re creating these drawables, so you must be putting something in them! Just put it somewhere else!

Or you could embed a drawable inside a DrawableComposite, and then you can shift it around in any way you want.

i create them from an image file.
i tried using same sized images, but juce cuts away the alpha parts, so the alignment is lost again.

i think I’ll take the drawableComposite route then.

anyway, thanks for the help :slight_smile:

No, there’s no code that would remove any transparent areas… if that’s happening, then it must be your image editor that’s doing it.

I’m also trying to use DrawableButton with a simple SVG image. I’d like the button to display the image centered in its original size, but can’t find way to accomplish this. I’m using ButtonStyle::ImageRaw as that’s the only one that don’t stretch it. The SVG has whatever size it has and the drawable seems to have bounds matching size and origin at zero - just as one would expect. The image appears at top left, which i’d imagine no one would ever want. I would expect some way to be able to make the drawable appear centered.