[Laszlo-checkins] r10106 - openlaszlo/trunk/lps/components/extensions

max@openlaszlo.org max at openlaszlo.org
Fri Jun 27 20:09:22 PDT 2008


Author: max
Date: 2008-06-27 20:09:15 -0700 (Fri, 27 Jun 2008)
New Revision: 10106

Modified:
   openlaszlo/trunk/lps/components/extensions/drawview.lzx
Log:
Change 20080627-maxcarlson-I by maxcarlson at Roboto on 2008-06-27 19:26:32 PDT
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Support automatic resizing of drawview in Flash

Bugs Fixed: LPP-4836 - Drawview does not update its size in 4.0.5

Technical Reviewer: promanik
QA Reviewer: akarlovac

Details: Fix conditionalization, indentation around swf9.  Add __updateSize() method for swf8.

Tests: See LPP-4836.  test/drawing/drawing.lzx runs in swf8, swf9 and dhtml.



Modified: openlaszlo/trunk/lps/components/extensions/drawview.lzx
===================================================================
--- openlaszlo/trunk/lps/components/extensions/drawview.lzx	2008-06-28 03:06:16 UTC (rev 10105)
+++ openlaszlo/trunk/lps/components/extensions/drawview.lzx	2008-06-28 03:09:15 UTC (rev 10106)
@@ -882,6 +882,8 @@
             var __bitmapdata = null;
             var __drawing = null;
             var __matrix = null;
+            var __measurewidth = true;
+            var __measureheight = true;
             
             var oncontext = LzDeclaredEvent;
     
@@ -902,6 +904,9 @@
 
             // Add bitmap data drawing layer
             function rebuildBitmap (ignore) {
+                if ($swf9) {
+                    return;
+                }
                 if (this['__bitmapmc']) {
                     this.__bitmapmc.removeMovieClip();
                 }
@@ -1009,31 +1014,28 @@
                 }
             }
 
