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] - Elements that have visible=false are now ignored by the layout beads which keeps the display in line with how HTML handles elements with display:none style. Changes to the visible property now dispatch "hide
Date Thu, 12 Mar 2015 21:29:18 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 72b15bb39 -> d15d58033


Elements that have visible=false are now ignored by the layout beads which keeps the display
in line with how HTML handles elements with display:none style. Changes to the visible property
now dispatch "hide" and "show" events.


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

Branch: refs/heads/develop
Commit: d15d58033d9a3a56f2be7513975c3aacdeca9c02
Parents: 72b15bb
Author: Peter Ent <pent@apache.org>
Authored: Thu Mar 12 17:29:12 2015 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Thu Mar 12 17:29:12 2015 -0400

----------------------------------------------------------------------
 .../FlexJSUI/src/org/apache/flex/core/UIBase.as         | 10 ++++++++++
 .../FlexJSUI/src/org/apache/flex/core/UIButtonBase.as   | 10 ++++++++++
 .../apache/flex/html/beads/layouts/ButtonBarLayout.as   | 12 +++++++++++-
 .../html/beads/layouts/NonVirtualHorizontalLayout.as    |  2 ++
 .../layouts/NonVirtualHorizontalScrollingLayout.as      |  1 +
 .../flex/html/beads/layouts/NonVirtualVerticalLayout.as |  4 +++-
 .../beads/layouts/NonVirtualVerticalScrollingLayout.as  |  3 ++-
 .../org/apache/flex/html/beads/layouts/TileLayout.as    | 11 ++++++++++-
 frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js |  1 +
 .../org/apache/flex/html/beads/layouts/TileLayout.js    | 10 +++++++++-
 10 files changed, 59 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
index ad23c52..35c7f21 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
@@ -490,6 +490,16 @@ package org.apache.flex.core
         {
             return (isNaN(_explicitHeight) && isNaN(_percentHeight));
         }
+		
+		/**
+		 * @private
+		 */
+		override public function set visible(value:Boolean):void
+		{
+			super.visible = value;
+			dispatchEvent(new Event(value?"show":"hide"));
+			dispatchEvent(new Event("visibleChanged"));
+		}
         
 		private var _model:IBeadModel;
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
index 6cfb32c..b8f3689 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
@@ -436,6 +436,16 @@ package org.apache.flex.core
         {
             return (isNaN(_explicitWidth) && isNaN(_percentWidth));
         }
