This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 6d1c020 Reconcile Basic ContainerView for SWF and JS (emphasis on not
changing JS side), and fix some issues on SWF side.
new 9d3d030 Merge pull request #1041 from
estanglerbm/reconcile-basic-containerview
6d1c020 is described below
commit 6d1c020577cec69b6207a5b46356b6a2b74f308c
Author: Edward Stangler <[email protected]>
AuthorDate: Wed Jan 6 01:18:49 2021 -0600
Reconcile Basic ContainerView for SWF and JS (emphasis on not changing JS
side), and fix some issues on SWF side.
---
.../org/apache/royale/html/beads/ContainerView.as | 307 ++++++---------------
1 file changed, 83 insertions(+), 224 deletions(-)
diff --git
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ContainerView.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ContainerView.as
index 057b787..12af0d8 100644
---
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ContainerView.as
+++
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ContainerView.as
@@ -21,7 +21,7 @@ package org.apache.royale.html.beads
import org.apache.royale.html.beads.GroupView;
import org.apache.royale.core.ContainerBase;
import org.apache.royale.core.IBead;
- import org.apache.royale.core.IBorderPaddingMarginValuesImpl;
+ import org.apache.royale.core.IBorderPaddingMarginValuesImpl;
import org.apache.royale.core.IContainer;
import org.apache.royale.core.ILayoutChild;
import org.apache.royale.core.ILayoutView;
@@ -50,58 +50,64 @@ package org.apache.royale.html.beads
* placement of the elements in the contentView. When a Container does
not have an
* explicit size (including a percent size), the content dictates the
size of the
* Container.
- *
+ *
* @viewbead
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.8
*/
- COMPILE::SWF
public class ContainerView extends GroupView
{
+ private var _viewport:IViewport;
+
/**
- * The ContainerView class is the default view for
- * the org.apache.royale.core.ContainerBase classes.
- * It lets you use some CSS styles to manage the border, background
- * and padding around the content area.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- */
+ * The ContainerView class is the default view for
+ * the org.apache.royale.core.ContainerBase classes.
+ * It lets you use some CSS styles to manage the border,
background
+ * and padding around the content area.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.8
+ */
public function ContainerView()
{
super();
}
/**
- * The sub-element used as the parent of the container's
elements. This does not
- * include the chrome elements.
+ * The viewport used to present the content and may display
+ * scroll bars (depending on the actual type of viewport).
*
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.8
*/
- override public function get contentView():ILayoutView
+ protected function get viewport():IViewport
{
- return viewport.contentView as ILayoutView;
+ return _viewport;
}
/**
- * The viewport used to present the content and may display
- * scroll bars (depending on the actual type of viewport).
+ * The sub-element used as the parent of the container's
elements. This does not
+ * include the chrome elements.
*
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.8
+ * @royaleignorecoercion org.apache.royale.core.ILayoutView
*/
- protected function get viewport():IViewport
+ override public function get contentView():ILayoutView
{
- return _viewport;
+ if (viewport != null) {
+ return viewport.contentView as ILayoutView;
+ } else {
+ return host as ILayoutView;
+ }
}
/**
@@ -113,14 +119,14 @@ package org.apache.royale.html.beads
* @playerversion AIR 2.6
* @productversion Royale 0.8
*/
+ COMPILE::SWF
public function get viewportModel():IViewportModel
{
return _viewportModel;
}
+ COMPILE::SWF
private var _viewportModel:IViewportModel;
- private var _viewport:IViewport;
- private var layoutRunning:Boolean;
/**
* Strand setter.
@@ -129,119 +135,85 @@ package org.apache.royale.html.beads
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.8
+ * @royaleignorecoercion org.apache.royale.core.IViewport
*/
override public function set strand(value:IStrand):void
{
_strand = value;
-
- createViewport();
-
- addViewport();
-
super.strand = value;
- }
-
- protected function addViewport():void
- {
- var chost:IContainer = host as IContainer;
- chost.strandChildren.addElement(viewport.contentView);
- }
-
- /**
- * Called when the host is ready to complete its setup (usually
after its size has been
- * determined).
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- */
- override protected function completeSetup():void
- {
- super.completeSetup();
- // when the first layout is complete, set up listeners
for changes
- // to the childrens' sizes.
-// host.addEventListener("layoutComplete",
childrenChangedHandler);
- }
-
- /**
- * Creates the Viewport (or ScrollableViewport) through which
the content
- * area is presented.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- */
- protected function createViewport():void
- {
+ COMPILE::SWF
+ {
if(!_viewportModel)
_viewportModel =
loadBeadFromValuesManager(IViewportModel, "iViewportModel", _strand) as
IViewportModel;
-
+ }
+
if(!_viewport)
_viewport =
loadBeadFromValuesManager(IViewport, "iViewport", _strand) as IViewport;
+ if (_viewport) {
+ addViewport();
+ }
}
/**
- * Calculate the space taken up by non-content children like a
TitleBar in a Panel.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- * @royaleignorecoercion
org.apache.royale.core.IBorderPaddingMarginValuesImpl
+ * @royaleignorecoercion org.apache.royale.core.IContainer
*/
- protected function getChromeMetrics():EdgeData
+ protected function addViewport():void
{
- var paddingMetrics:EdgeData = (ValuesManager.valuesImpl
as IBorderPaddingMarginValuesImpl).getPaddingMetrics(host);
- return paddingMetrics;
+ var chost:IContainer = host as IContainer;
+ // add the viewport's contentView to this host ONLY if
+ // the contentView is not the host itself, which is
likely
+ // most situations.
+ if (chost != null && chost != _viewport.contentView) {
+ chost.addElement(_viewport.contentView);
+ }
}
-
+
/**
* Positions the viewport, then sets any known sizes of the
Viewport prior
- * to laying out its content.
+ * to laying out its content.
*
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.8
- * @royaleignorecoercion
org.apache.royale.core.IBorderPaddingMarginValuesImpl
+ * @royaleignorecoercion
org.apache.royale.core.IBorderPaddingMarginValuesImpl
*/
+ COMPILE::SWF
override public function beforeLayout():Boolean
{
- var host:ILayoutChild = this.host as ILayoutChild;
- var vm:IViewportModel = viewportModel;
- COMPILE::SWF
- {
- // if earlier layouts set the size of the host
- // then it won't reflect changes in content size
- if (host is UIBase)
- {
- var uiBase:UIBase = host as UIBase;
- if (host.isWidthSizedToContent())
- {
- if (uiBase.width != uiBase.$width)
- {
- host.setWidth(uiBase.$width, true);
- }
- }
- if (host.isHeightSizedToContent())
- {
- if (uiBase.height != uiBase.$height)
- {
- host.setHeight(uiBase.$height, true);
- }
- }
- }
- }
+ var host:ILayoutChild = this.host as ILayoutChild;
+ var vm:IViewportModel = viewportModel;
+// COMPILE::SWF
+// {
+ // if earlier layouts set the size of the host
+ // then it won't reflect changes in content size
+ if (host is UIBase)
+ {
+ var uiBase:UIBase = host as UIBase;
+ if (host.isWidthSizedToContent())
+ {
+ if (uiBase.width != uiBase.$width)
+ {
+ host.setWidth(uiBase.$width,
true);
+ }
+ }
+ if (host.isHeightSizedToContent())
+ {
+ if (uiBase.height != uiBase.$height)
+ {
+ host.setHeight(uiBase.$height,
true);
+ }
+ }
+ }
+// }
var hostWidth:Number = host.width;
var hostHeight:Number = host.height;
- vm.borderMetrics = (ValuesManager.valuesImpl as
IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
+ vm.borderMetrics = (ValuesManager.valuesImpl as
IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
- viewport.setPosition(vm.borderMetrics.left, vm.borderMetrics.top);
+ viewport.setPosition(vm.borderMetrics.left,
vm.borderMetrics.top);
viewport.layoutViewportBeforeContentLayout(
hostWidth - vm.borderMetrics.left -
vm.borderMetrics.right,
@@ -253,6 +225,7 @@ package org.apache.royale.html.beads
/**
* @private
*/
+ COMPILE::SWF
private var adjusting:Boolean = false;
/**
@@ -264,6 +237,7 @@ package org.apache.royale.html.beads
* @playerversion AIR 2.6
* @productversion Royale 0.8
*/
+ COMPILE::SWF
override public function afterLayout():void
{
if (adjusting) return;
@@ -277,120 +251,5 @@ package org.apache.royale.html.beads
adjusting = false;
}
-
- /**
- * Handles dynamic changes to the host's size by running the
layout once
- * the viewport has been adjusted.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- */
-// override protected function resizeHandler(event:Event):void
-// {
-// if (!adjusting) {
-// performLayout(event);
-// }
-// }
-
- /**
- * Whenever children are added, listeners are added to detect
changes
- * in their size.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- */
-// protected function childrenChangedHandler(event:Event):void
-// {
-// var host:UIBase = _strand as UIBase;
-// host.removeEventListener(event.type,
childrenChangedHandler);
-//
-// var n:Number = contentView.numElements;
-// for (var i:int=0; i < n; i++) {
-// var child:IUIBase = contentView.getElementAt(i)
as IUIBase;
-// child.addEventListener("widthChanged",
childResizeHandler);
-// child.addEventListener("heightChanged",
childResizeHandler);
-// child.addEventListener("sizeChanged",
childResizeHandler);
-// }
-// }
- }
-
- COMPILE::JS
- public class ContainerView extends GroupView //??implements IParent
- {
- private var _viewport:IViewport;
-
- /**
- * The viewport used to present the content and may display
- * scroll bars (depending on the actual type of viewport).
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- */
- protected function get viewport():IViewport
- {
- return _viewport;
- }
-
- /**
- * The sub-element used as the parent of the container's
elements. This does not
- * include the chrome elements.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- * @royaleignorecoercion org.apache.royale.core.ILayoutView
- */
- override public function get contentView():ILayoutView
- {
- if (viewport != null) {
- return viewport.contentView as ILayoutView;
- } else {
- return host as ILayoutView;
- }
- }
-
- /**
- * Strand setter.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.8
- * @royaleignorecoercion org.apache.royale.core.IViewport
- * @royaleignorecoercion org.apache.royale.core.IContainer
- */
- override public function set strand(value:IStrand):void
- {
- _strand = value;
- super.strand = value;
-
- if(!_viewport)
- _viewport =
loadBeadFromValuesManager(IViewport, "iViewport", _strand) as IViewport;
-
- if (_viewport) {
- addViewport();
- }
- }
-
- /**
- * @royaleignorecoercion org.apache.royale.core.IContainer
- */
- protected function addViewport():void
- {
- var chost:IContainer = host as IContainer;
- // add the viewport's contentView to this host ONLY if
- // the contentView is not the host itself, which is
likely
- // most situations.
- if (chost != null && chost != _viewport.contentView) {
- chost.addElement(_viewport.contentView);
- }
- }
}
}