flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - A simpler way to ignore size changes to children during layout process.
Date Wed, 26 Aug 2015 11:41:09 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop a54a1ff2b -> 82032377d


A simpler way to ignore size changes to children during layout process.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/82032377
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/82032377
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/82032377

Branch: refs/heads/develop
Commit: 82032377d1634852e1d99eec90fb91a29ce33917
Parents: a54a1ff
Author: Peter Ent <pent@apache.org>
Authored: Wed Aug 26 13:41:05 2015 +0200
Committer: Peter Ent <pent@apache.org>
Committed: Wed Aug 26 13:41:05 2015 +0200

----------------------------------------------------------------------
 .../org/apache/flex/html/beads/ContainerView.as | 23 +++++++++++---------
 .../org/apache/flex/html/beads/ContainerView.js | 17 +++++----------
 2 files changed, 18 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/82032377/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
index 979a9e2..e3b6a1e 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/ContainerView.as
@@ -75,6 +75,9 @@ package org.apache.flex.html.beads
          */
 		public function ContainerView()
 		{
+			super();
+			
+			layoutRunning = false;
 		}
 		
 		/**
@@ -136,6 +139,7 @@ package org.apache.flex.html.beads
 		private var _viewportModel:IViewportModel;
 		private var _viewport:IViewport;
 		private var _strand:IStrand;
+		private var layoutRunning:Boolean;
 		
 		/**
 		 * Strand setter.
@@ -150,6 +154,8 @@ package org.apache.flex.html.beads
 			_strand = value;
 			super.strand = value;
 			
+			// create the content area where the elements being organized
+			// and laid out reside.
 			_contentArea = createContentView();
 			(host as UIBase).addElement(_contentArea,false);
 			ContainerBase(host).setActualParent(_contentArea as DisplayObjectContainer);
@@ -220,6 +226,7 @@ package org.apache.flex.html.beads
 		 */
 		protected function completeSetup():void
 		{
+			// create the viewport which displays the content
 			createViewport();
 			
 			(contentView as UIBase).setWidthAndHeight(viewportModel.contentWidth, viewportModel.contentHeight,
true);
@@ -341,6 +348,8 @@ package org.apache.flex.html.beads
 		 */
 		protected function performLayout(event:Event):void
 		{
+			layoutRunning = true;
+			
 			adjustSizeBeforeLayout();
 			
 			var host:UIBase = _strand as UIBase;
@@ -354,14 +363,14 @@ package org.apache.flex.html.beads
 				}
 			}
 			
-            resizingChildren = true;
 			if (layout) {
 				layout.layout();
 				determineContentSizeFromChildren();
 			}
-            resizingChildren = false;
 			
 			adjustSizeAfterLayout();
+			
+			layoutRunning = false;
 		}
 		
 		/**
@@ -500,9 +509,7 @@ package org.apache.flex.html.beads
 				child.addEventListener("sizeChanged", childResizeHandler);
 			}
 		}
-		
-		private var resizingChildren:Boolean = false;
-		
+				
 		/**
 		 * This event handles changes to the size of children of the container by running
 		 * the layout again and adjusting the size of the container or viewport as necessary. 
@@ -517,12 +524,8 @@ package org.apache.flex.html.beads
 			// during this process we don't want the layout to trigger
 			// an endless event chain should any children get resized
 			// by the layout.
-			if (resizingChildren) return;
-			resizingChildren = true;
-			
-			var child:UIBase = event.target as UIBase;
+			if (layoutRunning) return;			
 			performLayout(event);
-			resizingChildren = false;
 		}
 		
 		protected function displayBackgroundAndBorder(host:UIBase) : void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/82032377/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
index bbce1be..3b16e68 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/ContainerView.js
@@ -32,7 +32,7 @@ org.apache.flex.html.beads.ContainerView = function() {
   org.apache.flex.html.beads.ContainerView.base(this, 'constructor');
 
   this.className = 'ContainerView';
-  this.resizingChildren = false;
+  this.runningLayout = false;
 };
 goog.inherits(
     org.apache.flex.html.beads.ContainerView,
@@ -166,10 +166,8 @@ org.apache.flex.html.beads.ContainerView.
  */
  org.apache.flex.html.beads.ContainerView.
     prototype.childResizeHandler = function(event) {
-    if (this.resizingChildren) return;
-    this.resizingChildren = true;
+    if (this.runningLayout) return;
     this.performLayout(event);
-    this.resizingChildren = false;
 };
 
 
@@ -233,6 +231,7 @@ org.apache.flex.html.beads.ContainerView.
  */
 org.apache.flex.html.beads.ContainerView.
     prototype.performLayout = function(event) {
+  this.runningLayout = true;
   this.adjustSizeBeforeLayout();
   if (this.layout == null) {
     this.layout = this._strand.getBeadByType(org.apache.flex.core.IBeadLayout);
@@ -242,16 +241,10 @@ org.apache.flex.html.beads.ContainerView.
       this._strand.addBead(this.layout);
     }
   }
-  this.resizingChildren = true;
-  /*
-  org.apache.flex.utils.Language.trace(this._strand.id);
-  var foo = false;
-  if (foo)
-  */
-    this.layout.layout();
-  this.resizingChildren = false;
+  this.layout.layout();
 
   this.adjustSizeAfterLayout();
+  this.runningLayout = false;
 };
 
 


Mime
View raw message