Jucer Relative Layout Seems Broken


After tediously calculating layouts for resizable components and using the setBoundsRelative method for resizing, I discovered the relative modes of layout in the Jucer. But they don’t appear to work correctly.

For example, suppose I’ve got a component with width 600 and height 400 and place a button (width: 100, height:24) so that it’s centered using absolute coordinates at x=250, y=188. I then set the mode for the x position to “percentage of width of parent, anchored at left, relative to the parent component” and the mode for the y position to “percentage of height of parent, anchored at top. relative to the parent component”. It puts the percentages at 18.222% for the x position and 20.324% for the y position. Now these percentages should 41.667 (250/600100) and 47.0 (188/400100) respectively. Putting these latter numbers (and similar modes for the button width and height) in a setBoundsRelative call works as expected.


No, there’s no bug with that code, you’re must be using a parent size that isn’t what you think it is… Did you set the “keep component size fixed” option in the class properties?


Changing the class property, “fixed size” to “keep component size fixed” fixed my problem, but I maintain that there’s still a bug, maybe not with the code but with the design. When the bounds mode for a control is “percentage of parent width” etc, it should be relative to the parent. While in the Jucer, that parent may be the workspace (the class property value “Resize component to fit workspace”), but in a running program, a control’s parent should be the component containing the control. In that case "percentage of the parent’s, say width, should be the width of the component. Perhaps I’m misunderstanding what the fixed size property is–but it seems to be a Jucer property not a Component property. If that’s the case, then “percentage of the parent width” should mean the component regardless of the value of “fixed size”.

However, I’d assign the bug a low severity since there is a work around.


No, there’s definitely no bug!

If that’s the case, then “percentage of the parent width” should mean the component regardless of the value of “fixed size”. [/quote]

It does always mean that. Obviously if you set the fixed size, then that IS the current size of the parent. You’re certainly confused about something, but I can’t figure out what!