flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [3/6] git commit: [flex-asjs] [refs/heads/develop] - fix up panel sizing in FlexJSStore
Date Wed, 26 Aug 2015 06:16:39 GMT
fix up panel sizing in FlexJSStore


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

Branch: refs/heads/develop
Commit: 339462a8332dfeea98a13ea648fa88afa5dc6d26
Parents: b6cce51
Author: Alex Harui <aharui@apache.org>
Authored: Tue Aug 25 17:20:13 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Aug 25 17:20:13 2015 -0700

----------------------------------------------------------------------
 .../src/org/apache/flex/core/IViewportModel.as  |  3 +
 .../src/org/apache/flex/html/beads/PanelView.as | 73 +++++++++++++++++---
 2 files changed, 67 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/339462a8/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as b/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as
index 0f894dd..662577a 100644
--- a/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as
+++ b/frameworks/projects/Core/as/src/org/apache/flex/core/IViewportModel.as
@@ -22,6 +22,9 @@ package org.apache.flex.core
 	 * A Viewport is a window onto an area of content. A viewport is given space
 	 * in which to operate by a View bead and given this model with the properties
 	 * necessary for its function.
+     * The viewport is the non-chrome, non-border area in a container.
+     * The contentView is then offset from the viewport area for padding and
+     * potentially scrollbars.
 	 */
 	public interface IViewportModel extends IBeadModel
 	{	

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/339462a8/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 4b4b0c4..2d6eae7 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
@@ -26,12 +26,14 @@ package org.apache.flex.html.beads
 	import org.apache.flex.core.IViewportModel;
 	import org.apache.flex.core.UIBase;
 	import org.apache.flex.core.UIMetrics;
+    import org.apache.flex.core.ValuesManager;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.html.Container;
 	import org.apache.flex.html.Panel;
 	import org.apache.flex.html.TitleBar;
 	import org.apache.flex.utils.BeadMetrics;
+    import org.apache.flex.utils.CSSUtils;
 	
 	/**
 	 *  The Panel class creates the visual elements of the org.apache.flex.html.Panel 
@@ -113,21 +115,74 @@ package org.apache.flex.html.beads
 			super.completeSetup();
 		}
 		
+        override protected function adjustSizeBeforeLayout():void
+        {
+            var metrics:UIMetrics = BeadMetrics.getMetrics(host);
+            
+            viewportModel.contentWidth = Math.max(host.width - metrics.left - metrics.right,
0);
+            viewportModel.contentHeight = Math.max(host.height - titleBar.height - metrics.top
- metrics.bottom, 0);
+            viewportModel.contentX = metrics.left;
+            viewportModel.contentY = metrics.top;
+            
+            contentView.x = viewportModel.contentX;
+            contentView.y = viewportModel.contentY;
+            contentView.width = viewportModel.contentWidth;
+            contentView.height = viewportModel.contentHeight;
+        }
+        
 		override protected function layoutContainer(widthSizedToContent:Boolean, heightSizedToContent:Boolean):void
 		{
-			titleBar.x = 0;
-			titleBar.y = 0;
-			titleBar.width = host.width;
-			titleBar.dispatchEvent( new Event("layoutNeeded") );
+            var borderThickness:Object = ValuesManager.valuesImpl.getValue(host,"border-width");
+            var borderStyle:Object = ValuesManager.valuesImpl.getValue(host,"border-style");
+            var border:Object = ValuesManager.valuesImpl.getValue(host,"border");
+            var borderOffset:Number;
+            if (borderStyle == "none")
+                borderOffset = 0;
+            else if (borderThickness != null)
+            {
+                if (borderThickness is String)
+                    borderOffset = CSSUtils.toNumber(borderThickness as String, host.width);
+                else
+                    borderOffset = Number(borderThickness);
+                if( isNaN(borderOffset) ) borderOffset = 0;            
+            }
+            else // no style and/or no width
+            {
+                border = ValuesManager.valuesImpl.getValue(host,"border");
+                if (border != null)
+                {
+                    if (border is Array)
+                    {
+                        borderOffset = CSSUtils.toNumber(border[0], host.width);
+                        borderStyle = border[1];
+                    }
+                    else if (border == "none")
+                        borderOffset = 0;
+                    else if (border is String)
+                        borderOffset = CSSUtils.toNumber(border as String, host.width);
+                    else
+                        borderOffset = Number(border);
+                }
+                else // no border style set at all so default to none
+                    borderOffset = 0;
+            }
+
+            titleBar.x = borderOffset;
+			titleBar.y = borderOffset;
+			titleBar.width = host.width - 2 * borderOffset;
+			titleBar.dispatchEvent( new Event("layoutNeeded") ); // this shouldn't be needed
 			
 			if (heightSizedToContent) {
-				host.height = host.height + titleBar.height;
+				host.height = viewportModel.contentHeight + titleBar.height + 2 * borderOffset;
 			}
+            if (widthSizedToContent) {
+                host.width = viewportModel +  2 * borderOffset;
+            }
 			
-			viewportModel.viewportHeight = host.height - titleBar.height;
-			viewportModel.viewportWidth = host.width;
-			viewportModel.viewportX = 0;
-			viewportModel.viewportY = titleBar.height;
+			viewportModel.viewportHeight = host.height - titleBar.height - 2 * borderOffset;
+			viewportModel.viewportWidth = host.width - 2 * borderOffset;
+			viewportModel.viewportX = borderOffset;
+			viewportModel.viewportY = titleBar.height + borderOffset;
 		}       
 	}
 }


Mime
View raw message