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 2018/11/29 00:25:09 UTC
[royale-asjs] 02/02: get SkinnableContainer to contain a GroupBase
so Spark Layout can run on it
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
commit 1f3a2dd31265ceda908811c09fc98eda0afe2cd1
Author: Alex Harui <ah...@apache.org>
AuthorDate: Wed Nov 28 16:24:52 2018 -0800
get SkinnableContainer to contain a GroupBase so Spark Layout can run on it
---
.../SparkRoyale/src/main/resources/defaults.css | 5 +-
.../src/main/royale/SparkRoyaleClasses.as | 1 +
.../royale/spark/components/SkinnableContainer.as | 53 +++------------
.../components/beads/SkinnableContainerView.as | 75 ++++++++++++++++++++++
.../layouts/supportClasses/SparkLayoutBead.as | 6 +-
5 files changed, 92 insertions(+), 48 deletions(-)
diff --git a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
index 38550ed..2e2c802 100644
--- a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
@@ -104,10 +104,11 @@ Panel .TitleBar
SkinnableContainer
{
- IBeadView: ClassReference("org.apache.royale.html.beads.ContainerView");
- IBeadLayout: ClassReference("org.apache.royale.html.beads.layouts.BasicLayout");
+ IBeadView: ClassReference("spark.components.beads.SkinnableContainerView");
+ IBeadLayout: ClassReference("spark.layouts.supportClasses.SparkLayoutBead");
IViewport: ClassReference("org.apache.royale.html.supportClasses.ScrollingViewport");
IViewportModel: ClassReference("org.apache.royale.html.beads.models.ViewportModel");
+ IContentView: ClassReference("spark.components.Group");
}
TextArea
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as b/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
index c6a21fa..4dc8cee 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
@@ -75,6 +75,7 @@ internal class SparkRoyaleClasses
import spark.components.SkinnablePopUpContainer; SkinnablePopUpContainer;
import spark.components.beads.PanelView; PanelView;
+ import spark.components.beads.SkinnableContainerView; SkinnableContainerView;
}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/SkinnableContainer.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/SkinnableContainer.as
index 421d8f7..5f8ecb4 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/SkinnableContainer.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/SkinnableContainer.as
@@ -401,6 +401,7 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
public function SkinnableContainer()
{
super();
+ typeNames = "SkinnableContainer";
}
/**
@@ -1017,9 +1018,8 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
super.addedToParent();
- // disabled for now to see if we can use spark LayoutBase instead
// Load the layout bead if it hasn't already been loaded.
- //loadBeadFromValuesManager(IBeadLayout, "iBeadLayout", this);
+ loadBeadFromValuesManager(IBeadLayout, "iBeadLayout", this);
dispatchEvent(new Event("initComplete"));
if ((isHeightSizedToContent() || !isNaN(explicitHeight)) &&
@@ -1295,42 +1295,7 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
// element/child handlers
//
//--------------------------------------------------------------------------
-
-
- /**
- * @private
- */
- COMPILE::JS
- override public function addElement(c:IChild, dispatchEvent:Boolean = true):void
- {
- super.addElement(c, dispatchEvent);
- if (dispatchEvent)
- this.dispatchEvent(new ValueEvent("childrenAdded", c));
- }
-
- /**
- * @private
- */
- COMPILE::JS
- override public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void
- {
- super.addElementAt(c, index, dispatchEvent);
- if (dispatchEvent)
- this.dispatchEvent(new ValueEvent("childrenAdded", c));
- }
-
- /**
- * @private
- */
- COMPILE::JS
- override public function removeElement(c:IChild, dispatchEvent:Boolean = true):void
- {
- super.removeElement(c, dispatchEvent);
- //TODO This should possibly be ultimately refactored to be more PAYG
- if (dispatchEvent)
- this.dispatchEvent(new ValueEvent("childrenRemoved", c));
- }
-
+
/*
* The following functions are for the SWF-side only and re-direct element functions
* to the content area, enabling scrolling and clipping which are provided automatically
@@ -1340,10 +1305,14 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
/**
* @private
*/
- COMPILE::SWF
override public function addElement(c:IChild, dispatchEvent:Boolean = true):void
{
var contentView:IParent = getLayoutHost().contentView as IParent;
+ if (c == contentView)
+ {
+ super.addElement(c); // ContainerView uses addElement to add inner contentView
+ return;
+ }
contentView.addElement(c, dispatchEvent);
if (dispatchEvent)
this.dispatchEvent(new ValueEvent("childrenAdded", c));
@@ -1352,7 +1321,6 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
/**
* @private
*/
- COMPILE::SWF
override public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void
{
var contentView:IParent = getLayoutHost().contentView as IParent;
@@ -1364,7 +1332,6 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
/**
* @private
*/
- COMPILE::SWF
override public function getElementIndex(c:IChild):int
{
var layoutHost:ILayoutHost = view as ILayoutHost;
@@ -1375,7 +1342,6 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
/**
* @private
*/
- COMPILE::SWF
override public function removeElement(c:IChild, dispatchEvent:Boolean = true):void
{
var layoutHost:ILayoutHost = view as ILayoutHost;
@@ -1389,10 +1355,10 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
/**
* @private
*/
- COMPILE::SWF
override public function get numElements():int
{
var layoutHost:ILayoutHost = view as ILayoutHost;
+ if (!layoutHost) return 0; // view is null when called in addingChild from MXMLDataInterpreter before children are added
var contentView:IParent = layoutHost.contentView as IParent;
return contentView.numElements;
}
@@ -1400,7 +1366,6 @@ public class SkinnableContainer extends SkinnableComponent implements IContainer
/**
* @private
*/
- COMPILE::SWF
override public function getElementAt(index:int):IChild
{
var layoutHost:ILayoutHost = view as ILayoutHost;
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SkinnableContainerView.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SkinnableContainerView.as
new file mode 100644
index 0000000..f02ae43
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SkinnableContainerView.as
@@ -0,0 +1,75 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.components.beads
+{
+
+import spark.components.SkinnableContainer;
+import spark.components.supportClasses.GroupBase;
+
+import org.apache.royale.core.IBead;
+import org.apache.royale.core.ILayoutChild;
+import org.apache.royale.core.IStrand;
+import org.apache.royale.core.UIBase;
+import org.apache.royale.html.beads.ContainerView;
+
+/**
+ * @private
+ * The SkinnableContainerView for emulation.
+ */
+public class SkinnableContainerView extends ContainerView
+{
+ //--------------------------------------------------------------------------
+ //
+ // Constructor
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public function SkinnableContainerView()
+ {
+ super();
+ }
+
+ /**
+ */
+ override public function set strand(value:IStrand):void
+ {
+ super.strand = value;
+ var host:SkinnableContainer = _strand as SkinnableContainer;
+ var g:GroupBase = (contentView as GroupBase);
+ g.layout = host.layout;
+
+ if (!host.isWidthSizedToContent())
+ g.percentWidth = 100;
+ if (!host.isHeightSizedToContent())
+ g.percentHeight = 100;
+
+ }
+
+}
+
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as
index af956ec..b74d2ae 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/supportClasses/SparkLayoutBead.as
@@ -28,8 +28,9 @@ import mx.core.mx_internal;
import spark.components.supportClasses.GroupBase;
import spark.core.NavigationUnit;
-import org.apache.royale.core.IStrand;
import org.apache.royale.core.IBeadLayout;
+import org.apache.royale.core.ILayoutHost;
+import org.apache.royale.core.IStrand;
import org.apache.royale.core.LayoutBase;
import org.apache.royale.core.UIBase;
import org.apache.royale.events.Event;
@@ -101,7 +102,8 @@ public class SparkLayoutBead extends org.apache.royale.core.LayoutBase
override public function set strand(value:IStrand):void
{
_strand = value;
- _target = value as GroupBase;
+ var host:UIBase = value as UIBase;
+ _target = (host.view as ILayoutHost).contentView as GroupBase;
super.strand = value;
}