-            if ($swf9) {
-            } else {
-                function drawImage(image, x, y, w, h, r) {
-                    if ($swf7) {
-                        if ($debug) Debug.warn('Drawview.drawImage() is supported in swf7.');
-                    } else {
-                        if (typeof image == 'string') {
-                            image = this.getImage(image);
-                        }
-                        if (! image) return;
+            function drawImage(image, x, y, w, h, r) {
+                if ($swf9) {
+                    if ($debug) Debug.warn('Drawview.drawImage() is not yet supported in swf9.');
+                } else {
+                    if (typeof image == 'string') {
+                        image = this.getImage(image);
+                    }
+                    if (! image) return;
 
-                        var m = this.getIdentityMatrix();
+                    var m = this.getIdentityMatrix();
 
-                        var tw = w ? w / image.width : 1;
-                        var th = h ? h / image.height : 1;
-                        m.scale(tw, th);
+                    var tw = w ? w / image.width : 1;
+                    var th = h ? h / image.height : 1;
+                    m.scale(tw, th);
 
-                        if (r != null) m.rotate(r);
+                    if (r != null) m.rotate(r);
 
-                        var tx = x ? x : 0;
-                        var ty = y ? y : 0;
-                        m.translate(tx, ty);
+                    var tx = x ? x : 0;
+                    var ty = y ? y : 0;
+                    m.translate(tx, ty);
 
-                        this.copyBitmap(image, this.width, this.height, this.__bitmapdata, m);
-                    }
+                    this.copyBitmap(image, this.width, this.height, this.__bitmapdata, m);
                 }
             }
     
@@ -1172,7 +1174,7 @@
                 this.closePath();
                 this.__playPath(this.context);
                 this.context.endFill();
-                this.sprite.updateResourceSize();
+                this.__updateSize();
             }
     
             function __playPath(m) {
@@ -1197,48 +1199,48 @@
             }
     
             if ($swf9) {    
-            function clipPath() {
-                if ($debug) {
-                    Debug.warn('Drawview.clipPath() is not currently supported in swf9.');
+                function clipPath() {
+                    if ($debug) {
+                        Debug.warn('Drawview.clipPath() is not currently supported in swf9.');
+                    }
                 }
-            }
 
-            function clipButton() {
-                if ($debug) {
-                    Debug.warn('Drawview.clipButton() is not currently supported in swf9.');
+                function clipButton() {
+                    if ($debug) {
+                        Debug.warn('Drawview.clipButton() is not currently supported in swf9.');
+                    }
                 }
-            }
             } else {
-            function clip() {
-                if ($debug) Debug.warn('drawview.clip() is deprecated.  Use clipPath() instead.');
-                this.clipPath();
-            }
-            function clipPath() {
-                this.sprite.applyMask(true);
-                var __clipmc = this.sprite.__LZmaskClip;
-                this.closePath();
-                __clipmc.clear();
-                __clipmc.beginFill(0xffffff, 100);
-                this.__playPath(__clipmc);
-                __clipmc.endFill();
-                this.updateResourceSize();
-            }
-            function clipButton() {
-                var mc = this.getMCRef();
-                //Debug.write('clip', this, mc, this.sprite.__LZbuttonRef);
-                if (! this['__clipmc']) {
-                    this.__clipmc = this.sprite.__LZmovieClipRef.createEmptyMovieClip("$lzclipmc", 6);
-                    this.sprite.__LZbuttonRef.setMask(this.__clipmc);
+                function clip() {
+                    if ($debug) Debug.warn('drawview.clip() is deprecated.  Use clipPath() instead.');
+                    this.clipPath();
                 }
-                this.closePath();
+                function clipPath() {
+                    this.sprite.applyMask(true);
+                    var __clipmc = this.sprite.__LZmaskClip;
+                    this.closePath();
+                    __clipmc.clear();
+                    __clipmc.beginFill(0xffffff, 100);
+                    this.__playPath(__clipmc);
+                    __clipmc.endFill();
+                    this.updateResourceSize();
+                }
+                function clipButton() {
+                    var mc = this.getMCRef();
+                    //Debug.write('clip', this, mc, this.sprite.__LZbuttonRef);
+                    if (! this['__clipmc']) {
+                        this.__clipmc = this.sprite.__LZmovieClipRef.createEmptyMovieClip("$lzclipmc", 6);
+                        this.sprite.__LZbuttonRef.setMask(this.__clipmc);
+                    }
+                    this.closePath();
 
-                this.__clipmc.clear();
-                this.__clipmc.beginFill(0xffffff, 100);
-                this.__playPath(this.__clipmc);
-                this.__clipmc.endFill();
-                this.updateResourceSize();
+                    this.__clipmc.clear();
+                    this.__clipmc.beginFill(0xffffff, 100);
+                    this.__playPath(this.__clipmc);
+                    this.__clipmc.endFill();
+                    this.updateResourceSize();
+                }
             }
-            }
     
             function stroke() {
                 if (this.strokeStyle instanceof LzCanvasGradient) {
@@ -1252,8 +1254,28 @@
                 this.context.lineStyle(this.lineWidth, color.c, alpha * 100);
                 this.__playPath(this.context);
                 this.context.lineStyle(undefined);
-                this.sprite.updateResourceSize();
+                this.__updateSize();
             }
+
+            if ($swf8) {
+                function setWidth(w, ...internal) {
+                    if (internal.length == 0) this.__measurewidth = w == null;
+                    super.setWidth(w);
+                }
+
+                function setHeight(h, ...internal) {
+                    if (internal.length == 0) this.__measureheight = h == null;
+                    super.setHeight(h);
+                }
+            }
+
+            function __updateSize() {
+                if ($swf8) {
+                    var mc = this.sprite.getContext();
+                    if (this.__measurewidth) this.setWidth(mc._width, true);
+                    if (this.__measureheight) this.setHeight(mc._height, true);
+                }
+            }
     
             function clear() {
                 this.context.clear();



More information about the Laszlo-checkins mailing list