You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/12/03 19:47:19 UTC

[royale-asjs] branch develop updated (fc02c51 -> dd7174f)

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


    from fc02c51  Update UIComponent
     new 4e1ba97  improve measuring
     new dd7174f  Spark Rect

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/royale/mx/core/UIComponent.as         |  31 +-
 .../src/main/royale/spark/primitives/Rect.as       | 465 ++-------------------
 2 files changed, 61 insertions(+), 435 deletions(-)


[royale-asjs] 02/02: Spark Rect

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit dd7174fe3f851786a18461a8832ec9ff908ceeac
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Dec 3 11:46:55 2018 -0800

    Spark Rect
---
 .../src/main/royale/spark/primitives/Rect.as       | 465 ++-------------------
 1 file changed, 38 insertions(+), 427 deletions(-)

diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/primitives/Rect.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/primitives/Rect.as
index 036f4bc..d895d43 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/primitives/Rect.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/primitives/Rect.as
@@ -19,6 +19,14 @@
 
 package spark.primitives
 {
+import mx.display.Graphics;
+import org.apache.royale.geom.Rectangle;
+
+import mx.graphics.IFill;
+import mx.graphics.IStroke;
+import mx.graphics.SolidColorStroke;
+
+
 /* import flash.display.Graphics;
 import flash.geom.Matrix;
 import flash.geom.Point;
@@ -31,8 +39,7 @@ import spark.primitives.supportClasses.FilledElement;
 
  */
 import mx.core.mx_internal;
-import mx.graphics.IStroke;
-import mx.graphics.IFill;
+import mx.core.UIComponent;
 
 import org.apache.royale.events.EventDispatcher;
 use namespace mx_internal;
@@ -55,7 +62,7 @@ use namespace mx_internal;
  *  @playerversion AIR 1.5
  *  @productversion Royale 0.9.4
  */
-public class Rect  extends EventDispatcher
+public class Rect extends UIComponent
 { //extends FilledElement
    // include "../core/Version.as";
 
@@ -783,391 +790,7 @@ public class Rect  extends EventDispatcher
         
         return boundingBox;
     } */
-	//----------------------------------
-    //  visible copied from GraphicElement
-    //----------------------------------
-
-    /**
-     *  @private
-     *  Storage for the visible property.
-     */
-    private var _visible:Boolean = true;
-    
-    
-    /**
-     *  @private
-     *  The actual 'effective' visibility of this
-     *  element, one that considers the visibility of
-     *  the owning design layer parent (if any).
-     */
-   // protected var _effectiveVisibility:Boolean = true;
-    
-    /**
-     *  @private
-     */
-  //  private var visibleChanged:Boolean;
-
-    [Inspectable(category="General")]
-
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     *  @royalesuppresspublicvarwarning
-	*/
-    public function get visible():Boolean
-    {
-        return _visible;
-    }
-
-    /**
-     *  @private
-     */
-    public function set visible(value:Boolean):void
-    {
-        _visible = value;
-        
-        /* if (designLayer && !designLayer.effectiveVisibility)
-            value = false; 
-        
-        if (_effectiveVisibility == value)
-            return;
-        
-        _effectiveVisibility = value;
-        visibleChanged = true;
-        invalidateProperties(); */
-    }
-    //----------------------------------
-    //  height copied from GraphicElement
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the height property.
-     */
-    /* mx_internal */ private var _height:Number = 0;
-
-    [Bindable("propertyChange")]
-    [Inspectable(category="General")]
-    [PercentProxy("percentHeight")]
-
-    /**
-     *  The height of the graphic element.
-     *
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     *  @royalesuppresspublicvarwarning
-	 */
-    public function get height():Number
-    {
-        return _height;
-    }
-
-    /**
-     *  @private
-     */
-    
-    public function set height(value:Number):void
-    {
-       // explicitHeight = value;
-
-        if (_height == value)
-            return;
-
-        var oldValue:Number = _height;
-        _height = value;
-       // dispatchPropertyChangeEvent("height", oldValue, value);
-
-        // Invalidate the display list, since we're changing the actual height
-        // and we're not going to correctly detect whether the layout sets
-        // new actual height different from our previous value.
-       // invalidateDisplayList();
-    }
-    //----------------------------------
-    //  width copied from GraphicElement
-    //----------------------------------
-
-    /**
-     *  @private
-     *  Storage for the width property.
-     */
-     /* mx_internal */ private var _width:Number = 0;
-	 
-	 [Bindable("propertyChange")]
-	 [Inspectable(category="General")]
-	 [PercentProxy("percentWidth")]
-
-    /**
-     *  The width of the graphic element.
-     *
-     *  @default 0
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     *  @royalesuppresspublicvarwarning
-	*/
-    public function get width():Number
-    {
-        return _width;
-    }
-
-    /**
-     *  @private
-     */
-    public function set width(value:Number):void
-    {
-       // explicitWidth = value;
-
-        if (_width == value)
-            return;
-
-        var oldValue:Number = _width;
-        _width = value;
-
-        // The width is needed for the mirroring transform.
-      /*   if (layoutFeatures)
-        {
-            layoutFeatures.layoutWidth = value;
-            invalidateTransform();
-        }        
-
-        dispatchPropertyChangeEvent("width", oldValue, value);
-
-        // Invalidate the display list, since we're changing the actual width
-        // and we're not going to correctly detect whether the layout sets
-        // new actual width different from our previous value.
-        invalidateDisplayList(); */
-    }
-	
-	//----------------------------------
-    //  alpha copied from GraphicElement
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the alpha property.
-     */
-    private var _alpha:Number = 1.0;
-   // private var _effectiveAlpha:Number = 1.0;
-    
-    /**
-     *  @private
-     */
-   // private var alphaChanged:Boolean = false;
-    
-    [Inspectable(category="General", minValue="0.0", maxValue="1.0")]
-
-    /**
-     *  The level of transparency of the graphic element. Valid values are decimal values between
-     *  0 (fully transparent) and 1 (fully opaque). For example, a value of .25 means that the 
-     *  element has 25% opacity.
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get alpha():Number
-    {
-        return _alpha;
-    }
-
-    /**
-     *  @private
-     */
-    public function set alpha(value:Number):void
-    {    
-        if (_alpha == value)
-            return;
-        
-       // var previous:Boolean = needsDisplayObject;
-        _alpha = value;
-        
-    // The product of _alpha and the designLayer's 
-    // alpha is the effectiveAlpha which is 
-    // committed in commitProperties() 
-       /*  if (designLayer)
-            value = value * designLayer.effectiveAlpha; 
-
-        if (_blendMode == "auto")
-        {
-            // If alpha changes from an opaque/transparent (1/0) and translucent
-            // (0 < value < 1), then trigger a blendMode change
-            if ((value > 0 && value < 1 && (_effectiveAlpha == 0 || _effectiveAlpha == 1)) ||
-                ((value == 0 || value == 1) && (_effectiveAlpha > 0 && _effectiveAlpha < 1)))
-            {
-                blendModeChanged = true;
-            }
-        }
-        
-        _effectiveAlpha = value;
-        
-        // Clear the colorTransform flag since alpha was explicitly set
-        var mxTransform:mx.geom.Transform = _transform as mx.geom.Transform;
-        if (mxTransform)
-            mxTransform.applyColorTransformAlpha = false;        
-        
-        if (previous != needsDisplayObject)
-            invalidateDisplayObjectSharing();    
-
-        alphaChanged = true;
-        invalidateProperties(); */
-    }
-    //----------------------------------
-    //  left copied from GraphicElement
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the left property.
-     */
-    private var _left:Object;
-
-    [Inspectable(category="General")]
-
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get left():Object
-    {
-        return _left;
-    }
-
-    /**
-     *  @private
-     */
-    public function set left(value:Object):void
-    {
-        if (_left == value)
-            return;
-
-        _left = value;
-       // invalidateParentSizeAndDisplayList();
-    }
-	
-    //----------------------------------
-    //  right copied from GraphicElement
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the right property.
-     */
-    private var _right:Object;
-
-    [Inspectable(category="General")]
-
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get right():Object
-    {
-        return _right;
-    }
 
-    /**
-     *  @private
-     */
-    public function set right(value:Object):void
-    {
-        if (_right == value)
-            return;
-
-        _right = value;
-        //invalidateParentSizeAndDisplayList();
-    }
-	//----------------------------------
-    //  top copied from GraphicElement
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the top property.
-     */
-    private var _top:Object;
-
-    [Inspectable(category="General")]
-
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get top():Object
-    {
-        return _top;
-    }
-
-    /**
-     *  @private
-     */
-    public function set top(value:Object):void
-    {
-        if (_top == value)
-            return;
-
-        _top = value;
-       // invalidateParentSizeAndDisplayList();
-    }
-	
-	//----------------------------------
-    //  bottom copied from GraphicElement
-    //----------------------------------
-    
-    /**
-     *  @private
-     *  Storage for the bottom property.
-     */
-    private var _bottom:Object;
-
-    [Inspectable(category="General")]
-
-    /**
-     *  @inheritDoc
-     *  
-     *  @langversion 3.0
-     *  @playerversion Flash 10
-     *  @playerversion AIR 1.5
-     *  @productversion Royale 0.9.4
-     */
-    public function get bottom():Object
-    {
-        return _bottom;
-    }
-
-    /**
-     *  @private
-     */
-    public function set bottom(value:Object):void
-    {
-        if (_bottom == value)
-            return;
-
-        _bottom = value;
-       // invalidateParentSizeAndDisplayList();
-    }
 	//----------------------------------
     //  stroke copied from StrokedElement
     //----------------------------------
@@ -1276,46 +899,34 @@ public class Rect  extends EventDispatcher
         invalidateDisplayList(); */
     }
 	
