Here's a simplified version of what I got to work, which now that I look at
it is a wee bit more complicated that I remembered. You have to redraw the
shape whenever the size changes! This code tries to be lazy about that, only
resizing once after both the width and height change. 

        -Don


<canvas
  width="100%"
  height="100%"
  proxied="false"
>

  <drawview
    id="myFrame"
    width="${parent.width}"
    height="${parent.height}"
  >


    <attribute name="setSizeLaterDelegate" value="$once{new LzDelegate(this,
'setSizeLater')}"/>
    <attribute name="setSizeLaterDelegateTriggered" value="false"/>
    

    <method name="invalidateSize"><![CDATA[
        if (this.setSizeLaterDelegateTriggered) {
          return;
        }
        LzIdle.callOnIdle(this.setSizeLaterDelegate);
        this.setSizeLaterDelegateTriggered = true;
      ]]>
    </method>


    <method name="setSizeLater"><![CDATA[
        Debug.write("setSizeLater", this, this.width, this.height);
        this.setSizeLaterDelegateTriggered = false;
        this.setSizeNow();
      ]]>
    </method>


    <method name="setSizeNow"><![CDATA[
Debug.write("frame setSizeNow", this);
        var width = this.width;
        var height = this.height;
        this.clearMask();
        this.oval(
          width / 2,
          height / 2,
          width / 2,
          height / 2);
        this.clip();
      ]]>
    </method>


    <method event="onwidth"><![CDATA[
        this.invalidateSize();
      ]]>
    </method>


    <method event="onheight"><![CDATA[
        this.invalidateSize();
      ]]>
    </method>


    <view id="yellowThing" 
      width="${parent.width}"
      height="${parent.height}"
      bgcolor="0xffff00"
    />


  </drawview>

</canvas>



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

Reply via email to