You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/12/29 11:30:53 UTC
[royale-asjs] branch develop updated: jewel: Rework some
dependencies to make StyledUIBase the base class for Jewel Container.
Introduces Jewel GroupBase and ContainerBase
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 ac8ab3b jewel: Rework some dependencies to make StyledUIBase the base class for Jewel Container. Introduces Jewel GroupBase and ContainerBase
ac8ab3b is described below
commit ac8ab3b5d366516f6d730578c27dfd609a6000f2
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Sun Dec 29 12:30:41 2019 +0100
jewel: Rework some dependencies to make StyledUIBase the base class for Jewel Container. Introduces Jewel GroupBase and ContainerBase
---
.../royale/org/apache/royale/jewel/Container.as | 88 +-----
.../supportClasses/container/ContainerBase.as | 253 ++++++++++++++++
.../royale/jewel/supportClasses/group/GroupBase.as | 323 +++++++++++++++++++++
3 files changed, 577 insertions(+), 87 deletions(-)
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
index 6cd7b71..b60757c 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Container.as
@@ -18,12 +18,11 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.jewel
{
- import org.apache.royale.core.ContainerBase;
import org.apache.royale.core.IMXMLDocument;
import org.apache.royale.core.ValuesManager;
import org.apache.royale.events.Event;
import org.apache.royale.jewel.beads.layouts.StyledLayoutBase;
- import org.apache.royale.utils.ClassSelectorList;
+ import org.apache.royale.jewel.supportClasses.container.ContainerBase;
import org.apache.royale.utils.IClassSelectorListSupport;
import org.apache.royale.utils.MXMLDataInterpreter;
import org.apache.royale.utils.StringUtil;
@@ -33,7 +32,6 @@ package org.apache.royale.jewel
* definition in an MXML file.
*/
[DefaultProperty("mxmlContent")]
-
/**
* The Container class implements a basic container for
@@ -84,98 +82,14 @@ package org.apache.royale.jewel
public function Container()
{
super();
- classSelectorList = new ClassSelectorList(this);
typeNames = "";
}
- protected var classSelectorList:ClassSelectorList;
-
COMPILE::JS
override protected function setClassName(value:String):void
{
classSelectorList.addNames(value);
}
-
- /**
- * Add a class selector to the list.
- *
- * @param name Name of selector to add.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.4
- */
- public function addClass(name:String):void
- {
- COMPILE::JS
- {
- classSelectorList.add(name);
- }
- }
-
- /**
- * Removes a class selector from the list.
- *
- * @param name Name of selector to remove.
- *
- * @royaleignorecoercion HTMLElement
- * @royaleignorecoercion DOMTokenList
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.4
- */
- public function removeClass(name:String):void
- {
- COMPILE::JS
- {
- classSelectorList.remove(name);
- }
- }
-
- /**
- * Add or remove a class selector to/from the list.
- *
- * @param name Name of selector to add or remove.
- * @param value True to add, False to remove.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.4
- */
- public function toggleClass(name:String, value:Boolean):void
- {
- COMPILE::JS
- {
- classSelectorList.toggle(name, value);
- }
- }
-
- /**
- * Search for the name in the element class list
- *
- * @param name Name of selector to find.
- * @return return true if the name is found or false otherwise.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.4
- */
- public function containsClass(name:String):Boolean
- {
- COMPILE::JS
- {
- return classSelectorList.contains(name);
- }
- COMPILE::SWF
- {//not implemented
- return false;
- }
- }
protected var _layout:StyledLayoutBase;
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/container/ContainerBase.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/container/ContainerBase.as
new file mode 100644
index 0000000..4f778dd
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/container/ContainerBase.as
@@ -0,0 +1,253 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.royale.jewel.supportClasses.container
+{
+ COMPILE::SWF
+ {
+ import org.apache.royale.events.ValueEvent;
+ import org.apache.royale.core.ILayoutHost;
+ }
+ import org.apache.royale.jewel.supportClasses.group.GroupBase;
+ import org.apache.royale.core.IContainerBaseStrandChildrenHost;
+ import org.apache.royale.core.ContainerBaseStrandChildren;
+ import org.apache.royale.core.IParent;
+ import org.apache.royale.core.IChild;
+
+ /**
+ * Indicates that the state change has completed. All properties
+ * that need to change have been changed, and all transitinos
+ * that need to run have completed. However, any deferred work
+ * may not be completed, and the screen may not be updated until
+ * code stops executing.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="stateChangeComplete", type="org.apache.royale.events.Event")]
+
+ /**
+ * Indicates that the initialization of the container is complete.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="initComplete", type="org.apache.royale.events.Event")]
+
+ /**
+ * Indicates that the children of the container is have been added.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="childrenAdded", type="org.apache.royale.events.Event")]
+
+ /**
+ * The ContainerBase class is the base class for most containers
+ * in Royale. It is usable as the root tag of MXML
+ * documents and UI controls and containers are added to it.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public class ContainerBase extends GroupBase implements IContainerBaseStrandChildrenHost
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function ContainerBase()
+ {
+ super();
+ }
+
+ private var _strandChildren:ContainerBaseStrandChildren;
+
+ /**
+ * @private
+ */
+ override public function get strandChildren():IParent
+ {
+ if (_strandChildren == null) {
+ _strandChildren = new ContainerBaseStrandChildren(this);
+ }
+ return _strandChildren;
+ }
+
+ /*
+ * 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
+ * in the JS-side. GroupBase handles event dispatching if necessary.
+ */
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ override public function addElement(c:IChild, dispatchEvent:Boolean = true):void
+ {
+ var contentView:IParent = getLayoutHost().contentView as IParent;
+ contentView.addElement(c, dispatchEvent);
+ if (dispatchEvent)
+ this.dispatchEvent(new ValueEvent("childrenAdded", c));
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ override public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void
+ {
+ var contentView:IParent = getLayoutHost().contentView as IParent;
+ contentView.addElementAt(c, index, dispatchEvent);
+ if (dispatchEvent)
+ this.dispatchEvent(new ValueEvent("childrenAdded", c));
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ override public function getElementIndex(c:IChild):int
+ {
+ var layoutHost:ILayoutHost = view as ILayoutHost;
+ var contentView:IParent = layoutHost.contentView as IParent;
+ return contentView.getElementIndex(c);
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ override public function removeElement(c:IChild, dispatchEvent:Boolean = true):void
+ {
+ var layoutHost:ILayoutHost = view as ILayoutHost;
+ var contentView:IParent = layoutHost.contentView as IParent;
+ contentView.removeElement(c, dispatchEvent);
+ //TODO This should possibly be ultimately refactored to be more PAYG
+ if(dispatchEvent)
+ this.dispatchEvent(new ValueEvent("childrenRemoved", c));
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ override public function get numElements():int
+ {
+ var layoutHost:ILayoutHost = view as ILayoutHost;
+ var contentView:IParent = layoutHost.contentView as IParent;
+ return contentView.numElements;
+ }
+
+ /**
+ * @private
+ */
+ COMPILE::SWF
+ override public function getElementAt(index:int):IChild
+ {
+ var layoutHost:ILayoutHost = view as ILayoutHost;
+ var contentView:IParent = layoutHost.contentView as IParent;
+ return contentView.getElementAt(index);
+ }
+
+ /*
+ * IStrandPrivate
+ *
+ * These "internal" function provide a backdoor way for proxy classes to
+ * operate directly at strand level. While these function are available on
+ * both SWF and JS platforms, they really only have meaning on the SWF-side.
+ * Other subclasses may provide use on the JS-side.
+ *
+ * @see org.apache.royale.core.IContainer#strandChildren
+ */
+
+ /**
+ * @private
+ * @suppress {undefinedNames}
+ * Support strandChildren.
+ */
+ public function get $numElements():int
+ {
+ return super.numElements;
+ }
+
+ /**
+ * @private
+ * @suppress {undefinedNames}
+ * Support strandChildren.
+ */
+ public function $addElement(c:IChild, dispatchEvent:Boolean = true):void
+ {
+ super.addElement(c, dispatchEvent);
+ }
+
+ /**
+ * @private
+ * @suppress {undefinedNames}
+ * Support strandChildren.
+ */
+ public function $addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void
+ {
+ super.addElementAt(c, index, dispatchEvent);
+ }
+
+ /**
+ * @private
+ * @suppress {undefinedNames}
+ * Support strandChildren.
+ */
+ public function $removeElement(c:IChild, dispatchEvent:Boolean = true):void
+ {
+ super.removeElement(c, dispatchEvent);
+ }
+
+ /**
+ * @private
+ * @suppress {undefinedNames}
+ * Support strandChildren.
+ */
+ public function $getElementIndex(c:IChild):int
+ {
+ return super.getElementIndex(c);
+ }
+
+ /**
+ * @private
+ * @suppress {undefinedNames}
+ * Support strandChildren.
+ */
+ public function $getElementAt(index:int):IChild
+ {
+ return super.getElementAt(index);
+ }
+
+ }
+}
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/group/GroupBase.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/group/GroupBase.as
new file mode 100644
index 0000000..6db9f15
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/group/GroupBase.as
@@ -0,0 +1,323 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 org.apache.royale.jewel.supportClasses.group
+{
+ COMPILE::JS
+ {
+ import org.apache.royale.core.WrappedHTMLElement;
+ import org.apache.royale.html.util.addElementToWrapper;
+ }
+ import org.apache.royale.core.IBeadLayout;
+ import org.apache.royale.core.IChild;
+ import org.apache.royale.core.IContainer;
+ import org.apache.royale.core.IContentViewHost;
+ import org.apache.royale.core.ILayoutHost;
+ import org.apache.royale.core.ILayoutParent;
+ import org.apache.royale.core.ILayoutView;
+ import org.apache.royale.core.IParent;
+ import org.apache.royale.core.IState;
+ import org.apache.royale.core.IStatesImpl;
+ import org.apache.royale.core.IStatesObject;
+ import org.apache.royale.core.StyledUIBase;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.ValueChangeEvent;
+ import org.apache.royale.events.ValueEvent;
+ import org.apache.royale.utils.loadBeadFromValuesManager;
+
+ /**
+ * Indicates that the state change has completed. All properties
+ * that need to change have been changed, and all transitinos
+ * that need to run have completed. However, any deferred work
+ * may not be completed, and the screen may not be updated until
+ * code stops executing.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="stateChangeComplete", type="org.apache.royale.events.Event")]
+
+ /**
+ * Indicates that the initialization of the container is complete.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="initComplete", type="org.apache.royale.events.Event")]
+
+ /**
+ * Indicates that the children of the container is have been added.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ [Event(name="childrenAdded", type="org.apache.royale.events.Event")]
+
+ /**
+ * The Jewel GroupBase class is the base class for most simple containers
+ * in Royale. It is usable as the root tag of MXML
+ * documents and UI controls and containers are added to it.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public class GroupBase extends StyledUIBase implements IStatesObject, IContainer, ILayoutParent, ILayoutView, IContentViewHost
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function GroupBase()
+ {
+ super();
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override protected function createElement():WrappedHTMLElement
+ {
+ return addElementToWrapper(this,'div');
+ }
+
+ override public function addedToParent():void
+ {
+ super.addedToParent();
+
+ // Load the layout bead if it hasn't already been loaded.
+ loadBeadFromValuesManager(IBeadLayout, "iBeadLayout", this);
+ }
+
+ /*
+ * IContainer
+ */
+
+ /**
+ * @private
+ */
+ public function childrenAdded():void
+ {
+ dispatchEvent(new ValueEvent("childrenAdded"));
+ }
+
+ /*
+ * Utility
+ */
+
+ /**
+ * Dispatches a "layoutNeeded" event
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function layoutNeeded():void
+ {
+ dispatchEvent( new Event("layoutNeeded") );
+ }
+
+ /*
+ * ILayoutParent
+ */
+
+ /**
+ * Returns the ILayoutHost which is its view. From ILayoutParent.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ * @royaleignorecoercion org.apache.royale.core.ILayoutHost
+ */
+ public function getLayoutHost():ILayoutHost
+ {
+ return view as ILayoutHost;
+ }
+
+ /**
+ * @copy org.apache.royale.core.IContentViewHost#strandChildren
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function get strandChildren():IParent
+ {
+ return this;
+ }
+
+ private var _states:Array;
+
+ /**
+ * The array of view states. These should
+ * be instances of org.apache.royale.states.State.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function get states():Array
+ {
+ return _states;
+ }
+
+ /**
+ * @private
+ * @royaleignorecoercion Class
+ * @royaleignorecoercion org.apache.royale.core.IBead
+ */
+ public function set states(value:Array):void
+ {
+ _states = value;
+ _currentState = _states[0].name;
+
+ try{
+ loadBeadFromValuesManager(IStatesImpl, "iStatesImpl", this);
+ }
+ //TODO: Need to handle this case more gracefully
+ catch(e:Error)
+ {
+ COMPILE::SWF
+ {
+ trace(e.message);
+ }
+ }
+
+ }
+
+ /**
+ * <code>true</code> if the array of states
+ * contains a state with this name.
+ *
+ * @param state The state namem.
+ * @return True if state in state array
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function hasState(state:String):Boolean
+ {
+ for each (var s:IState in _states)
+ {
+ if (s.name == state)
+ return true;
+ }
+ return false;
+ }
+
+ private var _currentState:String;
+
+ [Bindable("currentStateChange")]
+ /**
+ * The name of the current state.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function get currentState():String
+ {
+ return _currentState;
+ }
+
+ /**
+ * @private
+ */
+ public function set currentState(value:String):void
+ {
+ if (value == _currentState) return;
+ var event:ValueChangeEvent = new ValueChangeEvent("currentStateChange", false, false, _currentState, value)
+ _currentState = value;
+ dispatchEvent(event);
+ }
+
+ private var _transitions:Array;
+
+ /**
+ * The array of transitions.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.7
+ */
+ public function get transitions():Array
+ {
+ return _transitions;
+ }
+
+ /**
+ * @private
+ */
+ public function set transitions(value:Array):void
+ {
+ _transitions = value;
+ }
+
+ /**
+ * @private
+ */
+ override public function addElement(c:IChild, dispatchEvent:Boolean = true):void
+ {
+ super.addElement(c, dispatchEvent);
+ if (dispatchEvent)
+ this.dispatchEvent(new ValueEvent("childrenAdded", c));
+ }
+
+ /**
+ * @private
+ */
+ 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
+ */
+ 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));
+ }
+
+ }
+}