-	//----------------------------------
-	//  percentWidth
-	//----------------------------------
-	
-	/**
-	 *  @private
-	 *  Storage for the percentWidth property.
-	 */
-	private var _percentWidth:Number;
-	
-	[Inspectable(category="General")]
-	
-	/**
-	 *  @copy mx.core.UIComponent#percentWidth
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10
-	 *  @playerversion AIR 1.5
-	 *  @productversion Flex 4
-	 */
-	public function get percentWidth():Number
-	{
-		return _percentWidth;
-	}
-	
-	/**
-	 *  @private
-	 */
-	public function set percentWidth(value:Number):void
-	{
-		if (_percentWidth == value)
-			return;
-		
-		/*if (!isNaN(value))
-			explicitWidth = NaN;*/
-		
-		_percentWidth = value;
-		
-		// invalidateParentSizeAndDisplayList();
-	}
+    override public function addedToParent():void
+    {
+        super.addedToParent();
+        setActualSize(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight());
+    }
+    
+    override public function setActualSize(w:Number, h:Number):void
+    {
+        super.setActualSize(w, h);
+        updateDisplayList(w, h);
+    }
+    
+    override protected function updateDisplayList(unscaledWidth:Number,
+                                                  unscaledHeight:Number):void
+    {
+        super.updateDisplayList(unscaledWidth,unscaledHeight);
+        var g:Graphics = graphics;
+        g.clear();
+        
+        if (fill)
+            fill.begin(g, new Rectangle(0, 0, unscaledWidth, unscaledHeight), null);
+
+        if (stroke)
+            stroke.apply(g, new Rectangle(0, 0, unscaledWidth, unscaledHeight), null);
+        
+        g.drawRoundRect(0, 0, unscaledWidth, unscaledHeight, radiusX, radiusY);
+    }
+
 
 }
 


