PDA

View Full Version : Circular Constraints


antun
05-08-2003, 04:04 PM
Laszlo resolves circular constraints very well. In the following example the red view's y attribute is constrained to the blue view's y attribute, and vice versa:


<canvas>
<view name="redview" bgcolor="red"
onmousedown="ds.apply()" onmouseup="ds.remove()"
width="40" height="40" y="blueview.y">
<dragstate name="ds"/>
</view>
<view name="blueview" bgcolor="blue"
onmousedown="ds.apply()" onmouseup="ds.remove()"
width="40" height="40" y="redview.y">
<dragstate name="ds"/>
</view>
<simplelayout spacing="40" axis="x"/>
</canvas>


Enjoy!

ows
05-10-2003, 02:47 PM
You can use circular constraints to specify an aspect ratio for a window (or other view):


<window width="this.height*2.35" height="this.width/2.35"/>


The following fragment defines a tag 'aspectwindow', that takes an attribute that defines the aspect ratio:


<class name="aspectwindow" extends="window"
width="this.height*this.aspectratio" height="this.width/this.aspectratio">
<attribute name="aspectratio" value="1"/>
</class>

<aspectwindow title="Movie" aspectratio="2.35"/>
<aspectwindow title="Television" aspectratio="4/3"/>


(Warning: I haven't tested any of this code yet. I'll edit this comment out when I get around to that.)