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/12/07 05:32:01 UTC

[royale-asjs] 02/05: need a custom GroupView to handle size to content

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 c046115826a1fb34b23bbae7114e74b15d7ee41a
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Dec 6 21:30:24 2018 -0800

    need a custom GroupView to handle size to content
---
 .../SparkRoyale/src/main/resources/defaults.css    |   2 +-
 .../src/main/royale/SparkRoyaleClasses.as          |   1 +
 .../royale/spark/components/beads/GroupView.as     | 104 +++++++++++++++++++++
 3 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
index 9e93095..04db8a9 100644
--- a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
@@ -55,7 +55,7 @@ ComboBox
 GroupBase
 {
 	IBeadLayout: ClassReference("spark.layouts.supportClasses.SparkLayoutBead");
-	IBeadView: ClassReference("org.apache.royale.html.beads.GroupView");
+	IBeadView: ClassReference("spark.components.beads.GroupView");
 }
 
 Image
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as b/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
index d9f4357..2c8e1cf 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.GroupView; GroupView;
     import spark.components.beads.SkinnableContainerView; SkinnableContainerView;
     import spark.components.beads.DropDownListView; DropDownListView;
     import spark.components.beads.controllers.DropDownListController; DropDownListController;
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/GroupView.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/GroupView.as
new file mode 100644
index 0000000..8e7e6b1
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/GroupView.as
@@ -0,0 +1,104 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.supportClasses.GroupBase;
+import spark.layouts.supportClasses.LayoutBase;
+
+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.events.Event;
+import org.apache.royale.events.IEventDispatcher;
+import org.apache.royale.html.beads.GroupView;
+
+/**
+ *  @private
+ *  The PanelView for emulation.
+ */
+public class GroupView extends org.apache.royale.html.beads.GroupView
+{
+	//--------------------------------------------------------------------------
+	//
+	//  Constructor
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  Constructor.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function GroupView()
+	{
+		super();
+	}
+
+    /**
+     *  Adjusts the size of the host after the layout has been run if needed
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     *  @royaleignorecoercion org.apache.royale.core.UIBase
+     */
+    override public function beforeLayout():void
+    {
+        var host:GroupBase = _strand as GroupBase;
+        if (host.isWidthSizedToContent() || host.isHeightSizedToContent())
+        {
+            host.layout.measure();
+        }
+    }
+    
+    /**
+     *  Adjusts the size of the host after the layout has been run if needed
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     *  @royaleignorecoercion org.apache.royale.core.UIBase
+     */
+    override public function afterLayout():void
+    {
+        var host:UIBase = _strand as UIBase;
+        if (host.isWidthSizedToContent() || host.isHeightSizedToContent())
+        {
+            // request re-run layout on the parent.  In theory, we should only
+            // end up in afterLayout if the content size changed.
+            if (host.parent)
+            {
+                (host.parent as IEventDispatcher).dispatchEvent(new Event("layoutNeeded"));   
+            }
+        }
+    }
+
+
+}
+
+}
+