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/04 22:46:17 UTC

[royale-asjs] branch develop updated (993234b -> 56233b2)

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


    from 993234b  fix combobox popup scrolling in android devices
     new 688a650  DropDownList now has prompt field
     new 4127ce7  topMostEventDispatcher
     new 56233b2  Spark DropDownList

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/spark/controls/DropdownExample.mxml        |   9 +-
 .../src/main/royale/mx/core/UIComponent.as         |  18 ++-
 .../SparkRoyale/src/main/resources/defaults.css    |   7 +
 .../src/main/royale/SparkRoyaleClasses.as          |   2 +
 .../main/royale/spark/components/DropDownList.as   |  31 ++++
 .../spark/components/beads/DropDownListView.as     | 176 +++++++++++++++++++++
 .../beads/controllers/DropDownListController.as    | 111 +++++++++++++
 .../components/supportClasses/DropDownListBase.as  |  21 +--
 8 files changed, 358 insertions(+), 17 deletions(-)
 create mode 100644 frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as
 create mode 100644 frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as


[royale-asjs] 01/03: DropDownList now has prompt field

Posted by ah...@apache.org.
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 688a6502056d89696a90b2a437856ba70dc601c9
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Dec 4 14:44:38 2018 -0800

    DropDownList now has prompt field
---
 .../tourdeflexmodules/src/spark/controls/DropdownExample.mxml    | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/examples/mxroyale/tourdeflexmodules/src/spark/controls/DropdownExample.mxml b/examples/mxroyale/tourdeflexmodules/src/spark/controls/DropdownExample.mxml
index 6e9b695..08d80b4 100644
--- a/examples/mxroyale/tourdeflexmodules/src/spark/controls/DropdownExample.mxml
+++ b/examples/mxroyale/tourdeflexmodules/src/spark/controls/DropdownExample.mxml
@@ -71,14 +71,11 @@
 		
 		<s:VGroup width="100%" height="100%" left="120" top="5">
 			<s:Label text="RJ's Warehouse Price Checker" fontSize="18" />
-			<!--<s:DropDownList id="list1" width="50%" dataProvider="{depts}" labelField="label" 
+			<s:DropDownList id="list1" width="50%" dataProvider="{depts}" labelField="label" 
 							prompt="Select Category"
-							change="handleDepartmentSelected(event)"/>-->
-            <s:DropDownList id="list1" width="50%" dataProvider="{depts}" labelField="label" 
-                            change="handleDepartmentSelected(event)"/>
+							change="handleDepartmentSelected(event)"/>
 			<s:Label id="text2"/>
-			<!--<s:DropDownList id="list2" width="50%" labelField="label" prompt="None"/>-->
-            <s:DropDownList id="list2" width="50%" labelField="label"/>
+			<s:DropDownList id="list2" width="50%" labelField="label" prompt="None"/>
 			<mx:Spacer height="10"/>
 			<s:Label fontSize="14" color="0x336699" text="The price of item: {list2.selectedItem.label} is: ${list1.selectedItem.data}" verticalAlign="bottom"/>
 		</s:VGroup>


[royale-asjs] 02/03: topMostEventDispatcher

Posted by ah...@apache.org.
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 4127ce7a4e3af09b22970aa0ca77ee92523cd62b
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Dec 4 14:45:21 2018 -0800

    topMostEventDispatcher
---
 .../MXRoyale/src/main/royale/mx/core/UIComponent.as    | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 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 4721f4a..da268c4 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -1556,7 +1556,6 @@ public class UIComponent extends UIBase
     public function get systemManager():ISystemManager
     {
         // TODO
-        trace("systemManager not implemented");
         return _systemManager;
     }
 
@@ -1566,7 +1565,6 @@ public class UIComponent extends UIBase
     public function set systemManager(value:ISystemManager):void
     {
         // TODO
-        trace("systemManager not implemented");
         _systemManager = value;
     }
     
@@ -5384,6 +5382,22 @@ COMPILE::JS
         super.removeElement(c, dispatchEvent);
         childRemoved(c as IUIBase);
     }
