It seems like the mask clip needs to be maintained along the current background, possibly in a separate method a la LzSprite.drawBackground(). I've attached a quick patch that may help.

On 2/2/10 1:45 PM, Raju Bitter wrote:
Good point! My focus was on getting the clipping right.

There still needs to be optimization for showing borders AND rounded corners. 
The borders are partially cut off in that case.

Thanks,
Raju

On Feb 2, 2010, at 10:11 PM, Max Carlson wrote:

This looks like a great start.  When cornerradius>  0, won't you need to redraw 
the mask clip when setWidth/Height() is called?

Regards,
Max Carlson
OpenLaszlo.org

On 2/2/10 1:52 AM, Raju Bitter wrote:
Max,

I just saw that called svn-review out of the test folder. Here's an updated 
version from the $LZ_LPS_ROOT folder.

- Raju

Change 20100202-raju-J by [email protected] on 2010-02-02 
10:05:25 CET
     in /Users/rajubitter/src/svn/openlaszlo/trunk-corner
     for http://[email protected]/openlaszlo/trunk

Summary: Support for clipping views with rounded corners in AS3 runtimes

New Features:
Add support for masking sprites with rounded corners in AS3 based runtimes.

Bugs Fixed: http://jira.openlaszlo.org/jira/browse/LPP-8508

Technical Reviewer: [email protected]
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Overview:


Details:
Details can be found in this email on laszlo-dev:
http://www.openlaszlo.org/pipermail/laszlo-dev/2010-January/022415.html

Tests:
test/css/roundedcorner/roundedcornerclip_as3.lzx

Files:
A       test/css/roundedcorner
A       test/css/roundedcorner/Laszlo-Moholy-Photogramm.jpg
A       test/css/roundedcorner/roundedcornerclip_as3.lzx
M       WEB-INF/lps/lfc/kernel/swf9/LzSprite.as

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20100202-raju-J.tar

Index: WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- WEB-INF/lps/lfc/kernel/swf9/LzSprite.as     (revision 15597)
+++ WEB-INF/lps/lfc/kernel/swf9/LzSprite.as     (working copy)
@@ -245,17 +245,41 @@
         if (this.borderWidth) {
             var colorobj = LzColorUtils.inttocolorobj(borderColor);
             context.beginFill(colorobj.color, alpha);
-            var offset = this.padding + this.borderWidth;
-            LzKernelUtils.rect(context, 0 - offset, 0 - offset, this.lzwidth + 
(offset * 2), this.lzheight + (offset * 2), this.cornerradius);
+            this.drawBorder(context);
             context.endFill();
         }
         if (bgcolor != null) {
             context.beginFill(this.bgcolor, alpha);
-            LzKernelUtils.rect(context, 0 - this.padding, 0 - this.padding, 
this.lzwidth + (this.padding * 2), this.lzheight + (this.padding * 2), 
this.cornerradius);
+            this.drawBGColor();
             context.endFill();
         }
+
     }
 
+    public function drawMask():void {
+        if (this.masksprite) {
+            var context = this.masksprite.graphics;
+            context.clear();
+            context.beginFill(0xffffff);
+            this.drawBorder(context);
+            this.drawBGColor(context);
+            context.endFill();
+        }
+    }
+
+    private function drawBorder(context):void {
+        if (this.borderWidth) {
+            var offset = this.padding + this.borderWidth;
+            LzKernelUtils.rect(context, 0 - offset, 0 - offset, this.lzwidth + 
(offset * 2), this.lzheight + (offset * 2), this.cornerradius);
+        }
+    }
+
+    private function drawBGColor(context):void {
+        if (bgcolor != null) {
+            LzKernelUtils.rect(context, 0 - this.padding, 0 - this.padding, 
this.lzwidth + (this.padding * 2), this.lzheight + (this.padding * 2), 
this.cornerradius);
+        }
+    }
+
     private var _frame:int = 1;
 
     public function set frame (fr:int) :void {
@@ -957,9 +981,7 @@
 
         // Update the clip region if there is one
         if (this.masksprite) {
-            //trace('...sprite setting mask w,h', this.lzwidth ,this.lzheight);
-            this.masksprite.scaleX = this.lzwidth;
-            this.masksprite.scaleY = this.lzheight;
+            this.drawMask();
         }
 
         drawBackground();
@@ -981,9 +1003,7 @@
 
         // Update the clip region if there is one
         if (this.masksprite) {
-            //trace('...sprite setting mask w,h', this.lzwidth ,this.lzheight);
-            this.masksprite.scaleX = this.lzwidth;
-            this.masksprite.scaleY = this.lzheight;
+            this.drawMask();
         }
         drawBackground();
     }
@@ -1285,12 +1305,6 @@
         var ms:Sprite = this.masksprite;
         if (ms == null) {
             ms = new Sprite();
-            ms.graphics.clear();
-            ms.graphics.beginFill(0xffffff);
-            ms.graphics.drawRect(0, 0, 1, 1);
-            ms.graphics.endFill();
-            ms.scaleX = this.lzwidth;
-            ms.scaleY = this.lzheight;
             addChild(ms);
             this.mask = ms;
             this.masksprite = ms;
@@ -1300,16 +1314,15 @@
                 addChild(ms);
                 this.mask = ms;
             }
-            //trace('applyMask [2] ', this.lzwidth, this.lzheight, owner);
-            ms.scaleX = this.lzwidth;
-            ms.scaleY = this.lzheight;
         }
+        this.drawMask();
     }
 
     public function removeMask():void {
         if (this.mask != null) {
             this.removeChild(this.masksprite);
             this.mask = null;
+            this.masksprite = null;
         }
     }
 
_______________________________________________
Laszlo-reviews mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews

Reply via email to