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] - Resolves layout timing issues. Cleaned up Panel presentation.
Date Thu, 16 Jul 2015 14:20:26 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 18b4a7a02 -> d0fa0c8c8


Resolves layout timing issues. Cleaned up Panel presentation.


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

Branch: refs/heads/develop
Commit: d0fa0c8c86a704a3ab07fb902fa412ea534b2dae
Parents: 18b4a7a
Author: Peter Ent <pent@apache.org>
Authored: Thu Jul 16 10:20:19 2015 -0400
Committer: Peter Ent <pent@apache.org>
Committed: Thu Jul 16 10:20:19 2015 -0400

----------------------------------------------------------------------
 frameworks/projects/HTML/as/defaults.css        |  4 +-
 .../org/apache/flex/html/beads/ContainerView.as | 49 +++++++++++++-------
 .../src/org/apache/flex/html/beads/PanelView.as | 15 +++---
 .../flex/html/beads/PanelWithControlBarView.as  | 38 +++++++--------
 .../flex/html/beads/SolidBackgroundBead.as      |  3 +-
 .../html/supportClasses/ScrollingViewport.as    | 12 ++---
 6 files changed, 66 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0fa0c8c/frameworks/projects/HTML/as/defaults.css
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/defaults.css b/frameworks/projects/HTML/as/defaults.css
index dc0311d..c18570a 100644
--- a/frameworks/projects/HTML/as/defaults.css
+++ b/frameworks/projects/HTML/as/defaults.css
@@ -95,7 +95,7 @@ Container
 ControlBar
 {
 	IBeadView: ClassReference("org.apache.flex.html.beads.ContainerView");
-	IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalLayout");
+	IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.FlexibleFirstChildHorizontalLayout");
 	
     background-color: #CECECE;
     border-style: solid;
@@ -293,7 +293,7 @@ Container
 
 ControlBar
 {
-    IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.HorizontalLayout");
+	IBeadLayout: ClassReference("org.apache.flex.html.beads.layouts.FlexibleFirstChildHorizontalLayout");
     iMeasurementBead: ClassReference("org.apache.flex.html.beads.ControlBarMeasurementBead");
     iBackgroundBead: ClassReference("org.apache.flex.html.beads.SolidBackgroundBead");
     iBorderBead: ClassReference("org.apache.flex.html.beads.SingleLineBorderBead");    

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0fa0c8c/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 e201c64..517d22d 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
@@ -96,28 +96,32 @@ package org.apache.flex.html.beads
 			
 			displayBackgroundAndBorder(host as UIBase);
 			
+			// listen for initComplete to signal that the strand is set with its size
+			// and beads.
+			host.addEventListener("initComplete", initCompleteHandler);
+		}
+		
+		protected function initCompleteHandler(event:Event):void
+		{
+			trace("initCompleteHandler: completeSetup for "+UIBase(_strand).id);
+			// if the host component is not being sized by percentage, go ahead and complete the setup.
 			if (isNaN((host as UIBase).percentHeight) && isNaN((host as UIBase).percentWidth))
{
 				completeSetup();
-				IEventDispatcher(_strand).dispatchEvent( new Event("viewCreated") );
+				performLayout(event);
 			}
 			else {
+				trace(" -- deferring setup for "+UIBase(_strand).id);
+				// otherwise, wait until the size has been set and then finish
 				host.addEventListener("sizeChanged", deferredSizeHandler);
 			}
 		}
 		
-		protected function createContentView():IParentIUIBase
-		{
-			var area:ContainerContentArea = new ContainerContentArea();
-			area.className = "ActualParent";
-			return area;
-		}
-		
 		protected function deferredSizeHandler(event:Event):void
 		{
+			trace("deferredSizeHandler ("+event.type+"): "+UIBase(_strand).id);
 			host.removeEventListener(event.type, deferredSizeHandler);
-			
 			completeSetup();
-			IEventDispatcher(_strand).dispatchEvent( new Event("viewCreated") );
+			performLayout(event);
 		}
 		
 		protected function completeSetup():void
@@ -134,6 +138,13 @@ package org.apache.flex.html.beads
 			host.addEventListener("viewCreated", viewCreatedHandler);
 		}
 		
