Can't get simple setBound(RelativeRectangle) to work


#1

Hi guys,

This works:

void MyComponent::resized()
{
m_SubComponent->setBounds (544, 24, 432, 560);

//[UserResized] Add your own custom resize handling here..
//[/UserResized]

}

This doesn’t:

void MyComponent::resized()
{
m_SubComponent->setBounds (544, 24, 432, 560);

//[UserResized] Add your own custom resize handling here..
m_SubComponent->setBounds("544,24,432,560");
//[/UserResized]

}

I put a breakpount in my subcomponent paint( ) and in the first case it’s reached, but in the second, it isn’t… I wanted to do some more fancy layout with autosizing, but… if this one doesn;t work I guess the more fancy ones won’t either :slight_smile:

  • bram

#2
setBounds("544,24,432,560");

that will never work, remove the quotes …


#3

I beg to differ:

http://www.rawmaterialsoftware.com/juce/api/classComponent.html#a821833808f451753df397802d9d6160a

that’s the whole point of the RelativeRectangle stuff…


#4

The first version uses normal int parameters, which fit the form: x,y,width,height.
The second version, using a string expression, takes a slightly different form: left,top,right,bottom

Thus, your examples are not equivalent. For the second to be the same as the first, you could do:

“544, 24, left+432, top+560”


#5

ah yes sorry i thought this was a normal Rectangle, my mistake.


#6

Ah, thanks haydxn,
I had failed to see that!

Using “544, 24, 544+parent.width, 24+parent.width” does scale it the way I want!

  • bram