+    
+    /**
+     *  @copy org.apache.royale.core.IUIBase#topMostEventDispatcher
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     *  @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+     *  @royaleignorecoercion org.apache.royale.events.IEventDispatcher
+     */
+    override public function get topMostEventDispatcher():IEventDispatcher
+    {
+        return FlexGlobals.topLevelApplication.parent as IEventDispatcher;
+    }
+
 }
 
 }


[royale-asjs] 03/03: Spark DropDownList

Posted by ah...@apache.org.
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 56233b20ba864cb215e0273600fa97325c7434cb
Author: Alex Harui <ah...@apache.org>
AuthorDate: Tue Dec 4 14:46:02 2018 -0800

    Spark DropDownList
---
 .../SparkRoyale/src/main/resources/defaults.css    |   7 +
 .../src/main/royale/SparkRoyaleClasses.as          |   2 +
 .../main/royale/spark/components/DropDownList.as   |  31 ++++
 .../spark/components/beads/DropDownListView.as     | 176 +++++++++++++++++++++
 .../beads/controllers/DropDownListController.as    | 111 +++++++++++++
 .../components/supportClasses/DropDownListBase.as  |  21 +--
 6 files changed, 339 insertions(+), 9 deletions(-)

diff --git a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
index ddde944..9e93095 100644
--- a/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/SparkRoyale/src/main/resources/defaults.css
@@ -78,6 +78,13 @@ DataGroup
 	IViewportModel: ClassReference("org.apache.royale.html.beads.models.ViewportModel");
 }
 
+DropDownList
+{
+	IBeadModel: ClassReference("mx.controls.beads.models.SingleSelectionICollectionViewModel");
+	IBeadView: ClassReference("spark.components.beads.DropDownListView");
+	IBeadController: ClassReference("spark.components.beads.controllers.DropDownListController");
+}
+
 List
 {
 	IBeadView: ClassReference("spark.components.beads.SkinnableContainerView");
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as b/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
index 4dc8cee..d9f4357 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/SparkRoyaleClasses.as
@@ -76,6 +76,8 @@ internal class SparkRoyaleClasses
     
     import spark.components.beads.PanelView; PanelView;
     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/DropDownList.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DropDownList.as
index ffea061..f17a8bd 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DropDownList.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/DropDownList.as
@@ -32,6 +32,7 @@ import spark.utils.LabelUtil;
     
  */
  import spark.components.supportClasses.DropDownListBase;
+ import spark.components.beads.DropDownListView;
 
 
 //--------------------------------------
@@ -379,5 +380,35 @@ public class DropDownList extends DropDownListBase
                   labelDisplay.text = prompt;
 		}
     } */
+    
+    /**
+     *  @private
+     *  Because DropDown extends List which overrides numChildren to point to
+     *  the DataGroup, the default measurement code will be incorrect
+     *  
+     *  @royaleignorecoercion spark.components.beads.DropDownListView 
+     */
+    override public function get measuredWidth():Number
+    {
+        var mw:Number = super.measuredWidth;
+        if (mw == 0)
+            mw = (view as DropDownListView).label.measuredWidth;
+        return mw;
+    }
+    
+    /**
+     *  @private
+     *  Because DropDown extends List which overrides numChildren to point to
+     *  the DataGroup, the default measurement code will be incorrect
+     *  
+     *  @royaleignorecoercion spark.components.beads.DropDownListView 
+     */
+    override public function get measuredHeight():Number
+    {
+        var mh:Number = super.measuredHeight;
+        if (mh == 0)
+            mh = (view as DropDownListView).label.measuredHeight;
+        return mh;
+    }
 }
 }