[royale-asjs] 01/02: improve measuring

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 4e1ba979821801ab8385db6f743bfd56fd0c3b86
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Dec 3 11:05:20 2018 -0800

    improve measuring
---
 .../src/main/royale/mx/core/UIComponent.as         | 31 ++++++++++++++++------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index 3d76156..4721f4a 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -1972,9 +1972,15 @@ COMPILE::JS
 			if (isNaN(_measuredWidth)) 
             {
                 var oldWidth:Object;
+                var oldLeft:String;
+                var oldRight:String;
                 oldWidth = this.positioner.style.width;
+                oldLeft = this.positioner.style.left;
+                oldRight = this.positioner.style.right;
                 if (oldWidth.length)
                     this.positioner.style.width = "";
+                if (oldLeft.length && oldRight.length) // if both are set, this also dictates width
+                    this.positioner.style.left = "";
                 var mw:Number = this.positioner.offsetWidth;
                 if (mw == 0 && numChildren > 0)
                 {
@@ -1988,6 +1994,8 @@ COMPILE::JS
                 }
                 if (oldWidth.length)
                     this.positioner.style.width = oldWidth;
+                if (oldLeft.length && oldRight.length) // if both are set, this also dictates width
+                    this.positioner.style.left = oldLeft;
                 return mw;
 			}
 		}
@@ -2037,9 +2045,15 @@ COMPILE::JS
             if (isNaN(_measuredHeight))
             {
                 var oldHeight:Object;
-        		oldHeight = this.positioner.style.height;
+                var oldTop:String;
+                var oldBottom:String;
+                oldTop = this.positioner.style.top;
+                oldBottom = this.positioner.style.bottom;
+                oldHeight = this.positioner.style.height;
                 if (oldHeight.length)
                     this.positioner.style.height = "";
+                if (oldTop.length && oldBottom.length) // if both are set, this also dictates height
+                    this.positioner.style.top = "";
                 var mh:Number = this.positioner.offsetHeight;
                 if (mh == 0 && numChildren > 0)
                 {
@@ -2052,6 +2066,8 @@ COMPILE::JS
                 }
                 if (oldHeight.length)
                     this.positioner.style.height = oldHeight;
+                if (oldTop.length && oldBottom.length) // if both are set, this also dictates width
+                    this.positioner.style.top = oldTop;
                 return mh;
             }
 		}
@@ -4274,11 +4290,11 @@ COMPILE::JS
      */
     public function get horizontalCenter():Object
     {
-        return 0;
+        return ValuesManager.valuesImpl.getValue(this, "horizontalCenter");
     }
     public function set horizontalCenter(value:Object):void
     {
-        trace("horizontalCenter not implemented");
+        setStyle("horizontalCenter", value);
     }
 
     [Inspectable(category="General")]
@@ -4303,11 +4319,11 @@ COMPILE::JS
      */
     public function get verticalCenter():Object
     {
-        return 0;
+        return ValuesManager.valuesImpl.getValue(this, "verticalCenter");
     }
     public function set verticalCenter(value:Object):void
     {
-        trace("verticalCenter not implemented");
+        setStyle("verticalCenter", value);
     }
 	
     [Inspectable(category="General")]
@@ -4403,12 +4419,11 @@ COMPILE::JS
      */
     public function get textAlign():Object
     {
-        trace("textAlign not implemented");
-        return 0;
+        return ValuesManager.valuesImpl.getValue(this, "textAlign");
     }
     public function set textAlign(value:Object):void
     {
-        trace("textAlign not implemented");
+        setStyle("textAlign", value);
     }
 	[Inspectable(category="General")]