You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2019/11/22 06:42:50 UTC
[royale-asjs] branch develop updated: try tickling layout in
Container/Module
This is an automated email from the ASF dual-hosted git repository.
aharui 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 23a281c try tickling layout in Container/Module
23a281c is described below
commit 23a281c1d7fe6a3ab157b224de4186a55a803f2a
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Nov 21 22:42:40 2019 -0800
try tickling layout in Container/Module
---
.../MXRoyale/src/main/resources/defaults.css | 2 +-
.../MXRoyale/src/main/royale/MXRoyaleClasses.as | 1 +
.../mx/containers/beads/layouts/BasicLayout.as | 223 +++++++++++++++++++++
3 files changed, 225 insertions(+), 1 deletion(-)
diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index 1324dc6..39c0d25 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -147,7 +147,7 @@ ComboBox
Container
{
IBeadView: ClassReference("org.apache.royale.html.beads.ContainerView");
- IBeadLayout: ClassReference("org.apache.royale.html.beads.layouts.BasicLayout");
+ IBeadLayout: ClassReference("mx.containers.beads.layouts.BasicLayout");
IViewport: ClassReference("org.apache.royale.html.supportClasses.ScrollingViewport");
IViewportModel: ClassReference("org.apache.royale.html.beads.models.ViewportModel");
align-items: flex-start;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index ed38f8a..bc9bd47 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -53,6 +53,7 @@ internal class MXRoyaleClasses
import mx.containers.beads.ApplicationLayout; ApplicationLayout;
import mx.containers.beads.BoxLayout; BoxLayout;
import mx.containers.beads.CanvasLayout; CanvasLayout;
+ import mx.containers.beads.layouts.BasicLayout; BasicLayout;
import mx.controls.beads.AlertView; AlertView;
import mx.containers.gridClasses.GridColumnInfo; GridColumnInfo;
import mx.containers.gridClasses.GridRowInfo; GridRowInfo;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/layouts/BasicLayout.as b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/layouts/BasicLayout.as
new file mode 100644
index 0000000..b2e22d1
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/containers/beads/layouts/BasicLayout.as
@@ -0,0 +1,223 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.containers.beads.layouts
+{
+ import mx.containers.Canvas;
+ import mx.core.Container;
+ import mx.core.EdgeMetrics;
+ import mx.core.IUIComponent;
+
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.LayoutBase;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.geom.Rectangle;
+
+/*
+import mx.core.mx_internal;
+import mx.events.ChildExistenceChangedEvent;
+import mx.events.MoveEvent;
+import mx.resources.IResourceManager;
+import mx.resources.ResourceManager;
+import flash.utils.Dictionary;
+
+use namespace mx_internal;
+*/
+
+/**
+ * @private
+ * The CanvasLayout class is for internal use only.
+ */
+public class BasicLayout extends LayoutBase
+{
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function BasicLayout()
+ {
+ super();
+ }
+
+ //--------------------------------------------------------------------------
+ //
+ // Properties
+ //
+ //--------------------------------------------------------------------------
+
+ private var _strand:IStrand;
+
+ override public function set strand(value:IStrand):void
+ {
+ _strand = value;
+ _target = value as Container;
+ super.strand = value;
+
+ }
+
+ private var _target:Container;
+
+ public function get target():Container
+ {
+ return _target;
+ }
+
+ public function set target(value:Container):void
+ {
+ _target = value;
+ }
+
+
+ //--------------------------------------------------------------------------
+ //
+ // Overridden methods
+ //
+ //--------------------------------------------------------------------------
+
+ override public function layout():Boolean
+ {
+ COMPILE::SWF
+ {
+ var hostWidthSizedToContent:Boolean = host.isWidthSizedToContent();
+ var hostHeightSizedToContent:Boolean = host.isHeightSizedToContent();
+
+ var w:Number = hostWidthSizedToContent ? 0 : target.width;
+ var h:Number = hostHeightSizedToContent ? 0 : target.height;
+
+ var n:int = target.numChildren;
+
+ for (var i:int = 0; i < n; i++)
+ {
+ var child:IUIComponent = target.getLayoutChildAt(i);
+ if (!child.includeInLayout) continue;
+
+ var positions:Object = childPositions(child);
+ var margins:Object = childMargins(child, target.width, target.height);
+ var ww:Number = w;
+ var hh:Number = h;
+
+ var xpos:Number;
+ var ypos:Number;
+ var useWidth:Number;
+ var useHeight:Number;
+
+ // set the top edge of the child
+ if (!isNaN(positions.left))
+ {
+ xpos = positions.left+margins.left;
+ ww -= positions.left + margins.left;
+ }
+
+ // set the left edge of the child
+ if (!isNaN(positions.top))
+ {
+ ypos = positions.top+margins.top;
+ hh -= positions.top + margins.top;
+ }
+
+ // set the right edge of the child
+ if (!isNaN(positions.right))
+ {
+ if (!hostWidthSizedToContent)
+ {
+ if (!isNaN(positions.left))
+ {
+ useWidth = ww - positions.right - margins.right;
+ }
+ else
+ {
+ xpos = w - positions.right - margins.left - child.width - margins.right
+ }
+ }
+ }
+ else if (child != null && !isNaN(child.percentWidth) && !hostWidthSizedToContent)
+ {
+ useWidth = (ww - margins.right - margins.left) * child.percentWidth/100;
+ }
+
+ // set the bottm edge of the child
+ if (!isNaN(positions.bottom))
+ {
+ if (!hostHeightSizedToContent)
+ {
+ if (!isNaN(positions.top))
+ {
+ useHeight = hh - positions.bottom - margins.bottom;
+ }
+ else
+ {
+ ypos = h - positions.bottom - child.height - margins.bottom;
+ }
+ }
+ }
+ else if (child != null && !isNaN(child.percentHeight) && !hostHeightSizedToContent)
+ {
+ useHeight = (hh - margins.top - margins.bottom) * child.percentHeight/100;
+ }
+
+ if (margins.auto)
+ {
+ xpos = (w - child.width) / 2;
+ }
+
+ child.move(xpos, ypos);
+ child.setActualSize(useWidth, useHeight);
+ }
+
+ return true;
+
+ }
+
+ COMPILE::JS
+ {
+ var i:int
+ var n:int;
+
+ n = target.numChildren;
+
+ // host must have either have position:absolute or position:relative
+ if (target.element.style.position != "absolute" && target.element.style.position != "relative") {
+ target.element.style.position = "relative";
+ }
+
+ // each child must have position:absolute for BasicLayout to work
+ for (i=0; i < n; i++) {
+ var child:IUIComponent = target.getLayoutChildAt(i);
+ child.positioner.style.position = "absolute";
+ child.dispatchEvent(new Event("layoutNeeded"));
+ }
+
+ return true;
+ }
+ }
+}
+}
+