Constraints are allowed to be arbitrary expressions, so you could write:

   width="parent.width > 0 ? parent.width - 20 : 0"

Or you could create a subclass of view that enforces minimums:

<class name="minview" extends="view">
   <attribute name="minwidth" value="0" />
   <method name="setWidth" args="newwidth">
     super.setWidth(newwidth &lt; minwidth ? minwidth : newwidth);
   </method>
</class>

Of course, you might also hope that the basic view would not let you  
set your width to a negative number...

On 2006-09-23, at 01:25 EDT, [EMAIL PROTECTED] wrote:

> In my example below, I create a view with a smaller nested view.  The
> inner view gets its size from constraints based on the its parent.
> The problem is, when the parent is resized too small, the constraints
> on the inner view become negative.  If you run my app, you can adjust
> the size with the slider and see what happens.  Basically, I need some
> way to have a constraint that tracks the parent, but cannot become
> negative.  Is there some way to do this in a contstraint?  Or possibly
> a different solution that doesn't have the negative constraint  
> problem?
>
>
> <canvas>
>
>    <view x="20" y="20" layout="axis:y">
>      <view layout="axis:x">
>        <text text="outer view size: "/>
>        <slider id="sizeslider" width="100" showvalue="true"  
> value="50"/>
>      </view>
>      <view layout="axis:x">
>        <text text="inner view size: "/>
>        <text text="${box.subviews[0].height}" bgcolor="silver"/>
>      </view>
>    </view>
>
>    <view id="box" x="20" y="80" bgcolor="blue"
>          width="${sizeslider.value}" height="${sizeslider.value}">
>      <view bgcolor="green" x="10" y="10"
>            width="${parent.width - 20}" height="${parent.height -  
> 20}"/>
>    </view>
>
>
> </canvas>
>
>
> _______________________________________________
> Laszlo-user mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user


_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to