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/12/23 06:52:41 UTC
[royale-asjs] 03/09: something showed up
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 7d88501ef80f09915114bb7604d2671830b1955a
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Dec 17 21:07:19 2019 -0800
something showed up
---
.../src/main/royale/mx/core/UIComponent.as | 35 +++++++
.../src/main/royale/spark/components/FormItem.as | 5 +
.../royale/spark/components/SkinnableContainer.as | 19 +++-
.../royale/spark/components/beads/GroupView.as | 3 +
.../components/beads/SkinnableContainerView.as | 31 ++++++
.../spark/components/beads/SparkContainerView.as | 50 +++++++++-
.../supportClasses/SkinnableComponent.as | 109 ++++++++++++++++++---
.../main/royale/spark/layouts/ConstraintLayout.as | 4 +-
8 files changed, 236 insertions(+), 20 deletions(-)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index 12d7914..d5242bc 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -4350,6 +4350,41 @@ COMPILE::JS
invalidateDisplayListFlag = false;
}
+ override public function isWidthSizedToContent():Boolean
+ {
+ if (!isNaN(_explicitWidth))
+ return false;
+ if (!isNaN(percentWidth))
+ return false;
+ var left:* = ValuesManager.valuesImpl.getValue(this, "left");
+ var right:* = ValuesManager.valuesImpl.getValue(this, "right");
+ if (typeof(left) === "string" && String(left).indexOf(":") != -1)
+ left = undefined;
+ if (typeof(right) === "string" && String(right).indexOf(":") != -1)
+ right = undefined;
+ if (left === undefined || right === undefined) return true;
+ if (parent is UIComponent)
+ return (parent as UIComponent).isWidthSizedToContent();
+ return false;
+ }
+
+ override public function isHeightSizedToContent():Boolean
+ {
+ if (!isNaN(_explicitHeight))
+ return false;
+ if (!isNaN(percentHeight))
+ return false;
+ var top:* = ValuesManager.valuesImpl.getValue(this, "top");
+ var bottom:* = ValuesManager.valuesImpl.getValue(this, "bottom");
+ if (typeof(top) === "string" && String(top).indexOf(":") != -1)
+ top = undefined;
+ if (typeof(bottom) === "string" && String(bottom).indexOf(":") != -1)
+ bottom = undefined;
+ if (top === undefined || bottom === undefined) return true;
+ if (parent is UIComponent)
+ return (parent as UIComponent).isHeightSizedToContent();
+ return false;
+ }
[Inspectable(category="General")]
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/FormItem.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/FormItem.as
index f29c132..d8681e3 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/FormItem.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/FormItem.as
@@ -423,6 +423,11 @@ package spark.components
}
}
+ override protected function get skinParts():Object
+ {
+ return { labelDisplay: true, sequenceLabelDisplay: true};
+ }
+
/**
* @private
*/
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 f612a3a..4491791 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/SkinnableContainer.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/SkinnableContainer.as
@@ -55,6 +55,7 @@ import org.apache.royale.core.IParent;
import org.apache.royale.core.ValuesManager;
import org.apache.royale.events.ValueEvent;
import org.apache.royale.events.Event;
+import org.apache.royale.events.IEventDispatcher;
import org.apache.royale.utils.MXMLDataInterpreter;
import org.apache.royale.utils.loadBeadFromValuesManager;
@@ -658,8 +659,8 @@ public class SkinnableContainer extends SkinnableContainerBase implements IConta
? contentGroup.layout
: contentGroupProperties.layout;
*/
- if (!_layout)
- _layout = new BasicLayout();
+ //if (!_layout)
+ // _layout = new BasicLayout();
return _layout;
}
@@ -902,6 +903,11 @@ public class SkinnableContainer extends SkinnableContainerBase implements IConta
*/
public function childrenAdded():void
{
+ if (skin)
+ {
+ var skinDispatcher:IEventDispatcher = (view as SkinnableContainerView).contentView as IEventDispatcher;
+ skinDispatcher.dispatchEvent(new ValueEvent("childrenAdded"));
+ }
dispatchEvent(new ValueEvent("childrenAdded"));
}
@@ -998,10 +1004,11 @@ public class SkinnableContainer extends SkinnableContainerBase implements IConta
* @playerversion AIR 1.5
* @productversion Royale 0.9.4
*/
- protected function partAdded(partName:String, instance:Object):void
- { //override
- /* super.partAdded(partName, instance);
+ override protected function partAdded(partName:String, instance:Object):void
+ {
+ super.partAdded(partName, instance);
+ /*
if (instance == contentGroup)
{
if (_contentModified)
@@ -1264,6 +1271,8 @@ public class SkinnableContainer extends SkinnableContainerBase implements IConta
if (c == contentView)
{
super.addElement(c); // ContainerView uses addElement to add inner contentView
+ if (c == skin)
+ findSkinParts();
return;
}
contentView.addElement(c, dispatchEvent);
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
index 8e7e6b1..89f221e 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/GroupView.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/GroupView.as
@@ -68,6 +68,9 @@ public class GroupView extends org.apache.royale.html.beads.GroupView
override public function beforeLayout():void
{
var host:GroupBase = _strand as GroupBase;
+ // some Groups have left/right but are still sized to content.
+ // the left/right create padding instead. So isntead of
+ // isWidthSizedToContent, we only check explicit and percent
if (host.isWidthSizedToContent() || host.isHeightSizedToContent())
{
host.layout.measure();
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
index 7e4ece8..f9263a7 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SkinnableContainerView.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SkinnableContainerView.as
@@ -23,6 +23,8 @@ package spark.components.beads
import spark.components.SkinnableContainer;
import spark.components.supportClasses.GroupBase;
import spark.components.supportClasses.SkinnableComponent;
+import spark.components.supportClasses.Skin;
+import spark.layouts.BasicLayout;
import org.apache.royale.core.IBead;
import org.apache.royale.core.IContainer;
@@ -55,6 +57,35 @@ public class SkinnableContainerView extends SparkContainerView
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:SkinnableContainer = _strand as SkinnableContainer;
+ if (host.isWidthSizedToContent() || host.isHeightSizedToContent())
+ {
+ if (host.skin)
+ {
+ (host.skin as Skin).layout.measure();
+ host.measuredHeight = host.skin.measuredHeight;
+ host.measuredWidth = host.skin.measuredWidth;
+ }
+ else
+ {
+ if (host.layout == null)
+ host.layout = new BasicLayout();
+ host.layout.measure();
+ }
+ }
+ }
+
override protected function addViewport():void
{
var chost:IContainer = host as IContainer;
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkContainerView.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkContainerView.as
index e27a832..0331ec3 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkContainerView.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkContainerView.as
@@ -22,6 +22,7 @@ package spark.components.beads
import spark.components.SkinnableContainer;
import spark.components.supportClasses.GroupBase;
+import spark.layouts.BasicLayout;
import org.apache.royale.core.IBead;
import org.apache.royale.core.IContainer;
@@ -29,6 +30,8 @@ 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;
+import org.apache.royale.events.Event;
+import org.apache.royale.events.IEventDispatcher;
/**
* @private
@@ -62,7 +65,10 @@ public class SparkContainerView extends ContainerView
super.strand = value;
var host:SkinnableContainer = _strand as SkinnableContainer;
var g:GroupBase = (contentView as GroupBase);
- g.layout = host.layout;
+ if (host.layout != null)
+ g.layout = host.layout;
+ if (g.layout == null)
+ g.layout = new BasicLayout();
if (!host.isWidthSizedToContent())
g.percentWidth = 100;
@@ -70,6 +76,48 @@ public class SparkContainerView extends ContainerView
g.percentHeight = 100;
}
+
+ /**
+ * 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:SkinnableContainer = _strand as SkinnableContainer;
+ 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:SkinnableContainer = _strand as SkinnableContainer;
+ 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"));
+ }
+ }
+ }
+
}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
index e96269f..e0c4153 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
@@ -26,25 +26,17 @@ COMPILE::JS
/*
import flash.display.DisplayObject;*/
-import org.apache.royale.events.Event;
-/*import flash.geom.Point;
-import flash.utils.*;
-import mx.core.FlexVersion;
-import mx.core.ILayoutElement;
-import mx.core.IVisualElement;
-import mx.events.PropertyChangeEvent;
-
-import spark.events.SkinPartEvent;
-import spark.utils.FTETextUtil;
-
-*/
+import mx.collections.IList;
import mx.core.IFactory;
import mx.core.mx_internal;
-import mx.collections.IList;
+
+import org.apache.royale.events.Event;
use namespace mx_internal;
import mx.core.UIComponent;
import spark.components.DataGroup;
+//import spark.events.SkinPartEvent;
+
//--------------------------------------
// Styles
//--------------------------------------
@@ -288,8 +280,99 @@ public class SkinnableComponent extends UIComponent
return;
_skin = value;
+ findSkinParts();
dispatchEvent(new Event("skinChanged"));
}
+
+ /**
+ * @private
+ *
+ * Contains a flat list of all the skin parts. This includes
+ * inherited skin parts. It is best to use a for...in to loop
+ * through the skin parts. The property name will be the name of the
+ * skin part and it's value will be a boolean specifying if it is required
+ * or not.
+ *
+ * The actual return value of this method will be generated by the
+ * compiler and may not be null.
+ *
+ */
+ protected function get skinParts():Object
+ {
+ return null;
+ }
+
+ /**
+ * Find the skin parts in the skin class and assign them to the properties of the component.
+ * You do not call this method directly.
+ * Flex calls it automatically when it calls the <code>attachSkin()</code> method.
+ * Typically, a subclass of SkinnableComponent does not override this method.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ protected function findSkinParts():void
+ {
+ if (skinParts)
+ {
+ for (var id:String in skinParts)
+ {
+ if (skinParts[id] == true)
+ {
+ if (!(id in skin))
+ throw(new Error(resourceManager.getString("components", "requiredSkinPartNotFound", [id])));
+ }
+
+ if (id in skin)
+ {
+ this[id] = skin[id];
+
+ // If the assigned part has already been instantiated, call partAdded() here,
+ // but only for static parts.
+ if (this[id] != null && !(this[id] is IFactory))
+ partAdded(id, this[id]);
+ }
+ }
+ }
+ }
+
+ /**
+ * Called when a skin part is added.
+ * You do not call this method directly.
+ * For static parts, Flex calls it automatically when it calls the <code>attachSkin()</code> method.
+ * For dynamic parts, Flex calls it automatically when it calls
+ * the <code>createDynamicPartInstance()</code> method.
+ *
+ * <p>Override this function to attach behavior to the part.
+ * If you want to override behavior on a skin part that is inherited from a base class,
+ * do not call the <code>super.partAdded()</code> method.
+ * Otherwise, you should always call the <code>super.partAdded()</code> method.</p>
+ *
+ * @param partname The name of the part.
+ *
+ * @param instance The instance of the part.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Flex 4
+ */
+ protected function partAdded(partName:String, instance:Object):void
+ {
+ /*
+ // Dispatch a partAdded event.
+ // This event is an internal implementation detail subject to change.
+ // The accessibility implementation classes listen for this to know
+ // when to add their event listeners to skin parts being added.
+ var event:SkinPartEvent = new SkinPartEvent(SkinPartEvent.PART_ADDED);
+ event.partName = partName;
+ event.instance = instance;
+ dispatchEvent(event);
+ */
+ }
+
//dataGroup copied from SkinnableDataContainer
/**
* An optional skin part that defines the DataGroup in the skin class
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/ConstraintLayout.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/ConstraintLayout.as
index 07c6fbd..d949fb1 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/ConstraintLayout.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/layouts/ConstraintLayout.as
@@ -679,7 +679,7 @@ public class ConstraintLayout extends LayoutBase
COMPILE::JS
{
if (layoutElement['constraintElementId'] == null)
- layoutElement['constraintElementId'] = constraintElementId.toString();
+ layoutElement['constraintElementId'] = (constraintElementId++).toString();
var elementInfo:ElementConstraintInfo = constraintCache[layoutElement['constraintElementId']];
}
COMPILE::SWF
@@ -1733,6 +1733,8 @@ public class ConstraintLayout extends LayoutBase
}
COMPILE::JS
{
+ if (layoutElement['constraintElementId'] == null)
+ layoutElement['constraintElementId'] = (constraintElementId++).toString();
constraintCache[layoutElement['constraintElementId']] = elementInfo;
}