Rather than testing for `null`, you should test for `lz.colors.transparent`. Yes, this is currently the same value, but we plan to change it to `rbga(0,0,0,0)`, which is the correct CSS value.
Clearly it is just an optimization to remove the shadow if the shadow is transparent, but we want people to be able to either use the `transparent` keyword _or_ the rgba equivalent. A further optimization would be to remove the shadow for any color with an alpha of 0, but we can't do that as long as there are places that are relying on `null` to mean transparent. I guess there should be a Jira bug to fix that throughout the kernel. On 2010-12-08, at 07:05, [email protected] wrote: > Author: hqm > Date: 2010-12-08 07:05:19 -0800 (Wed, 08 Dec 2010) > New Revision: 17973 > > Modified: > openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as > openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as > openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs > Log: > Change hqm-20101207-QEn by [email protected] on 2010-12-07 23:09:59 EST > in /Users/hqm/openlaszlo/trunk3 > for http://svn.openlaszlo.org/openlaszlo/trunk > > Summary: fixes for swf10 shadow rendering > > New Features: > > Bugs Fixed: LPP-9494, LPP-9565 > > Technical Reviewer: max > QA Reviewer: ffeng > Doc Reviewer: (pending) > > Documentation: > > Release Notes: > > Overview: > > > Details: > > + shadowcolor alpha value needs to be converted to value between 0 and 1 > > + for LzSprite, create a dedicated sprite to form a filled bounding > box for the shadow filter shape. > > There may be an optimization to use the bgsprite as a shadow outline > if it exists and is hidden, but I didn't want to try to figure out the > logic for that right now, and it's not clear it would work if alpha != > 1. > > Tests: > > For swf10, verify that the focus shadow glow effect applies to > bounding box of the whole component (button), not to the internal text > or icon. > > + demos/house.lzx > + demos/ptw.lzx > + see test case attached to bug report, lpp-9440.lzx > > > > Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as > =================================================================== > --- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as 2010-12-08 > 10:47:31 UTC (rev 17972) > +++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as 2010-12-08 > 15:05:19 UTC (rev 17973) > @@ -1034,6 +1034,7 @@ > } > > drawBackground(); > + if (shadowsprite != null) { updateShadow(_shadowcolor, > _shadowdistance, _shadowangle, _shadowblurradius); } > } > > > @@ -1054,6 +1055,7 @@ > this.drawMask(); > } > drawBackground(); > + if (shadowsprite != null) { updateShadow(_shadowcolor, > _shadowdistance, _shadowangle, _shadowblurradius); } > } > > /** @field Number rotation: The rotation value for the view (in degrees) > @@ -1914,7 +1916,23 @@ > } > > var shadowfilter:DropShadowFilter = new DropShadowFilter(0, 0, 0, 1, 4, > 4, 1, 2, false, false, false); > + var shadowsprite:Sprite = null; > + var _shadowcolor:*; > + var _shadowangle:Number;; > + var _shadowdistance:Number; > + var _shadowblurradius:Number; > > + /** > + Set up drop shadow filter. > + > + TODO [hqm 2010-12] If a color of "null" is passed in, the > + filter is removed. It looks like currently the LFC always > + passes in a valid color object for shadowcolor. There should > + probably be some API in the LFC to remove the filter by passing > + null in. > + > + @access private > + */ > function updateShadow(shadowcolor, shadowdistance:Number, > shadowangle:Number, shadowblurradius:Number) { > /* DropShadowFilter attributes > * [distance:Number] > @@ -1930,8 +1948,16 @@ > * [hideObject:Boolean]) > */ > > - var filters = []; > - if (shadowcolor != null) { > + this._shadowcolor = shadowcolor; > + this._shadowangle = shadowangle; > + this._shadowdistance = shadowdistance; > + this._shadowblurradius = shadowblurradius; > + > + if (shadowcolor == null) { > + removeChild(shadowsprite); > + this.shadowsprite = null; > + } else { > + var filters = []; > var inner:Boolean = shadowblurradius < 0; > if (inner) { > // Flip the distance (inner uses a positive value) > @@ -1939,18 +1965,45 @@ > } > shadowfilter.angle = shadowangle; > shadowfilter.distance = shadowdistance; > - var colorobj = LzColorUtils.inttocolorobj(shadowcolor); > - shadowfilter.color = colorobj.color; > - shadowfilter.alpha = colorobj.alpha != null ? colorobj.alpha : 1; > + var color_alpha = > LzColorUtils.coloralphafrominternal(shadowcolor); > + var color = color_alpha[0]; > + var alpha = color_alpha[1]; > + shadowfilter.color = color; > + shadowfilter.alpha = alpha != null ? alpha : 1; > shadowfilter.blurX = shadowblurradius; > shadowfilter.blurY = shadowblurradius; > shadowfilter.inner = inner; > filters = [shadowfilter]; > + > + > + // If the bgcolor is hidden or null, make a dedicated sprite > + // for the shadow, and fill it to match our bbox+radius shape > + > + shadowfilter.knockout = true; > + // Fill in rect the size and shape of our bounding box. If there > is a bgsprite already, use it, > + // else make a dedicated shadow sprite. > + if (shadowsprite == null) { > + shadowsprite = new Sprite(); > + addChild(shadowsprite); > + } > + var context = shadowsprite.graphics; > + > + context.clear(); > + context.beginFill(0xFF0000, 1); > + drawBackgroundFill(context); > + context.endFill(); > + > + if (this.borderWidth) { > + context.lineStyle(this.borderWidth, 0xFF0000, 1, false, > "normal", null, "miter"); > + this.drawBorder(context); > + context.lineStyle(undefined); > + } > + > + shadowsprite.filters = filters; > } > - var mc = getDisplayObject(); > - mc.filters = filters; > } > - > + > + > var cornerradius:Array = [0, 0, 0, 0]; > function setCornerRadius(radius) { > cornerradius = radius; > > Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as > =================================================================== > --- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as > 2010-12-08 10:47:31 UTC (rev 17972) > +++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as > 2010-12-08 15:05:19 UTC (rev 17973) > @@ -945,6 +945,57 @@ > this.activateLinks(active); > } > > + > + /** > + Set up drop shadow filter. > + > + TODO [hqm 2010-12] If a color of "null" is passed in, the > + filter is removed. It looks like the LFC always passes in a valid > + color object for shadowcolor. There should probably be some API > + in the LFC to remove the filter by passing null in. > + > + @access private > + */ > + > + override function updateShadow(shadowcolor, shadowdistance:Number, > shadowangle:Number, shadowblurradius:Number) { > + /* DropShadowFilter attributes > + * [distance:Number] > + * [angle:Number] > + * [color:Number] > + * [alpha:Number] > + * [blurX:Number] > + * [blurY:Number] > + * [strength:Number] > + * [quality:Number] > + * [inner:Boolean] > + * [knockout:Boolean] > + * [hideObject:Boolean]) > + */ > + > + var filters = []; > + var mc = getDisplayObject(); > + if (shadowcolor != null) { > + var inner:Boolean = shadowblurradius < 0; > + if (inner) { > + // Flip the distance (inner uses a positive value) > + shadowblurradius = -shadowblurradius; > + } > + shadowfilter.angle = shadowangle; > + shadowfilter.distance = shadowdistance; > + var color_alpha = > LzColorUtils.coloralphafrominternal(shadowcolor); > + var color = color_alpha[0]; > + var alpha = color_alpha[1]; > + shadowfilter.color = color; > + shadowfilter.alpha = alpha != null ? alpha : 1; > + shadowfilter.blurX = shadowblurradius; > + shadowfilter.blurY = shadowblurradius; > + shadowfilter.inner = inner; > + filters = [shadowfilter]; > + } > + mc.filters = filters; > + } > + > + > }# > } > > > Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs > =================================================================== > --- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs 2010-12-08 > 10:47:31 UTC (rev 17972) > +++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs 2010-12-08 > 15:05:19 UTC (rev 17973) > @@ -3673,7 +3673,7 @@ > */ > function $lzc$set_shadowcolor(color) { > if (this.capabilities['dropshadows']) { > - this.shadowcolor = LzColorUtils.torgb(color); > + this.shadowcolor = color; > this.__updateShadow(); > if (this.onshadowcolor.ready) { > this.onshadowcolor.sendEvent(color); > > > _______________________________________________ > Laszlo-checkins mailing list > [email protected] > http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
