[Laszlo-user] syntax problem using variables in a view's x and y
P T Withington
ptw at openlaszlo.org
Thu Apr 6 12:27:38 EDT 2006
That might be a better (or more intuitive) interface than
getAttributeRelative. We surely want to add more CSS support.
On 2006-04-06 08:35 PDT, graphis1 at mac.com wrote:
>
> Would it make more sense to propose the addition of a "position"
> attribute to the view class? It could be set to "absolute" or
> "relative" (and default to absolute) - this would mirror the CSS
> attribute of the same name.
>
> Getting and setting the x or y position of a relatively positioned
> view would set or return the value relative to parent, whilst
> getting or setting an absolutely positioned view would set or
> return the value relative to canvas.
>
> I suspect this could also be achieved by creating a custom layout
> with a position attribute, or by extending the view class.
>
>
>
> On Thursday, April 06, 2006, at 03:37PM, William Krick <wkrick at eio-
> online.com> wrote:
>
>> I was wondering if anyone had any thoughts on "x" vs "absolutex"...
>> -----Original Message-----
>> From: William Krick [mailto:wkrick at eio-online.com]
>> Sent: Thursday, February 09, 2006 3:05 PM
>> To: laszlo-user at openlaszlo.org
>> Subject: RE: [Laszlo-user] syntax problem using variables in a
>> view's x
>> and y
>>
>>
>> Ok, that makes sense now.
>>
>> It *is* a little strange though in that it isn't symmetrical...
>>
>> When I query a view for its x or y, it gives me its position
>> relative to the canvas, but when I set a view's x or y, I'm
>> setting the its position relative to its parent.
>>
>> I think it would make more sense if there were two types of x
>> positions..
>>
>> view.x and view.absolutex
>>
>> view.x is always the x relative to the view's parent.
>>
>> view.absolutex is always the x relative to the canvas.
>>
>> Obviously, this all applies to y as well.
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: Dan Stowell [mailto:dstowell at laszlosystems.com]
>> Sent: Thursday, February 09, 2006 2:47 PM
>> To: William Krick; laszlo-user at openlaszlo.org
>> Subject: RE: [Laszlo-user] syntax problem using variables in a
>> view's x
>> and y
>>
>>
>>> But shouldn't it still work with parent.x+5 anyway?
>>
>> Not quite. parent.x refers to the parent's x position relative to the
>> canvas. In your example, the first red view has an x of 0 in the
>> canvas.
>> The interior view is constrained to have an x of parent.x + 5, which
>> works out to 5 in this case. The second red view has an x of 100
>> relative to the canvas. The interior view therefore has an x of 105.
>> Since it is being place 105 pixels from the left of the second red
>> view,
>> the views are not working as desired. Here's a modified version:
>>
>> <canvas width="600" height="400">
>>
>> <simplelayout axis="x"/>
>>
>> <view name="first"
>> bgcolor="red" width="100" height="100">
>> <view bgcolor="black"
>> width="${ parent.width - 10 }" height="$
>> { parent.height -
>> 10 }"
>> x="5" y="5"/>
>> </view>
>>
>> <view name="second"
>> bgcolor="red" width="100" height="100">
>> <view bgcolor="black"
>> width="${ parent.width - 10 }" height="$
>> { parent.height -
>> 10 }"
>> x="5" y="5"/>
>> </view>
>>
>> </canvas>
>>
>>>> <canvas width="600" height="400">
>>>> <simplelayout axis="x"/>
>>>>
>>>> <view bgcolor="red" width="100" height="100">
>>>> <view bgcolor="black"
>>>> width="${parent.width-10}"
>>>> height="${parent.height-10}"
>>>> x="${parent.x+5}"
>>>> y="${parent.y+5}"/>
>>>> </view>
>>>>
>>>> <view bgcolor="red" width="100" height="100">
>>>> <view bgcolor="black"
>>>> width="${parent.width-10}"
>>>> height="${parent.height-10}"
>>>> x="${parent.x+5}"
>>>> y="${parent.y+5}"/>
>>>> </view>
>>>>
>>>> </canvas>
>>>> _______________________________________________
>>>> Laszlo-user mailing list
>>>> Laszlo-user at openlaszlo.org
>>>> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>>>
>>>
>>> Dan Stowell
>>> Software Engineer
>>> Laszlo Studios
>>>
>>>
>>>
>>
>>
>> Dan Stowell
>> Software Engineer
>> Laszlo Studios
>>
>>
>>
>>
>> _______________________________________________
>> Laszlo-user mailing list
>> Laszlo-user at openlaszlo.org
>> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>>
>>
>>
>> _______________________________________________
>> Laszlo-user mailing list
>> Laszlo-user at openlaszlo.org
>> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
>>
>>
> _______________________________________________
> Laszlo-user mailing list
> Laszlo-user at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
More information about the Laszlo-user
mailing list