flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject [1/2] git commit: [flex-asjs] [refs/heads/develop] - Updates the Container classes, including layouts, with a new life-cycle.
Date Tue, 25 Aug 2015 15:45:53 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 052af9d3c -> f03e77f54


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/StackedViewManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/StackedViewManager.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/StackedViewManager.as
index 54f3fd1..4b29d28 100644
--- a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/StackedViewManager.as
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/StackedViewManager.as
@@ -19,22 +19,14 @@
 package org.apache.flex.mobile
 {	
 	import org.apache.flex.events.Event;
-	import org.apache.flex.mobile.ManagerBase;
+	import org.apache.flex.html.Container;
+	import org.apache.flex.mobile.IView;
+	import org.apache.flex.mobile.IViewManager;
 	import org.apache.flex.mobile.chrome.NavigationBar;
 	import org.apache.flex.mobile.chrome.ToolBar;
 	import org.apache.flex.mobile.models.ViewManagerModel;
 	
 	/**
-	 * Event dispatched when the currently selected view changes.
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10.2
-	 *  @playerversion AIR 2.6
-	 *  @productversion FlexJS 0.0
-	 */
-	[Event("viewChanged")]
-	
-	/**
 	 * The StackedViewManager displays a single View at a time from a
 	 * collection of Views where views[0] is at the bottom and views[n-1]
 	 * is at the top and displayed.
@@ -48,7 +40,7 @@ package org.apache.flex.mobile
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	public class StackedViewManager extends ManagerBase implements IViewManager
+	public class StackedViewManager extends ViewManagerBase implements IViewManager
 	{
 		/**
 		 * Constructor.
@@ -66,95 +58,6 @@ package org.apache.flex.mobile
 		}
 		
 		/**
-		 * @private
-		 */
-		override public function addedToParent():void
-		{
-			super.addedToParent();
-			
-			var n:int = ViewManagerModel(model).views.length;
-			if (n > 0) {
-				for (var i:int = 0; i < n; i++)
-				{
-					var view:IView = ViewManagerModel(model).views[i] as IView;
-					view.viewManager = this;
-					if (i == (n-1)) {
-						addElement(view,false);
-						_topView = view;
-					}
-				}
-			}
-		}
-		
-		/**
-		 * The title to use in the NavigationBar.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get title():String
-		{
-			return ViewManagerModel(model).title;
-		}
-		public function set title(value:String):void
-		{
-			ViewManagerModel(model).title = value;
-		}
-		
-		/**
-		 * @private
-		 */
-		override public function toString():String
-		{
-			return ViewManagerModel(model).title;
-		}
-		
-		/**
-		 * True if this view manager is displaying a NavigationBar.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get hasNavigationBar():Boolean
-		{
-			return ViewManagerModel(model).navigationBarItems != null;
-		}
-		
-		/**
-		 * The contents of the NavigationBar.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get navigationBarItems():Array
-		{
-			return ViewManagerModel(model).navigationBarItems;
-		}
-		public function set navigationBarItems(value:Array):void
-		{
-			ViewManagerModel(model).navigationBarItems = value;
-		}
-		
-		/**
-		 * The NavigationBar (or null if not present).
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get navigationBar():NavigationBar
-		{
-			return ViewManagerModel(model).navigationBar; 
-		}
-				
-		/**
 		 * True if this view manager is displaying a ToolBar.
 		 *  
 		 *  @langversion 3.0
@@ -196,9 +99,10 @@ package org.apache.flex.mobile
 		{
 			return ViewManagerModel(model).toolBar;
 		}
+
 		
 		private var _topView:IView;
-		
+
 		/**
 		 * The top-most (current) view.
 		 *  
@@ -207,28 +111,11 @@ package org.apache.flex.mobile
 		 *  @playerversion AIR 2.6
 		 *  @productversion FlexJS 0.0
 		 */
-		public function get selectedView():IView
+		override public function get selectedView():IView
 		{
 			return _topView;
 		}
-		
-		/**
-		 *  The current set of views in the stack. The last entry is
-		 *  the top-most (visible) view.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get views():Array
-		{
-			return ViewManagerModel(model).views;
-		}
-		public function set views(value:Array):void
-		{
-			ViewManagerModel(model).views = value;
-		}
+
 		
 		/**
 		 *  Pushes the next view onto the navigation stack.
@@ -249,6 +136,7 @@ package org.apache.flex.mobile
 			
 			dispatchEvent( new Event("viewChanged") );
 		}
+		
 		/**
 		 *  Pops the top-most view from the navigation stack.
 		 *  
@@ -268,24 +156,6 @@ package org.apache.flex.mobile
 				dispatchEvent( new Event("viewChanged") );
 			}
 		}
-		
-		private var _viewManager:IViewManager;
-		
-		/**
-		 * This view manager's parent view manager, if any.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get viewManager():IViewManager
-		{
-			return _viewManager;
-		}
-		public function set viewManager(value:IViewManager):void
-		{
-			_viewManager = value;
-		}
+
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/TabbedViewManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/TabbedViewManager.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/TabbedViewManager.as
index 78cda35..43fc6a6 100644
--- a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/TabbedViewManager.as
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/TabbedViewManager.as
@@ -18,24 +18,13 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mobile
 {	
-	import org.apache.flex.events.Event;
-	import org.apache.flex.mobile.ManagerBase;
-	import org.apache.flex.mobile.chrome.NavigationBar;
+	import org.apache.flex.html.Container;
+	import org.apache.flex.mobile.IView;
+	import org.apache.flex.mobile.IViewManager;
 	import org.apache.flex.mobile.chrome.TabBar;
-	import org.apache.flex.mobile.chrome.ToolBar;
 	import org.apache.flex.mobile.models.ViewManagerModel;
 	
 	/**
-	 * Event dispatched when the current (selected) view changes.
-	 *  
-	 *  @langversion 3.0
-	 *  @playerversion Flash 10.2
-	 *  @playerversion AIR 2.6
-	 *  @productversion FlexJS 0.0
-	 */
-	[Event(name="viewChanged")]
-	
-	/**
 	 * The TabbedViewManager displays a set of views, only one of which is active at
 	 * a time. The other views are reachable via a set of tab buttons at the bottom of
 	 * the view manager's space.
@@ -45,7 +34,7 @@ package org.apache.flex.mobile
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	public class TabbedViewManager extends ManagerBase implements IViewManager
+	public class TabbedViewManager extends ViewManagerBase implements IViewManager
 	{
 		/**
 		 * Constructor.
@@ -60,76 +49,6 @@ package org.apache.flex.mobile
 			super();
 			
 			className = "TabbedViewManager";
-			
-			model.addEventListener("selectedIndexChanged", changeView);
-		}
-		
-		/**
-		 * A title that can be used in the NavigationBar.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get title():String
-		{
-			return ViewManagerModel(model).title;
-		}
-		public function set title(value:String):void
-		{
-			ViewManagerModel(model).title = value;
-		}
-		
-		/**
-		 * @private
-		 */
-		override public function toString():String
-		{
-			return ViewManagerModel(model).title;
-		}
-		
-		/**
-		 * True if this view manager instance is displaying a NavigationBar.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get hasNavigationBar():Boolean
-		{
-			return ViewManagerModel(model).navigationBarItems != null;
-		}
-		
-		/**
-		 * The items that make up the NavigationBar.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get navigationBarItems():Array
-		{
-			return ViewManagerModel(model).navigationBarItems;
-		}
-		public function set navigationBarItems(value:Array):void
-		{
-			ViewManagerModel(model).navigationBarItems = value;
-		}
-		
-		/**
-		 * The NavigationBar (or null if not present).
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get navigationBar():NavigationBar
-		{
-			return ViewManagerModel(model).navigationBar; 
 		}
 		
 		/**
@@ -161,97 +80,6 @@ package org.apache.flex.mobile
 		{
 			ViewManagerModel(model).selectedIndex = value;
 		}
-		
-		private var _currentView:IView;
-		
-		/**
-		 * The currently visible view.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get selectedView():IView
-		{
-			return _currentView;
-		}
-		
-		/**
-		 *  The current set of views in the stack. The last entry is
-		 *  the top-most (visible) view.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get views():Array
-		{
-			return ViewManagerModel(model).views;
-		}
-		public function set views(value:Array):void
-		{
-			ViewManagerModel(model).views = value;
-		}
-		
-		/**
-		 * @private
-		 */
-		private function changeView( event:Event ):void
-		{
-			var index:Number = ViewManagerModel(model).selectedIndex;
-			if (_currentView) {
-				removeElement(_currentView);
-			}
-			_currentView = views[index];
-			addElement(_currentView);
-			
-			dispatchEvent( new Event("viewChanged") );
-		}
-		
-		/**
-		 * @private
-		 */
-		override public function addedToParent():void
-		{
-			super.addedToParent();
-			
-			var n:int = ViewManagerModel(model).views.length;
-			if (n > 0) {
-				for (var i:int = 0; i < n; i++)
-				{
-					var view:IView = ViewManagerModel(model).views[i] as IView;
-					view.viewManager = this;
-					if (i == 0) {
-						addElement(view,false);
-					}
-				}
-				ViewManagerModel(model).selectedIndex = 0;
-			}
-		}
-		
-		/**
-		 * IViewManager
-		 */
-		
-		private var _viewManager:IViewManager;
-		
-		/**
-		 * This view manager's parent view manager, if any.
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function get viewManager():IViewManager
-		{
-			return _viewManager;
-		}
-		public function set viewManager(value:IViewManager):void
-		{
-			_viewManager = value;
-		}
+
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/ViewManagerBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/ViewManagerBase.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/ViewManagerBase.as
new file mode 100644
index 0000000..2ff631e
--- /dev/null
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/ViewManagerBase.as
@@ -0,0 +1,211 @@
+package org.apache.flex.mobile
+{
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.html.Container;
+	import org.apache.flex.mobile.IView;
+	import org.apache.flex.mobile.IViewManager;
+	import org.apache.flex.mobile.chrome.NavigationBar;
+	import org.apache.flex.mobile.models.ViewManagerModel;
+	
+//	import org.apache.flex.html.beads.SolidBackgroundBead;
+//	import org.apache.flex.html.beads.SingleLineBorderBead;
+	
+	/**
+	 * Event dispatched when the current (selected) view changes.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	[Event(name="viewChanged")]
+	
+	/**
+	 * Base class for mobile navigation controls.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class ViewManagerBase extends UIBase implements IViewManager
+	{
+		/**
+		 * Constructor.
+		 */
+		public function ViewManagerBase()
+		{
+			super();
+			
+			// views always fill their space
+			percentWidth = 100;
+			percentHeight = 100;
+			
+			model.addEventListener("selectedIndexChanged", changeView);
+			
+//			addBead(new SolidBackgroundBead());
+//			addBead(new SingleLineBorderBead());
+		}
+		
+		/**
+		 * A title that can be used in the NavigationBar.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get title():String
+		{
+			return ViewManagerModel(model).title;
+		}
+		public function set title(value:String):void
+		{
+			ViewManagerModel(model).title = value;
+		}
+		
+		/**
+		 * @private
+		 */
+		override public function toString():String
+		{
+			return ViewManagerModel(model).title;
+		}
+		
+		/**
+		 * True if this view manager instance is displaying a NavigationBar.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get hasNavigationBar():Boolean
+		{
+			return ViewManagerModel(model).navigationBarItems != null;
+		}
+		
+		/**
+		 * The items that make up the NavigationBar.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get navigationBarItems():Array
+		{
+			return ViewManagerModel(model).navigationBarItems;
+		}
+		public function set navigationBarItems(value:Array):void
+		{
+			ViewManagerModel(model).navigationBarItems = value;
+		}
+		
+		/**
+		 * The NavigationBar (or null if not present).
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get navigationBar():NavigationBar
+		{
+			return ViewManagerModel(model).navigationBar; 
+		}
+		
+		/**
+		 *  The current set of views in the stack. The last entry is
+		 *  the top-most (visible) view.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get views():Array
+		{
+			return ViewManagerModel(model).views;
+		}
+		public function set views(value:Array):void
+		{
+			ViewManagerModel(model).views = value;
+		}
+		
+		/**
+		 * @private
+		 */
+		override public function addedToParent():void
+		{
+			super.addedToParent();
+			
+			var n:int = ViewManagerModel(model).views.length;
+			if (n > 0) {
+				for (var i:int = 0; i < n; i++)
+				{
+					var view:IView = ViewManagerModel(model).views[i] as IView;
+					view.viewManager = this;
+					if (i == 0) {
+						addElement(view, true);
+					}
+				}
+				ViewManagerModel(model).selectedIndex = 0;
+			}
+		}
+		
+		/**
+		 * @private
+		 */
+		private function changeView( event:Event ):void
+		{
+			var index:Number = ViewManagerModel(model).selectedIndex;
+			if (_currentView) {
+				removeElement(_currentView);
+			}
+			_currentView = views[index];
+			addElement(_currentView);
+
+			dispatchEvent( new Event("viewChanged") );
+		}
+		
+		private var _currentView:IView;
+		
+		/**
+		 * The currently visible view.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get selectedView():IView
+		{
+			return _currentView;
+		}
+		
+		/**
+		 * IViewManager
+		 */
+		
+		private var _viewManager:IViewManager;
+		
+		/**
+		 * This view manager's parent view manager, if any.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function get viewManager():IViewManager
+		{
+			return _viewManager;
+		}
+		public function set viewManager(value:IViewManager):void
+		{
+			_viewManager = value;
+		}
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/StackedViewManagerView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/StackedViewManagerView.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/StackedViewManagerView.as
index b66d397..a38d2aa 100644
--- a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/StackedViewManagerView.as
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/StackedViewManagerView.as
@@ -17,18 +17,21 @@
 //
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.flex.mobile.beads
-{
+{	
 	import org.apache.flex.core.IBeadModel;
-	import org.apache.flex.core.IBeadView;
 	import org.apache.flex.core.IStrand;
-	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.IViewportModel;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.UIMetrics;
+	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.events.Event;
+	import org.apache.flex.html.beads.ContainerView;
 	import org.apache.flex.html.beads.layouts.HorizontalLayout;
-	import org.apache.flex.mobile.ManagerBase;
 	import org.apache.flex.mobile.chrome.NavigationBar;
 	import org.apache.flex.mobile.chrome.ToolBar;
 	import org.apache.flex.mobile.models.ViewManagerModel;
-	
+	import org.apache.flex.utils.BeadMetrics;
+
 	/**
 	 * The StackedViewManagerView creates the visual elements of the StackedViewManager. This
 	 * includes a NavigationBar, ToolBar, and contentArea.
@@ -38,7 +41,7 @@ package org.apache.flex.mobile.beads
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	public class StackedViewManagerView implements IBeadView
+	public class StackedViewManagerView extends ViewManagerView
 	{
 		/**
 		 * Constructor.
@@ -51,134 +54,76 @@ package org.apache.flex.mobile.beads
 		public function StackedViewManagerView()
 		{
 			super();
-			
-			layoutReady = false;
 		}
 		
-		private var _navigationBar:NavigationBar;
 		private var _toolBar:ToolBar;
-		
-		private var layoutReady:Boolean;
-		
-		private var _strand:ManagerBase;
-		
-		/**
-		 *  @copy org.apache.flex.core.IBead#strand
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function set strand(value:IStrand):void
+
+		override public function set strand(value:IStrand):void
 		{
-			_strand = value as ManagerBase;
-			_strand.addEventListener("widthChanged", changeHandler);
-			_strand.addEventListener("heightChanged", changeHandler);
-			
 			var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel;
-			model.addEventListener("viewsChanged", handleModelChanged);
-			model.addEventListener("viewPushed", handleModelChanged);
-			model.addEventListener("viewPopped", handleModelChanged);
-			
-			if (model.navigationBarItems)
-			{
-				_navigationBar = new NavigationBar();
-				_navigationBar.controls = model.navigationBarItems;
-				_navigationBar.addBead(new HorizontalLayout());
-				_strand.addElement(_navigationBar);
-			}
 			
 			if (model.toolBarItems)
 			{
 				_toolBar = new ToolBar();
 				_toolBar.controls = model.toolBarItems;
 				_toolBar.addBead(new HorizontalLayout());
-				_strand.addElement(_toolBar);
+				UIBase(value).addElement(_toolBar,false);
 			}
 			
-			layoutReady = true;
-			layoutChromeElements();			
+			super.strand = value;
 		}
-
+		override public function get strand():IStrand
+		{
+			return super.strand;
+		}
+		
 		/**
 		 * @private
 		 */
-		private function layoutChromeElements():void
+		override protected function layoutChromeElements():void
 		{
+			var host:UIBase = strand as UIBase;
 			var contentAreaY:Number = 0;
-			var contentAreaHeight:Number = _strand.height;
+			var contentAreaHeight:Number = host.height;
+			var toolbarHeight:Number = _toolBar == null ? 0 : _toolBar.height;
 			
-			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			
-			if (_navigationBar)
+			if (navigationBar)
 			{
-				_navigationBar.x = 0;
-				_navigationBar.y = 0;
-				_navigationBar.width = _strand.width;
+				navigationBar.x = 0;
+				navigationBar.y = 0;
+				navigationBar.width = host.width;
 				
-				contentAreaY = _navigationBar.height;
-				contentAreaHeight -= _navigationBar.height;
+				contentAreaHeight -= navigationBar.height;
+				contentAreaY = navigationBar.height;
 				
-				model.navigationBar = _navigationBar;
+				model.navigationBar = navigationBar;
 			}
 			
 			if (_toolBar)
 			{
 				_toolBar.x = 0;
-				_toolBar.y = _strand.height - _toolBar.height;
-				_toolBar.width = _strand.width;
+				_toolBar.y = host.height - toolbarHeight;
+				_toolBar.width = host.width;
 				
-				contentAreaHeight -= _toolBar.height;
+				contentAreaHeight -= toolbarHeight;
 				
 				model.toolBar = _toolBar;
 			}
 			
-			_strand.contentArea.x = 0;
-			_strand.contentArea.y = contentAreaY;
-			_strand.contentArea.width = _strand.width;
-			_strand.contentArea.height = contentAreaHeight;
-		}
-		
-		
-		/**
-		 * @private
-		 */
-		protected function changeHandler(event:Event):void
-		{
-			if (layoutReady) layoutChromeElements();
-		}
-		
-		/**
-		 * @private
-		 */
-		private function handleModelChanged(event:Event):void
-		{
-			trace("Model event: "+event.type);
-		}
-		
-		/**
-		 * @private
-		 */
-		public function get host():IUIBase
-		{
-			return _strand;
-		}
-		
-		/**
-		 * @private
-		 */
-		public function get viewWidth():Number
-		{
-			return _strand.width;
-		}
-		
-		/**
-		 * @private
-		 */
-		public function get viewHeight():Number
-		{
-			return _strand.height;
+			if (contentAreaY < 0) contentAreaY = 0;
+			if (contentAreaHeight < 0) contentAreaHeight = 0;
+			
+			model.contentX = 0;
+			model.contentY = contentAreaY;
+			model.contentWidth = host.width;
+			model.contentHeight = contentAreaHeight;
+			
+			sizeViewsToFitContentArea();
+			
+			// notify the views that the content size has changed
+			IEventDispatcher(strand).dispatchEvent( new Event("contentSizeChanged") );
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as
index b6742d2..de5fc92 100644
--- a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/TabbedViewManagerView.as
@@ -19,15 +19,18 @@
 package org.apache.flex.mobile.beads
 {
 	import org.apache.flex.core.IBeadModel;
-	import org.apache.flex.core.IBeadView;
 	import org.apache.flex.core.IStrand;
-	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.IViewportModel;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.UIMetrics;
+	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.events.Event;
+	import org.apache.flex.html.beads.ContainerView;
 	import org.apache.flex.html.beads.layouts.HorizontalLayout;
-	import org.apache.flex.mobile.ManagerBase;
 	import org.apache.flex.mobile.chrome.NavigationBar;
 	import org.apache.flex.mobile.chrome.TabBar;
 	import org.apache.flex.mobile.models.ViewManagerModel;
+	import org.apache.flex.utils.BeadMetrics;
 	
 	/**
 	 * The TabbedViewManagerView constructs the visual elements of the TabbedViewManager. The
@@ -38,7 +41,7 @@ package org.apache.flex.mobile.beads
 	 *  @playerversion AIR 2.6
 	 *  @productversion FlexJS 0.0
 	 */
-	public class TabbedViewManagerView implements IBeadView
+	public class TabbedViewManagerView extends ViewManagerView
 	{
 		/**
 		 * Constructor.
@@ -51,134 +54,88 @@ package org.apache.flex.mobile.beads
 		public function TabbedViewManagerView()
 		{
 			super();
-			layoutReady = false;
 		}
 		
-		private var _navigationBar:NavigationBar;
 		private var _tabBar:TabBar;
 		
-		private var layoutReady:Boolean;
-		
-		private var _strand:ManagerBase;
-		
-		/**
-		 *  @copy org.apache.flex.core.IBead#strand
-		 *  
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion FlexJS 0.0
-		 */
-		public function set strand(value:IStrand):void
+		private var _strand:IStrand;
+		override public function get strand():IStrand
 		{
-			_strand = value as ManagerBase;
-			_strand.addEventListener("widthChanged", changeHandler);
-			_strand.addEventListener("heightChanged", changeHandler);
-			_strand.addEventListener("sizeChanged", changeHandler);
+			return _strand;
+		}
+		override public function set strand(value:IStrand):void
+		{
+			_strand = value;
 			
 			var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel;
-			model.addEventListener("viewsChanged", changeHandler);
-			
-			if (model.navigationBarItems)
-			{
-				_navigationBar = new NavigationBar();
-				_navigationBar.controls = model.navigationBarItems;
-				_navigationBar.addBead(new HorizontalLayout());
-				_strand.addElement(_navigationBar);
-			}
 			
 			// TabbedViewManager always has a TabBar
 			_tabBar = new TabBar();
 			_tabBar.dataProvider = model.views;
 			_tabBar.labelField = "title";
-			_strand.addElement(_tabBar);
 			_tabBar.addEventListener("change",handleButtonBarChange);
+			UIBase(_strand).addElement(_tabBar, false);
 			
-			layoutReady = true;
+			super.strand = value;
+		}
+		
+		/**
+		 * @private
+		 */		
+		private function handleButtonBarChange(event:Event):void
+		{
+			var newIndex:Number = _tabBar.selectedIndex;
+			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			
+			// doing this will trigger the selectedIndexChanged event which will
+			// tell the strand to switch views
+			model.selectedIndex = newIndex;
 		}
 		
 		/**
 		 * @private
 		 */
-		private function layoutChromeElements():void
+		override protected function layoutChromeElements():void
 		{
+			var host:UIBase = _strand as UIBase;
 			var contentAreaY:Number = 0;
-			var contentAreaHeight:Number = _strand.height;
+			var contentAreaHeight:Number = host.height;
 			
-			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			var model:ViewManagerModel = strand.getBeadByType(IBeadModel) as ViewManagerModel;
 			
-			if (_navigationBar)
+			if (navigationBar)
 			{
-				_navigationBar.x = 0;
-				_navigationBar.y = 0;
-				_navigationBar.width = _strand.width;
+				navigationBar.x = 0;
+				navigationBar.y = 0;
+				navigationBar.width = host.width;
 				
-				contentAreaY = _navigationBar.height;
-				contentAreaHeight -= _navigationBar.height;
+				contentAreaHeight -= navigationBar.height;
+				contentAreaY = navigationBar.height;
 				
-				model.navigationBar = _navigationBar;
+				model.navigationBar = navigationBar;
 			}
 			
 			if (_tabBar)
 			{
 				_tabBar.x = 0;
-				_tabBar.y = _strand.height - _tabBar.height;
-				_tabBar.width = _strand.width;
-								
+				_tabBar.y = host.height - _tabBar.height;
+				_tabBar.width = host.width;
+				_tabBar.dispatchEvent(new Event("layoutNeeded"));
+				
 				contentAreaHeight -= _tabBar.height;
 				
 				model.tabBar = _tabBar;
 			}
 			
-			_strand.contentArea.x = 0;
-			_strand.contentArea.y = contentAreaY;
-			_strand.contentArea.width = _strand.width;
-			_strand.contentArea.height = contentAreaHeight;
-		}
-		
-		/**
-		 * @private
-		 */
-		protected function changeHandler(event:Event):void
-		{
-			if (layoutReady) layoutChromeElements();
-		}
-		
-		/**
-		 * @private
-		 */		
-		private function handleButtonBarChange(event:Event):void
-		{
-			var newIndex:Number = _tabBar.selectedIndex;
-			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			model.contentX = 0;
+			model.contentY = contentAreaY;
+			model.contentWidth = host.width;
+			model.contentHeight = contentAreaHeight;
 			
-			// doing this will trigger the selectedIndexChanged event which will
-			// tell the strand to switch views
-			model.selectedIndex = newIndex;
-		}
-		
-		/**
-		 * @private
-		 */
-		public function get host():IUIBase
-		{
-			return _strand;
-		}
-		
-		/**
-		 * @private
-		 */
-		public function get viewWidth():Number
-		{
-			return _strand.width;
-		}
-		
-		/**
-		 * @private
-		 */
-		public function get viewHeight():Number
-		{
-			return _strand.height;
+			sizeViewsToFitContentArea();
+			
+			// notify the views that the content size has changed
+			IEventDispatcher(strand).dispatchEvent( new Event("contentSizeChanged") );
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/ViewManagerView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/ViewManagerView.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/ViewManagerView.as
new file mode 100644
index 0000000..9e56ca3
--- /dev/null
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/beads/ViewManagerView.as
@@ -0,0 +1,167 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.mobile.beads
+{
+	import org.apache.flex.core.IBeadModel;
+	import org.apache.flex.core.IBeadView;
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.IUIBase;
+	import org.apache.flex.core.IViewportModel;
+	import org.apache.flex.core.UIBase;
+	import org.apache.flex.core.UIMetrics;
+	import org.apache.flex.events.IEventDispatcher;
+	import org.apache.flex.events.Event;
+	import org.apache.flex.html.Container;
+	import org.apache.flex.html.beads.layouts.HorizontalLayout;
+	import org.apache.flex.mobile.IView;
+	import org.apache.flex.mobile.chrome.NavigationBar;
+	import org.apache.flex.mobile.models.ViewManagerModel;
+	import org.apache.flex.utils.BeadMetrics;
+	
+	/**
+	 * The ViewManagerView creates the visual elements of the StackedViewManager. This
+	 * includes a NavigationBar, ToolBar, and contentArea.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.0
+	 */
+	public class ViewManagerView implements IBeadView
+	{
+		/**
+		 * Constructor.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.0
+		 */
+		public function ViewManagerView()
+		{
+			super();
+		}
+		
+		public function get host():IUIBase
+		{
+			return _strand as IUIBase;
+		}
+		public function set host(value:IUIBase):void
+		{
+			// not implemented; getter only.
+		}
+		
+		private var _navigationBar:NavigationBar;
+		public function get navigationBar():NavigationBar
+		{
+			return _navigationBar;
+		}
+		public function set navigationBar(value:NavigationBar):void
+		{
+			// not implemented; getter only.
+		}
+		
+		private var _strand:IStrand;
+		public function get strand():IStrand
+		{
+			return _strand;
+		}
+		public function set strand(value:IStrand):void
+		{
+			_strand = value;
+			UIBase(_strand).addEventListener("sizeChanged", sizeChangedHandler);
+			UIBase(_strand).addEventListener("widthChanged", sizeChangedHandler);
+			UIBase(_strand).addEventListener("heightChanged", sizeChangedHandler);
+			
+			var model:ViewManagerModel = value.getBeadByType(IBeadModel) as ViewManagerModel;
+			model.addEventListener("selectedIndexChanged", viewsChangedHandler);
+
+			if (model.navigationBarItems)
+			{
+				_navigationBar = new NavigationBar();
+				_navigationBar.controls = model.navigationBarItems;
+				_navigationBar.addBead(new HorizontalLayout());
+				UIBase(_strand).addElement(_navigationBar, false);
+			}
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function viewsChangedHandler(event:Event):void
+		{
+			layoutChromeElements();
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function sizeChangedHandler(event:Event):void
+		{
+			layoutChromeElements();
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function layoutChromeElements():void
+		{
+			var host:UIBase = _strand as UIBase;
+			var contentAreaY:Number = 0;
+			var contentAreaHeight:Number = host.height;
+			
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			
+			if (_navigationBar)
+			{
+				_navigationBar.x = 0;
+				_navigationBar.y = 0;
+				_navigationBar.width = host.width;
+				
+				contentAreaHeight -= _navigationBar.height;
+				contentAreaY = _navigationBar.height;
+				
+				model.navigationBar = _navigationBar;
+			}
+			
+			model.contentX = 0;
+			model.contentY = contentAreaY;
+			model.contentWidth = host.width;
+			model.contentHeight = contentAreaHeight;
+			
+			sizeViewsToFitContentArea();
+		}
+		
+		protected function sizeViewsToFitContentArea():void
+		{
+			var model:ViewManagerModel = _strand.getBeadByType(IBeadModel) as ViewManagerModel;
+			
+			var n:int = ViewManagerModel(model).views.length;
+			if (n > 0) {
+				for (var i:int = 0; i < n; i++)
+				{
+					var view:IView = ViewManagerModel(model).views[i] as IView;
+					UIBase(view).x = model.contentX;
+					UIBase(view).y = model.contentY;
+					UIBase(view).setWidthAndHeight(model.contentWidth, model.contentHeight, true);
+				}
+			}
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/models/ViewManagerModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/models/ViewManagerModel.as
b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/models/ViewManagerModel.as
index faa3936..c57cc61 100644
--- a/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/models/ViewManagerModel.as
+++ b/frameworks/projects/Mobile/asjs/src/org/apache/flex/mobile/models/ViewManagerModel.as
@@ -20,6 +20,7 @@ package org.apache.flex.mobile.models
 {
 	import org.apache.flex.core.IBeadModel;
 	import org.apache.flex.core.IStrand;
+	import org.apache.flex.core.UIBase;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.EventDispatcher;
 	import org.apache.flex.mobile.chrome.NavigationBar;
@@ -60,6 +61,11 @@ package org.apache.flex.mobile.models
 			_strand = value;
 		}
 		
+		public var contentX:Number = 0;
+		public var contentY:Number = 0;
+		public var contentWidth:Number = 0;
+		public var contentHeight:Number = 0;
+		
 		private var _views:Array;
 		
 		/**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f03e77f5/frameworks/projects/Mobile/js/src/org/apache/flex/mobile/ManagerBase.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Mobile/js/src/org/apache/flex/mobile/ManagerBase.js b/frameworks/projects/Mobile/js/src/org/apache/flex/mobile/ManagerBase.js
index 343ba4e..1cc77d5 100644
--- a/frameworks/projects/Mobile/js/src/org/apache/flex/mobile/ManagerBase.js
+++ b/frameworks/projects/Mobile/js/src/org/apache/flex/mobile/ManagerBase.js
@@ -123,10 +123,13 @@ org.apache.flex.mobile.ManagerBase.prototype.createElement =
   this.element.className = 'ManagerBase';
 
   this.positioner = this.element;
+  this.positioner.style.position = 'relative';
   this.element.flexjs_wrapper = this;
 
   this._contentArea = new org.apache.flex.core.UIBase();
   this._contentArea.className = 'ContentArea';
+  this._contentArea.positioner.style['width'] = '100%';
+  this._contentArea.positioner.style['height'] = '100%';
   org.apache.flex.core.UIBase.prototype.addElement.call(this, this._contentArea);
 
   return this.element;


Mime
View raw message