+		protected function createContentView():IParentIUIBase
+		{
+			var area:ContainerContentArea = new ContainerContentArea();
+			area.className = "ActualParent";
+			return area;
+		}
+		
 		protected function viewCreatedHandler(event:Event):void
 		{
 			resizeViewport();
@@ -166,12 +177,14 @@ package org.apache.flex.html.beads
 				viewport.model = viewportModel;
 			}
 			
+			var metrics:UIMetrics = BeadMetrics.getMetrics(host);
+			
 			viewportModel.contentArea = contentView;
 			viewportModel.contentIsHost = false;
-			viewportModel.contentWidth = host.width;
-			viewportModel.contentHeight = host.height;
-			viewportModel.contentX = 0;
-			viewportModel.contentY = 0;
+			viewportModel.contentWidth = host.width - metrics.left - metrics.right;
+			viewportModel.contentHeight = host.height - metrics.top - metrics.bottom;
+			viewportModel.contentX = metrics.left;
+			viewportModel.contentY = metrics.top;
 			
 			resizeViewport();
 		}
@@ -199,21 +212,23 @@ package org.apache.flex.html.beads
 		protected function adjustSizeAfterLayout():void
 		{
 			var host:UIBase = _strand as UIBase;
+			var metrics:UIMetrics = BeadMetrics.getMetrics(host);
 			
 			if (host.isWidthSizedToContent() && host.isHeightSizedToContent()) {					
-				host.setWidthAndHeight(viewportModel.contentWidth, viewportModel.contentHeight, true);
+				host.setWidthAndHeight(viewportModel.contentWidth+metrics.left+metrics.right, 
+					viewportModel.contentHeight+metrics.top+metrics.bottom, false);
 				resizeViewport();
 			}
 			else if (!host.isWidthSizedToContent() && host.isHeightSizedToContent())
 			{
 				viewport.needsHorizontalScroller();
-				host.setHeight(viewportModel.contentHeight, false);
+				host.setHeight(viewportModel.contentHeight-metrics.top-metrics.bottom, false);
 				resizeViewport();
 			}
 			else if (host.isWidthSizedToContent() && !host.isHeightSizedToContent())
 			{
 				viewport.needsVerticalScroller();
-				host.setWidth(viewportModel.contentWidth, false);
+				host.setWidth(viewportModel.contentWidth-metrics.left-metrics.right, false);
 				resizeViewport();
 			}
 			else {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0fa0c8c/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
index 67da9a4..2d3e4e4 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelView.as
@@ -92,8 +92,11 @@ package org.apache.flex.html.beads
 		{
             var host:UIBase = UIBase(value);
             
-            if (!_titleBar)
+            if (!_titleBar) {
                 _titleBar = new TitleBar();
+				_titleBar.id = "panelTitleBar";
+				_titleBar.height = 30;
+			}
 			// replace the TitleBar's model with the Panel's model (it implements ITitleBarModel)
so that
 			// any changes to values in the Panel's model that correspond values in the TitleBar will

 			// be picked up automatically by the TitleBar.
@@ -107,7 +110,6 @@ package org.apache.flex.html.beads
 			super.completeSetup();
 			
 			UIBase(_strand).addElement(titleBar, false);
-			titleBar.addEventListener("heightChanged", titleBarHeightChanged);
 		}
 		
 		/**
@@ -119,7 +121,6 @@ package org.apache.flex.html.beads
 			var metrics:UIMetrics = BeadMetrics.getMetrics(host);
 			
 			titleBar.width = host.width;
-			titleBar.height = 25;
 			titleBar.dispatchEvent( new Event("layoutNeeded") );
 			
 			var model:IViewportModel = viewport.model;
@@ -130,7 +131,7 @@ package org.apache.flex.html.beads
 			model.contentX = model.viewportX + metrics.left;
 			model.contentY = model.viewportY + metrics.top;
 			model.contentWidth = model.viewportWidth - metrics.left - metrics.right;
-			model.contentHeight = model.viewportHeight - metrics.top - metrics.bottom;
+			model.contentHeight = model.viewportHeight - metrics.bottom;
 			model.contentArea = contentView;
 			model.contentIsHost = false;
 			
@@ -151,6 +152,7 @@ package org.apache.flex.html.beads
 			titleBar.x = 0;
 			titleBar.y = 0;
 			titleBar.width = host.width;
+			titleBar.dispatchEvent( new Event("layoutNeeded") );
 			
 			// If the host is being sized by its content, the change in the contentArea
 			// causes the host's size to change
@@ -185,11 +187,6 @@ package org.apache.flex.html.beads
 				viewport.updateContentAreaSize();
 			}
 		}
-		
-		private function titleBarHeightChanged(event:Event):void
-		{
-			resizeViewport();
-		}
                 
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0fa0c8c/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelWithControlBarView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelWithControlBarView.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelWithControlBarView.as
index 286184b..ea66f6f 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelWithControlBarView.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/PanelWithControlBarView.as
@@ -103,16 +103,25 @@ package org.apache.flex.html.beads
 			var host:UIBase = UIBase(value);
 			
 			// TODO: (aharui) get class to instantiate from CSS
-			if (!_titleBar)
+			if (!_titleBar) {
 				_titleBar = new TitleBar();
+				_titleBar.id = "panelTitleBar";
+				_titleBar.height = 30;
+			}
 			// replace the TitleBar's model with the Panel's model (it implements ITitleBarModel)
so that
 			// any changes to values in the Panel's model that correspond values in the TitleBar will

 			// be picked up automatically by the TitleBar.
-			titleBar.model = host.model;
+			_titleBar.model = host.model;
 			
 			var controlBarItems:Array = (host.model as IPanelModel).controlBar;
 			if( controlBarItems && controlBarItems.length > 0 ) {
 				_controlBar = new ControlBar();
+				_controlBar.id = "panelControlBar";
+				_controlBar.height = 30;
+				
+				for each(var comp:IUIBase in controlBarItems) {
+					_controlBar.addElement(comp, false);
+				}
 			}
 			
 			super.strand = value;
@@ -123,20 +132,9 @@ package org.apache.flex.html.beads
 			super.completeSetup();
 			
 			UIBase(_strand).addElement(titleBar, false);
-			titleBar.addEventListener("heightChanged", chromeHeightChanged);
 			
-			var controlBarItems:Array = (UIBase(_strand).model as IPanelModel).controlBar;
-			if( _controlBar ) {
-				_controlBar.percentWidth = 100;
-				_controlBar.height = 30;
-				
-				for each(var comp:IUIBase in controlBarItems) {
-					_controlBar.addElement(comp, false);
-				}
-				_controlBar.dispatchEvent(new Event("layoutNeeded"));
-				
-				UIBase(_strand).addElement(controlBar, false);
-				controlBar.addEventListener("heightChanged", chromeHeightChanged);
+			if (controlBar) {
+				UIBase(_strand).addElement(_controlBar, false);
 			}
 		}
 		
@@ -146,8 +144,11 @@ package org.apache.flex.html.beads
 			var metrics:UIMetrics = BeadMetrics.getMetrics(host);
 			
 			titleBar.width = host.width;
+			titleBar.dispatchEvent( new Event("layoutNeeded") );
+			
 			if (controlBar) {
 				controlBar.width = host.width;
+				controlBar.dispatchEvent( new Event("layoutNeeded") );
 				controlBar.y = host.height - controlBar.height;
 			}
 			
@@ -176,10 +177,12 @@ package org.apache.flex.html.beads
 			titleBar.x = 0;
 			titleBar.y = 0;
 			titleBar.width = host.width;
+			titleBar.dispatchEvent( new Event("layoutNeeded") );
 			
 			if (controlBar) {
 				controlBar.width = host.width;
 				controlBar.y = host.height - controlBar.height;
+				controlBar.dispatchEvent( new Event("layoutNeeded") );
 			}
 			
 			// If the host is being sized by its content, the change in the contentArea
@@ -225,10 +228,5 @@ package org.apache.flex.html.beads
 				viewport.updateContentAreaSize();
 			}
 		}
-		
-		private function chromeHeightChanged(event:Event):void
-		{
-			resizeViewport();
-		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0fa0c8c/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
index ffa5502..696c814 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/beads/SolidBackgroundBead.as
@@ -75,7 +75,8 @@ package org.apache.flex.html.beads
             
             IEventDispatcher(host).addEventListener("heightChanged", changeHandler);
             IEventDispatcher(host).addEventListener("widthChanged", changeHandler);
-            IEventDispatcher(host).addEventListener("sizeChanged", changeHandler);
+			IEventDispatcher(host).addEventListener("sizeChanged", changeHandler);
+			IEventDispatcher(host).addEventListener("initComplete", changeHandler);
 			
 			var bgColor:Object = ValuesManager.valuesImpl.getValue(host, "background-color");
 			if( bgColor != null ) {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d0fa0c8c/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollingViewport.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollingViewport.as
b/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollingViewport.as
index 0b55370..fdce428 100644
--- a/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollingViewport.as
+++ b/frameworks/projects/HTML/as/src/org/apache/flex/html/supportClasses/ScrollingViewport.as
@@ -147,23 +147,23 @@ package org.apache.flex.html.supportClasses
 			if (addVbar) needsVerticalScroller();
 			if (_verticalScroller) {
 				ScrollBarModel(_verticalScroller.model).maximum = model.contentHeight;
-				ScrollBarModel(_verticalScroller.model).pageSize = model.viewportHeight - metrics.top
- metrics.bottom;
-				ScrollBarModel(_verticalScroller.model).pageStepSize = model.viewportHeight - metrics.top
- metrics.bottom;
+				ScrollBarModel(_verticalScroller.model).pageSize = model.viewportHeight;// - metrics.top
- metrics.bottom;
+				ScrollBarModel(_verticalScroller.model).pageStepSize = model.viewportHeight;// - metrics.top
- metrics.bottom;
 			}
 			
 			if (addHbar) needsHorizontalScroller();
 			if (_horizontalScroller) {
 				ScrollBarModel(_horizontalScroller.model).maximum = model.contentWidth;
-				ScrollBarModel(_horizontalScroller.model).pageSize = model.viewportWidth - metrics.left
- metrics.right;
-				ScrollBarModel(_horizontalScroller.model).pageStepSize = model.viewportWidth - metrics.left
- metrics.right
+				ScrollBarModel(_horizontalScroller.model).pageSize = model.viewportWidth;// - metrics.left
- metrics.right;
+				ScrollBarModel(_horizontalScroller.model).pageStepSize = model.viewportWidth;// - metrics.left
- metrics.right
 			}
 			
 			var rect:Rectangle = contentArea.scrollRect;
 			if (rect) {
 				rect.x = 0;
 				rect.y = 0;
-				rect.width = model.viewportWidth - metrics.left - metrics.right;
-				rect.height = model.viewportHeight - 2*metrics.top - 2*metrics.bottom;
+				rect.width = model.viewportWidth - metrics.left;// - metrics.right;
+				rect.height = model.viewportHeight - 2*metrics.top;// - 2*metrics.bottom;
 				contentArea.scrollRect = rect;
 			}
 		}


Mime
View raw message