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 2020/12/08 03:51:12 UTC

[royale-asjs] branch ChildResize updated (43ce0a8 -> 8ccfa56)

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

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


    from 43ce0a8  Merge branch 'develop' into ChildResize
     new 199b495  make sure Image/Bitmap image measurements are not NaN
     new 47a85d8  Spark Label is a 'native' control (no view) so it has to send notifications if its size changes as the text changes
     new 8ccfa56  listen for child size changing

The 3 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:
 .../MXRoyale/src/main/royale/mx/controls/Image.as  |  4 +-
 .../spark/components/supportClasses/TextBase.as    |  9 +++++
 .../layouts/supportClasses/SparkLayoutBead.as      | 43 +++++++++++++++++++++-
 3 files changed, 52 insertions(+), 4 deletions(-)


[royale-asjs] 03/03: listen for child size changing

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

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

commit 8ccfa56c28f457f725c7025b1779025d27060f64
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Dec 7 19:50:57 2020 -0800

    listen for child size changing
---
 .../layouts/supportClasses/SparkLayoutBead.as      | 43 +++++++++++++++++++++-
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as
index e1ed277..96a59ab 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as
@@ -36,6 +36,7 @@ import org.apache.royale.core.LayoutBase;
 import org.apache.royale.core.UIBase;
 import org.apache.royale.events.Event;
 import org.apache.royale.events.EventDispatcher;
+import org.apache.royale.events.IEventDispatcher;
 import org.apache.royale.utils.MXMLDataInterpreter;
 import org.apache.royale.utils.loadBeadFromValuesManager;
 
@@ -78,9 +79,14 @@ public class SparkLayoutBead extends org.apache.royale.core.LayoutBase
 		sawSizeChanged = true;
 		super.handleSizeChange(event);
 	}
-
+	
+	private var ranLayout:Boolean;	
+	private var inUpdateDisplayList:Boolean;	
+		
     override public function layout():Boolean
     {
+		ranLayout = true;
+		
         var n:int = target.numChildren;
         if (n == 0)
             return false;
@@ -107,7 +113,9 @@ public class SparkLayoutBead extends org.apache.royale.core.LayoutBase
             h = target.measuredHeight;
         if (target.layout.isWidthSizedToContent())
             w = target.measuredWidth;
+		inUpdateDisplayList = true;
         target.layout.updateDisplayList(w, h);
+		inUpdateDisplayList = false;
         
         // update the target's actual size if needed.
         if (target.layout.isWidthSizedToContent() && target.layout.isHeightSizedToContent()) {
@@ -136,7 +144,10 @@ public class SparkLayoutBead extends org.apache.royale.core.LayoutBase
         var host:UIBase = value as UIBase;
         _target = (host.view as ILayoutHost).contentView as GroupBase;
         super.strand = value;
-        
+        	// The main layout may not get put on the strand until
+		// after children are added so listen here as well
+		if (target.parent)
+			listenToChildren();		
     }
     
     private var _target:GroupBase;
@@ -151,5 +162,33 @@ public class SparkLayoutBead extends org.apache.royale.core.LayoutBase
         _target = value;
     }
 
+	override protected function handleChildrenAdded(event:Event):void
+	{
+		COMPILE::JS {
+			super.handleChildrenAdded(event);
+			listenToChildren();
+		}
+	}
+	
+	private function listenToChildren():void
+	{
+		var n:Number = layoutView.numElements;
+		for(var i:int=0; i < n; i++) {
+			var child:IEventDispatcher = layoutView.getElementAt(i) as IEventDispatcher;
+			child.addEventListener("widthChanged", childResizeHandler);
+			child.addEventListener("heightChanged", childResizeHandler);
+			child.addEventListener("sizeChanged", childResizeHandler);
+		}
+	}
+	
+	override protected function childResizeHandler(event:Event):void
+	{
+		if (inUpdateDisplayList) return;
+		ranLayout = false;
+		super.childResizeHandler(event); // will set ranLayout if it did
+		if (!ranLayout)
+			performLayout();
+	}		
+		
 }
 }


[royale-asjs] 01/03: make sure Image/Bitmap image measurements are not NaN

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

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

commit 199b4959b9f9b5d400718ababfedf1df720f9b08
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Dec 7 19:47:50 2020 -0800

    make sure Image/Bitmap image measurements are not NaN
---
 frameworks/projects/MXRoyale/src/main/royale/mx/controls/Image.as | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Image.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Image.as
index da77888..d69460e 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Image.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Image.as
@@ -617,12 +617,12 @@ public class Image extends UIComponent
 
 	override public function get measuredWidth():Number
 	{
-		return contentWidth;
+		return isNaN(contentWidth) ? 0 : contentWidth;
 	}
 
 	override public function get measuredHeight():Number
 	{
-		return contentHeight;
+		return isNaN(contentHeight) ? 0 : contentHeight;
 	}
 
 	override protected function updateDisplayList(unscaledWidth:Number,


[royale-asjs] 02/03: Spark Label is a 'native' control (no view) so it has to send notifications if its size changes as the text changes

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

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

commit 47a85d8436ebfcfc3d695e8418eed17c40f84ed7
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Dec 7 19:50:16 2020 -0800

    Spark Label is a 'native' control (no view) so it has to send notifications if its size changes as the text changes
---
 .../src/main/royale/spark/components/supportClasses/TextBase.as  | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as
index aaed390..5766edd 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/TextBase.as
@@ -560,6 +560,15 @@ public class TextBase extends UIComponent implements IDisplayText
                      _text = value;
                      textNode.nodeValue = value;
                      this.dispatchEvent('textChange');
+					 var contentWidth:Boolean = this.isWidthSizedToContent();
+					 var contentHeight:Boolean = this.isHeightSizedToContent();
+					 var eventType:String = null;
+					 if (contentWidth)
+						eventType = "widthChanged";
+					 if (contentHeight) 
+						eventType = contentWidth ? "sizeChanged" : "heightChanged";
+					 if (eventType)
+					    dispatchEvent(eventType);
                  }
              }