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/06/08 07:48:27 UTC

[royale-asjs] branch ChildResize created (now 0977676)

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.


      at 0977676  BoxLayout listens to children and runs layout if they change size

This branch includes the following new commits:

     new 03cc89e  remove trace statement so it doesn't show up in greps
     new 0977676  BoxLayout listens to children and runs layout if they change size

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.



[royale-asjs] 01/02: remove trace statement so it doesn't show up in greps

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 03cc89ec739af9b6b1cff557922cb4c07e430ec5
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Jun 8 00:47:16 2020 -0700

    remove trace statement so it doesn't show up in greps
---
 frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as | 2 --
 1 file changed, 2 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 c5fa102..36fc392 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -5040,8 +5040,6 @@ COMPILE::JS
      */
     public function setActualSize(w:Number, h:Number):void
     {
-    
-    //    trace("setActualSize not implemented");
 		this.setWidthAndHeight(w, h);
     }
 


[royale-asjs] 02/02: BoxLayout listens to children and runs layout if they change size

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 0977676251212ef20382044da91701a3a0047691
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Jun 8 00:47:53 2020 -0700

    BoxLayout listens to children and runs layout if they change size
---
 .../main/royale/mx/containers/beads/BoxLayout.as   | 42 +++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as
index f1b88b0..7bd5811 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/BoxLayout.as
@@ -34,6 +34,8 @@ package mx.containers.beads
 	import org.apache.royale.core.UIBase;
     import org.apache.royale.core.layout.EdgeData;
 	import org.apache.royale.core.ValuesManager;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.events.IEventDispatcher;
 
 	//import mx.core.mx_internal;
 	//import mx.core.ScrollPolicy;
@@ -80,7 +82,9 @@ package mx.containers.beads
 			_strand = value;
 			_target = value as Container;
 			super.strand = value;
-			
+			// The main layout may not get put on the strand until
+			// after children are added so listen here as well
+			listenToChildren();			
 		}
 		
 		private var _target:Container;
@@ -193,8 +197,12 @@ package mx.containers.beads
 			target.measuredHeight = preferredHeight + hPadding;
 		}
 		
+		private var ranLayout:Boolean;
+		
 		override public function layout():Boolean
 		{
+			ranLayout = true;
+			
 			var n:int = layoutView.numElements;
 			if (n == 0)
 				return false;
@@ -214,6 +222,8 @@ package mx.containers.beads
 			return true;
 		}
 		
+		private var inUpdateDisplayList:Boolean;
+		
 		/**
 		 *  @private
 		 *  Lay out children as per Box layout rules.
@@ -223,6 +233,7 @@ package mx.containers.beads
 		{			
 			var n:int = layoutView.numElements;
 			if (n == 0) return;
+			inUpdateDisplayList = true;
 			
 			var vm:EdgeMetrics = target.viewMetricsAndPadding;
             var pd:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getPaddingMetrics(target);
@@ -417,6 +428,7 @@ package mx.containers.beads
 						left += obj.width + gap;
 				}
 			}
+			inUpdateDisplayList = false;
 		}
 		
 		//--------------------------------------------------------------------------
@@ -504,6 +516,34 @@ package mx.containers.beads
 			// default = top
 			return 0;
 		}
+		
+		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();
+		}		
 	}
 	
 }