View Full Version : uniform spacing of children within resizable view
johnagrandy
08-02-2003, 06:29 PM
hi antun.
for the middle view of a horizontal stableborderlayout (or a horizontal resizelayout with middle view releasedtolayout), is there a simple way to cause the view's child controls (e.g. buttons) to be positioned symmetrically ? (the buttons don't resize, they just get "spaced-out" uniformly)
thanks.
antun
08-03-2003, 11:43 PM
Can you show me what code you're trying to run?
I think you would have to act on the children of the view that you would want to have resize, but I'd have to see the code.
-Antun
johnagrandy
08-04-2003, 04:17 PM
i do have questions about the code i'm trying to run .... but i also suspect there is a built-in lzx ability to space equal-width objects evenly over a horizontal range.
here is my code:
<view bgcolor="#bdbdbd" width="parent.width" height="this.leftButtons.refButton.height + 8">
<resizelayout axis="x" spacing="5" />
<view name="leftButtons" left="5" valign="middle">
<button name="refButton">1</button>
</view>
<view name="middleButtons" options="releasetolayout" valign="middle">
<attribute name="spacer" when="always" value="(this.width - 3 * this.refButton.width)/4" />
<simplelayout axis="x" spacing="5" />
<button name="refButton" left="parent.spacer">2</button>
<button left="${parent.spacer * 2 + this.width}">3</button>
<button left="${parent.spacer * 3 + this.width * 2}">4</button>
</view>
<view width="${parent.leftButtons.width}" />
</view>
also: while its great that tag attributes can use ${} to include javascript, i wonder about why lzx sometimes requires this and sometimes does not.
example:
<view height="parent.height">
works fine ...
so why does
<button name="refButton" left="parent.spacer">1</button>
give a "reference to undefined variable 'parent' error" ? ... but the problem is solved if ${} used ...
antun
08-05-2003, 01:14 AM
You might want to check out <wrappinglayout>. There's a thread about it here:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=282&highlight=wrappinglayout
Let me know if that works for you.
also: while its great that tag attributes can use ${} to include javascript, i wonder about why lzx sometimes requires this and sometimes does not.
This is really a legacy issue. It used to be that you could only write constraints in attributes for non-custom numeric attributes:
x="parent.with/2"
... but if you wanted to do anything like use a custom attribute, or a non-numeric value, you would have to use the <attribute> tag.
Now you can use the ${} syntax to do just about any attribute evaluation inside of an attribute, however we retained the old x="parent.with/2" syntax for backwards compatability, although that syntax is not formally deprecated at the moment.
If unsure, use the ${} syntax.
-Antun
johnagrandy
08-05-2003, 01:46 AM
Antun, are you saying that because "spacer" is a custom attribute, referring to it in attribute value assignments inside tags must be done with ${} ?
... but that's not consistent with the error message = "reference to undefined variable 'parent'" ... it's not able to evaluate "parent", it doesn't even get to "parent.spacer" ...
antun
08-05-2003, 02:31 AM
No, what I'm saying is that it used to be that since height and width were both numeric, you could say:
<view height="width/2">
I believe also that this was dependent on not being a custom attribute, but I'm not 100% sure there.
I would like to give you an example regarding what you said:
<button name="refButton" left="parent.spacer">1</button>
... but there isn't a "left" attribute for button. Can you tell me what you intended to write there?
-Antun
johnagrandy
08-05-2003, 09:07 AM
oh, ok, "x", not "left"
i was getting bogus error messages from lde. it should have caught that "left" is not a intrinsic attribute of button.
antun
08-05-2003, 09:22 AM
You're right, it should give you a practical error message. Could you post the code you were writing to get the bogus error?
When I do:
<canvas>
<view>
<button name="refButton" left="parent.spacer">1</button>
</view>
</canvas>
I get a Compliation Warning that says:
attributeerror.lzx:3:55: attribute "left" not allowed at this point; ignored
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.