[Laszlo-user] syntax problem using variables in a view's x and y

P T Withington ptw at openlaszlo.org
Thu Apr 6 11:43:20 EDT 2006


A view's x and y position are always relative to its parent view,  
whether you are setting or getting them.  Only a view on the canvas  
is relative to the canvas.  See getAttributeRelative and  
setAttributeRelative.  They can be used to translate x and y to  
another coordinate system (such as the canvas).  Once you get your  
head wrapped around it, relative coordinate systems are easier to  
deal with [they must be -- the display hardware has to deal in  
absolute coordinates, so why else would graphics systems have a layer  
of abstraction to create relative coordinate systems?  They would be  
much faster without them. :)]

On 2006-04-06 07:33 PDT, William Krick 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



More information about the Laszlo-user mailing list