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

bargull@openlaszlo.org bargull at openlaszlo.org
Wed Feb 25 14:13:30 PST 2009


Author: bargull
Date: 2009-02-25 14:13:27 -0800 (Wed, 25 Feb 2009)
New Revision: 13061

Modified:
   openlaszlo/trunk/lps/components/extensions/drawview.lzx
Log:
Change 20090225-bargull-ZKJ by bargull at dell--p4--2-53 on 2009-02-25 00:07:21
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: gradient alpha bug (dhtml) and resize bug (swf)

New Features:

Bugs Fixed: LPP-7755 (DHTML: gradient doesn't work properly), LPP-7380 (drawview does not resize after redraw)

Technical Reviewer: promanik
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
LPP-7755:
- add globalAlpha in addColorStop(), unless an explicit alpha was already provided

LPP-7380:
- remove __bitmapmc when context-size needs to be measured
- set __measurewidth/__measureheight again to true after resize
    

Tests:
testcases from bugreports
(note: gradient fill doesn't look the same in dhtml compared to swf, see LPP-7813)



Modified: openlaszlo/trunk/lps/components/extensions/drawview.lzx
===================================================================
--- openlaszlo/trunk/lps/components/extensions/drawview.lzx	2009-02-25 19:06:39 UTC (rev 13060)
+++ openlaszlo/trunk/lps/components/extensions/drawview.lzx	2009-02-25 22:13:27 UTC (rev 13061)
@@ -895,12 +895,32 @@
                     cstopColor = LzColorUtils.torgb(c);
                     ccache[c] = cstopColor;
                 }
+                var gAlpha = this.__context.globalAlpha;
+                if (gAlpha != 1) {
+                    // add globalAlpha (if there is no explicit alpha value)
+                    cstopColor = this.torgba(cstopColor, gAlpha);
+                }
                 this.__g.addColorStop(o, cstopColor);
             }
 
             /**
             * @access private
             */
+            function torgba (rgb, alpha) {
+                if (rgb.indexOf("rgba") == -1) {
+                    // remove "rgb(" and ")"
+                    var rgba = rgb.substring(4, rgb.length - 1).split(',');
+                    rgba.push(alpha);
+                    return "rgba(" + rgba.join(',') + ")";
+                } else {
+                    // already in rgba() format
+                    return rgb;
+                }
+            }
+
+            /**
+            * @access private
+            */
             function __applyFillTo(scope) {
                 scope.fillStyle = this.__g;
             }
@@ -961,6 +981,7 @@
                 var __drawing :MovieClip = null;
                 var __measurewidth :Boolean = true;
                 var __measureheight :Boolean = true;
+                var __norebuild :Boolean = false;
             }
 
             var oncontext :LzDeclaredEventClass = LzDeclaredEvent;
@@ -1336,7 +1357,10 @@
                 }
 
                 // Add bitmap data drawing layer
-                function rebuildBitmap () {
+                function rebuildBitmap () :void {
+                    if (this.__norebuild) {
+                        return;
+                    }
                     if (this['__bitmapmc']) {
                         this.__bitmapmc.removeMovieClip();
                     }
@@ -1360,14 +1384,31 @@
                     this.rebuildBitmap();
                 }
 
-                function __updateSize() {
+                function __updateSize() :void {
+                    var measureSize:Boolean = (this.__measurewidth || this.__measureheight);
+                    if (measureSize) {
+                        // __bitmapmc needs to be removed while measuring the context's size
+                        if (this['__bitmapmc']) {
+                            this.__bitmapmc.removeMovieClip();
+                            this.__bitmapmc = null;
+                        }
+                        // don't rebuild bitmap in width/height setter
+                        this.__norebuild = true;
+                    }
                     var mc:MovieClip = this.sprite.getContext();
                     if (this.__measurewidth && this.width !== mc._width) {
-                      this.setAttribute('width', mc._width);
+                        this.setAttribute('width', mc._width);
+                        this.__measurewidth = true;
                     }
                     if (this.__measureheight && this.height !== mc._height) {
-                      this.setAttribute('height', mc._height);
+                        this.setAttribute('height', mc._height);
+                        this.__measureheight = true;
                     }
+                    if (measureSize) {
+                        // now rebuild bitmap again
+                        this.__norebuild = false;
+                        this.rebuildBitmap();
+                    }
                 }
 
                 function drawImage(image, x, y, w, h, r) {



More information about the Laszlo-checkins mailing list