+		
+		/**
+		 * @private
+		 */
+		override public function set visible(value:Boolean):void
+		{
+			super.visible = value;
+			dispatchEvent(new Event(value?"show":"hide"));
+			dispatchEvent(new Event("visibleChanged"));
+		}
         
         /**
          *  @copy org.apache.flex.core.ILayoutChild#isHeightSizedToContent

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
index 4facb06..7589cdb 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/ButtonBarLayout.as
@@ -76,6 +76,7 @@ package org.apache.flex.html.beads.layouts
 			IEventDispatcher(value).addEventListener("heightChanged", changeHandler);
 			IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
 			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
+			IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
 		}
 		
 		private var _buttonWidths:Array = null;
@@ -108,13 +109,22 @@ package org.apache.flex.html.beads.layouts
 			var itemRendererParent:IItemRendererParent = contentView as IItemRendererParent;
 			
 			var n:int = itemRendererParent.numElements;
+			var realN:int = n;
+			
+			for (var j:int=0; j < n; j++)
+			{
+				var child:IUIBase = itemRendererParent.getElementAt(j) as IUIBase;
+				if (child == null || !child.visible) realN--;
+			}
+			
 			var xpos:Number = 0;
-			var useWidth:Number = IUIBase(_strand).width / n;
+			var useWidth:Number = IUIBase(_strand).width / realN;
 			var useHeight:Number = IUIBase(_strand).height;
 			
 			for (var i:int=0; i < n; i++)
 			{
 				var ir:ISelectableItemRenderer = itemRendererParent.getElementAt(i) as ISelectableItemRenderer;
+				if (ir == null || !UIBase(ir).visible) continue;
 				UIBase(ir).y = 0;
 				UIBase(ir).height = useHeight;
 				UIBase(ir).x = xpos;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.as
index c3540c1..7316f41 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalLayout.as
@@ -120,6 +120,7 @@ package org.apache.flex.html.beads.layouts
 			for (var i:int = 0; i < n; i++)
 			{
 				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
+				if (child == null || !child.visible) continue;
 				margin = ValuesManager.valuesImpl.getValue(child, "margin");
 				if (margin is Array)
 				{
@@ -198,6 +199,7 @@ package org.apache.flex.html.beads.layouts
 			{
 				var obj:Object = verticalMargins[0]
 				child = contentView.getElementAt(i) as IUIBase;
+				if (child == null || !child.visible) continue;
                 if (child is ILayoutChild)
                 {
                     ilc = child as ILayoutChild;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalScrollingLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalScrollingLayout.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalScrollingLayout.as
index 4cc9657..b3e2e92 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalScrollingLayout.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualHorizontalScrollingLayout.as
@@ -99,6 +99,7 @@ package org.apache.flex.html.beads.layouts
 			for (var i:int = 0; i < n; i++)
 			{
 				var ir:IUIBase = contentView.getElementAt(i) as IUIBase;
+				if (ir == null || !ir.visible) continue;
 				ir.x = xx;
 				ir.height = contentView.height;
 				xx += ir.width;			

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.as
index 28a5955..f45ca3e 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalLayout.as
@@ -93,7 +93,7 @@ package org.apache.flex.html.beads.layouts
         {
             host.addEventListener("childrenAdded", changeHandler);
             host.addEventListener("layoutNeeded", changeHandler);
-            host.addEventListener("itemsCreated", changeHandler);
+			host.addEventListener("itemsCreated", changeHandler);
         }
         
         private function sizeChangeHandler(event:Event):void
@@ -121,6 +121,7 @@ package org.apache.flex.html.beads.layouts
 			for (var i:int = 0; i < n; i++)
 			{
 				var child:IUIBase = contentView.getElementAt(i) as IUIBase;
+				if (child == null || !child.visible) continue;
 				margin = ValuesManager.valuesImpl.getValue(child, "margin");
 				if (margin is Array)
 				{
@@ -221,6 +222,7 @@ package org.apache.flex.html.beads.layouts
 			for (i = 0; i < n; i++)
 			{
                 child = contentView.getElementAt(i) as IUIBase;
+				if (child == null || !child.visible) continue;
                 if (hasHorizontalFlex)
                 {
 					var obj:Object = flexibleHorizontalMargins[i];

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalScrollingLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalScrollingLayout.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalScrollingLayout.as
index 46cd298..c9408f9 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalScrollingLayout.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/NonVirtualVerticalScrollingLayout.as
@@ -81,7 +81,7 @@ package org.apache.flex.html.beads.layouts
 			IEventDispatcher(value).addEventListener("widthChanged", changeHandler);
 			IEventDispatcher(value).addEventListener("itemsCreated", changeHandler);
             IEventDispatcher(value).addEventListener("childrenAdded", changeHandler);
-            IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
+			IEventDispatcher(value).addEventListener("layoutNeeded", changeHandler);
 		}
 		
 		private function changeHandler(event:Event):void
@@ -126,6 +126,7 @@ package org.apache.flex.html.beads.layouts
 			for (var i:int = 0; i < n; i++)
 			{
 				var ir:IUIBase = contentView.getElementAt(i) as IUIBase;
+				if (ir == null || !ir.visible) continue;
 				ir.y = yy;
 				ir.width = contentView.width;
 				yy += ir.height;			

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/TileLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/TileLayout.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/TileLayout.as
index ac3b837..cbdb4dc 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/TileLayout.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/beads/layouts/TileLayout.as
@@ -67,6 +67,7 @@ package org.apache.flex.html.beads.layouts
 			
 			IEventDispatcher(_strand).addEventListener("itemsCreated",handleCreated);
 			IEventDispatcher(_strand).addEventListener("childrenAdded",handleCreated);
+			IEventDispatcher(_strand).addEventListener("layoutNeeded",handleCreated);
 		}
 		
 		private var _numColumns:Number = 4;
@@ -155,16 +156,24 @@ package org.apache.flex.html.beads.layouts
 			var n:Number = area.numChildren;
 			if (n == 0) return;
 			
+			var realN:Number = n;
+			for(var j:int=0; j < n; j++)
+			{
+				var testChild:IUIBase = area.getChildAt(i) as IUIBase;
+				if (testChild && !testChild.visible) realN--;
+			}
+			
 			if (isNaN(useWidth)) useWidth = Math.floor(area.width / numColumns); // + gap
 			if (isNaN(useHeight)) {
 				// given the width and total number of items, how many rows?
-				var numRows:Number = Math.floor(n/numColumns);
+				var numRows:Number = Math.floor(realN/numColumns);
 				useHeight = Math.floor(area.height / numRows);
 			}
 			
 			for(var i:int=0; i < n; i++)
 			{
 				var child:IUIBase = area.getChildAt(i) as IUIBase;
+				if (child && !child.visible) continue;
 				child.width = useWidth;
 				child.height = useHeight;
 				child.x = xpos;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
index b4c99a4..24c9cb6 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js
@@ -835,6 +835,7 @@ org_apache_flex_core_UIBase.prototype.set_visible = function(value) {
       }
       this.dispatchEvent(new org_apache_flex_events_Event('show'));
     }
+    this.dispatchEvent(new org_apache_flex_events_Event('visibleChanged'));
   }
 };
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d15d5803/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/TileLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/TileLayout.js b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/TileLayout.js
index 38cc680..f1aa9f9 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/TileLayout.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/beads/layouts/TileLayout.js
@@ -128,6 +128,13 @@ org_apache_flex_html_beads_layouts_TileLayout.
   n = children.length;
   if (n === 0) return;
 
+  var realN = n;
+  for (i = 0; i < n; i++)
+  {
+    var child = children[i].flexjs_wrapper;
+    if (!child.get_visible()) realN--;
+  }
+
   xpos = 0;
   ypos = 0;
   useWidth = this.get_columnWidth();
@@ -136,13 +143,14 @@ org_apache_flex_html_beads_layouts_TileLayout.
   if (isNaN(useWidth)) useWidth = Math.floor(this.strand_.get_width() / this.get_numColumns());
// + gap
   if (isNaN(useHeight)) {
     // given the width and total number of items, how many rows?
-    var numRows = Math.floor(n / this.get_numColumns());
+    var numRows = Math.floor(realN / this.get_numColumns());
     useHeight = Math.floor(this.strand_.get_height() / numRows);
   }
 
   for (i = 0; i < n; i++)
   {
     var child = children[i].flexjs_wrapper;
+    if (!child.get_visible()) continue;
     child.positioner.internalDisplay = 'inline-block';
     child.set_width(useWidth);
     child.set_height(useHeight);


Mime
View raw message