\ No newline at end of file
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as
new file mode 100644
index 0000000..b0a2ee1
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/DropDownListView.as
@@ -0,0 +1,176 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.core.IFlexDisplayObject;
+import mx.core.IUIComponent;
+import mx.managers.PopUpManager;
+
+import spark.components.Button;
+import spark.components.DropDownList;
+
+import org.apache.royale.core.IBead;
+import org.apache.royale.core.IChild;
+import org.apache.royale.core.IContainer;
+import org.apache.royale.core.ILayoutChild;
+import org.apache.royale.core.IPopUpHost;
+import org.apache.royale.core.ISelectionModel;
+import org.apache.royale.core.IStrand;
+import org.apache.royale.core.IStrandWithModel;
+import org.apache.royale.core.IUIBase;
+import org.apache.royale.events.Event;
+import org.apache.royale.html.beads.IDropDownListView;
+
+/**
+ *  @private
+ *  The SkinnableContainerView for emulation.
+ */
+public class DropDownListView extends SkinnableContainerView implements IDropDownListView
+{
+	//--------------------------------------------------------------------------
+	//
+	//  Constructor
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  Constructor.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function DropDownListView()
+	{
+		super();
+	}
+
+    public var label:Button;
+    
+    private var selectionModel:ISelectionModel;
+
+    /**
+     */
+    override public function set strand(value:IStrand):void
+    {
+        super.strand = value;
+        
+        selectionModel = (value as IStrandWithModel).model as ISelectionModel;
+        selectionModel.addEventListener("selectedIndexChanged", selectionChangeHandler);
+        selectionModel.addEventListener("dataProviderChanged", selectionChangeHandler);
+        
+        // remove the DataGroup.  It will be the dropdown
+        var chost:IContainer = host as IContainer;
+        chost.strandChildren.removeElement(viewport.contentView);
+        
+        label = new Button();
+        if (selectionModel.selectedIndex == -1)
+            label.label = (host as DropDownList).prompt;
+        chost.strandChildren.addElement(label);
+        
+        
+        value.addBead(new DropDownListLayout());
+        
+    }
+    
+    private function selectionChangeHandler(event:Event):void
+    {
+        if (selectionModel.selectedItem == null)
+            label.label = (host as DropDownList).prompt;
+        else if (selectionModel.labelField != null)
+            label.label = selectionModel.selectedItem[selectionModel.labelField].toString();
+        else
+            label.label = selectionModel.selectedItem.toString();
+    }
+    
+    /**
+     *  The dropdown/popup that displays the set of choices.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get popUp():IStrand
+    {
+        return viewport.contentView as IStrand;
+    }
+    
+    private var _popUpVisible:Boolean;
+    
+    /**
+     *  A flag that indicates whether the dropdown/popup is
+     *  visible.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get popUpVisible():Boolean
+    {
+        return _popUpVisible;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set popUpVisible(value:Boolean):void
+    {
+        if (value != _popUpVisible)
+        {
+            _popUpVisible = value;
+            if (value)
+            {
+                PopUpManager.addPopUp(popUp as IFlexDisplayObject, _strand);
+                (popUp as IUIComponent).setActualSize((popUp as IUIComponent).width, 100);
+            }
+            else
+            {
+                PopUpManager.removePopUp(popUp as IFlexDisplayObject);
+            }
+        }
+    }
+}
+
+}
+
+import spark.components.Button;
+import spark.components.DropDownList;
+import spark.components.beads.DropDownListView;
+
+import org.apache.royale.core.LayoutBase;
+
+// this layouts out the one Label/Button.
+class DropDownListLayout extends LayoutBase
+{
+    override public function layout():Boolean
+    {
+        var list:DropDownList = host as DropDownList;
+        var view:DropDownListView = list.view as DropDownListView;
+        view.label.setActualSize(list.width, list.height);
+        
+        return false;
+    }
+}
+
+
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as
new file mode 100644
index 0000000..ffddb69
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/controllers/DropDownListController.as
@@ -0,0 +1,111 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.controllers
+{
+
+
+import org.apache.royale.core.IBead;
+import org.apache.royale.core.IBeadController;
+import org.apache.royale.core.ISelectionModel;
+import org.apache.royale.core.IStrand;
+import org.apache.royale.core.IUIBase;
+import org.apache.royale.core.UIBase;
+import org.apache.royale.events.Event;
+import org.apache.royale.events.IEventDispatcher;
+import org.apache.royale.events.MouseEvent;
+import org.apache.royale.html.beads.IDropDownListView;
+import org.apache.royale.geom.Point;
+import org.apache.royale.utils.PointUtils;
+import org.apache.royale.events.MouseEvent;
+
+import mx.core.UIComponent;
+
+/**
+ *  @private
+ *  The controller for Spark Dropdownlist.
+ * 
+ */
+public class DropDownListController implements IBead, IBeadController
+{
+    // NOTE:  this is a copy of Basic DropDownListController but the Basic one is SWF-only
+    
+    
+    private var _strand:IStrand;
+    
+    /**
+     *  @copy org.apache.royale.core.IBead#strand
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function set strand(value:IStrand):void
+    {
+        _strand = value;
+        IEventDispatcher(value).addEventListener(org.apache.royale.events.MouseEvent.CLICK, clickHandler);
+    }
+    
+    private function clickHandler(event:org.apache.royale.events.MouseEvent):void
+    {
+        var viewBead:IDropDownListView = _strand.getBeadByType(IDropDownListView) as IDropDownListView;
+        var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
+        var popUpModel:ISelectionModel = UIBase(viewBead.popUp).model as ISelectionModel;
+        IUIBase(viewBead.popUp).width = IUIBase(_strand).width;
+        popUpModel.dataProvider = selectionModel.dataProvider;
+        popUpModel.labelField = selectionModel.labelField;
+        viewBead.popUpVisible = true; // adds to display list as well
+        popUpModel.selectedIndex = selectionModel.selectedIndex;
+        var pt:Point = new Point(IUIBase(_strand).x, IUIBase(_strand).y + IUIBase(_strand).height);
+        pt = PointUtils.localToGlobal(pt, _strand);
+        IUIBase(viewBead.popUp).x = pt.x;
+        IUIBase(viewBead.popUp).y = pt.y;
+        IEventDispatcher(viewBead.popUp).addEventListener("change", changeHandler);
+        UIComponent(viewBead.popUp).callLater(registerDismissHandler);
+    }
+    
+    // The browser send clicks to listeners added as the event is being dispatched, so if we don't
+    // defer, we pick up the click that opened the dropdown.
+    private function registerDismissHandler():void
+    {
+        IUIBase(_strand).topMostEventDispatcher.addEventListener(org.apache.royale.events.MouseEvent.CLICK, dismissHandler);
+    }
+    
+    private function dismissHandler(event:org.apache.royale.events.MouseEvent):void
+    {
+        if (event.target == _strand) return;
+        
+        IUIBase(_strand).topMostEventDispatcher.removeEventListener(org.apache.royale.events.MouseEvent.CLICK, dismissHandler);
+        var viewBead:IDropDownListView = _strand.getBeadByType(IDropDownListView) as IDropDownListView;
+        viewBead.popUpVisible = false;
+    }
+    
+    private function changeHandler(event:Event):void
+    {
+        var viewBead:IDropDownListView = _strand.getBeadByType(IDropDownListView) as IDropDownListView;
+        viewBead.popUpVisible = false;
+        var selectionModel:ISelectionModel = _strand.getBeadByType(ISelectionModel) as ISelectionModel;
+        var popUpModel:ISelectionModel = UIBase(viewBead.popUp).model as ISelectionModel;
+        selectionModel.selectedIndex = popUpModel.selectedIndex;
+        IEventDispatcher(_strand).dispatchEvent(new Event("change"));
+    }
+}
+
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListBase.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListBase.as
index ebfac16..5ee368a 100644
--- a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListBase.as
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/DropDownListBase.as
@@ -38,6 +38,8 @@ import spark.components.List;
 //import spark.events.DropDownEvent;
 import spark.events.IndexChangeEvent;
 
+import org.apache.royale.core.ISelectionModel;
+
 import mx.core.mx_internal;
 use namespace mx_internal;
 
@@ -317,7 +319,9 @@ public class DropDownListBase extends List
         if (dataProvider === value)
             return;
             
-        super.dataProvider = value;
+        super.dataProvider = value; // this passes it to DataGroup
+        
+        (model as ISelectionModel).dataProvider = value;
        // labelChanged = true;
         invalidateProperties();
     }
@@ -367,15 +371,14 @@ public class DropDownListBase extends List
     /**
      *  @private
      */
-    /* override public function set labelField(value:String):void
+    override public function set labelField(value:String):void
     {
-        if (labelField == value)
-            return;
-            
-        super.labelField = value;
-        labelChanged = true;
-        invalidateProperties();
-    } */
+        super.labelField = value; // this passes it to DataGroup
+        
+        (model as ISelectionModel).labelField = value;
+        //labelChanged = true;
+        //invalidateProperties();
+    }
     
     //----------------------------------
     //  labelFunction