Help with drawableButton drawable justification


#1

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


#2

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.


#3

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


#4

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.


#5

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:


#6

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.