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/04/02 17:27:37 UTC

[royale-asjs] branch feature/MXRoyale updated (96dcb46 -> 8db355e)

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

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


    from 96dcb46  Updated ControlsExample to include NumericStepper.
     new 3971a6e  force a dependency to allow namespaces to work.  Should revisit this at some point.  Language can't really cause circulars
     new 296d625  mx_internal and RadioButtonView needed for RadioButton
     new 51816c6  fix up component/document chain
     new c366004  MXML components are top of component/document chain
     new 9f46e48  mx radiobutton passes checkintests
     new 8db355e  radiobutton mx checkintests

The 6 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:
 build.xml                                          |   5 +-
 .../projects/Language/src/main/royale/Namespace.as |   3 +
 .../MXRoyale/src/main/resources/defaults.css       |   6 +
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |   2 +
 .../src/main/royale/mx/controls/RadioButton.as     | 139 ++++++++++++++-
 .../main/royale/mx/controls/RadioButtonGroup.as    | 191 +++++++++++----------
 .../royale/mx/controls}/beads/RadioButtonView.as   | 113 ++++++++++--
 .../MXRoyale/src/main/royale/mx/core/Container.as  |   3 +
 .../src/main/royale/mx/core/UIComponent.as         |  18 +-
 .../src/main/royale/mx/core/mx_internal.as}        |  29 ++--
 .../tests/mxtests/basicTests/BasicTests-config.xml |   2 +-
 mustella/tests/mxtests/basicTests/BasicTests.mxml  |   4 +-
 .../halo/scripts/RadioButtonTestScript.mxml        |   2 +-
 .../basicTests/halo/views/RadioButtonTests.mxml    |   2 +-
 14 files changed, 370 insertions(+), 149 deletions(-)
 copy frameworks/projects/{Basic/src/main/royale/org/apache/royale/html => MXRoyale/src/main/royale/mx/controls}/beads/RadioButtonView.as (65%)
 copy frameworks/projects/{Core/src/main/royale/org/apache/royale/utils/HTMLLoader.as => MXRoyale/src/main/royale/mx/core/mx_internal.as} (69%)

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

[royale-asjs] 04/06: MXML components are top of component/document chain

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c3660043acd70548e10bfde9f10f23d905a14d01
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Apr 2 10:25:50 2018 -0700

    MXML components are top of component/document chain
---
 frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
index feca242..936cb9a 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
@@ -484,6 +484,9 @@ public class Container extends UIComponent
 			ValuesManager.valuesImpl.init(this);
 		}
 		
+        if (MXMLDescriptor)
+            component = this;
+        
 		super.addedToParent();
 		
 		if (!_initialized) {

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

[royale-asjs] 06/06: radiobutton mx checkintests

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8db355e38220ca75c8df604455cda9be8d32a04b
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Apr 2 10:27:17 2018 -0700

    radiobutton mx checkintests
---
 build.xml                                                            | 5 +++--
 mustella/tests/mxtests/basicTests/BasicTests-config.xml              | 2 +-
 mustella/tests/mxtests/basicTests/BasicTests.mxml                    | 4 ++--
 .../tests/mxtests/basicTests/halo/scripts/RadioButtonTestScript.mxml | 2 +-
 mustella/tests/mxtests/basicTests/halo/views/RadioButtonTests.mxml   | 2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/build.xml b/build.xml
index e9dd619..00848ff 100644
--- a/build.xml
+++ b/build.xml
@@ -1581,13 +1581,14 @@ limitations under the License.
     <target name="mxtests-run-js" >
         <property name="profile_arg" value="dummy=false" />
         <echo>url=file://${basedir}/mustella/tests/mxTests/bin/js-debug/index.html</echo>
-        <echo>script=${basedir}/mustella/tests/mxTests/halo/scripts/ButtonTestScript.mxml</echo>
-        <echo>script=${basedir}/mustella/tests/mxTests/halo/scripts/CheckBoxTestScript.mxml</echo>
+        <echo>script=${basedir}/mustella/tests/mxTests/basicTests/halo/scripts/ButtonTestScript.mxml</echo>
+        <echo>script=${basedir}/mustella/tests/mxTests/basicTests/halo/scripts/CheckBoxTestScript.mxml</echo>
         <java classname="marmotinni.MarmotinniRunner" classpath="${basedir}/mustella/target/classes" fork="true" failonerror="yes">
             <!--<arg value="browser=chrome" />-->
             <arg value="url=file://${basedir}/mustella/tests/mxTests/basicTests/bin/js-debug/index.html" />
             <arg value="script=${basedir}/mustella/tests/mxTests/basicTests/halo/scripts/ButtonTestScript.mxml" />
             <arg value="script=${basedir}/mustella/tests/mxTests/basicTests/halo/scripts/CheckBoxTestScript.mxml" />
+            <arg value="script=${basedir}/mustella/tests/mxTests/basicTests/halo/scripts/RadioButtonTestScript.mxml" />
             <!--<arg value="showSteps=true" />-->
             <arg value="${profile_arg}" />
             <classpath>
diff --git a/mustella/tests/mxtests/basicTests/BasicTests-config.xml b/mustella/tests/mxtests/basicTests/BasicTests-config.xml
index d12e551..db2177e 100644
--- a/mustella/tests/mxtests/basicTests/BasicTests-config.xml
+++ b/mustella/tests/mxtests/basicTests/BasicTests-config.xml
@@ -24,8 +24,8 @@
     <includes>
         <symbol>halo.scripts.ButtonTestScript</symbol>
         <symbol>halo.scripts.CheckBoxTestScript</symbol>
-        <!--
         <symbol>halo.scripts.RadioButtonTestScript</symbol>
+        <!--
         <symbol>halo.scripts.TextInputTestScript</symbol>
         <symbol>halo.scripts.TextAreaTestScript</symbol>
         <symbol>halo.scripts.ComboBoxTestScript</symbol>
diff --git a/mustella/tests/mxtests/basicTests/BasicTests.mxml b/mustella/tests/mxtests/basicTests/BasicTests.mxml
index 7321622..65420a2 100644
--- a/mustella/tests/mxtests/basicTests/BasicTests.mxml
+++ b/mustella/tests/mxtests/basicTests/BasicTests.mxml
@@ -38,8 +38,8 @@ preloader="BasicTestsPreloader"
         <mx:State name="basicTest" />
         <mx:State name="haloButtonTest" />
         <mx:State name="haloCheckBoxTest" />
-        <!--
         <mx:State name="haloRadioButtonTest" />
+        <!--
         <mx:State name="haloTextInputTest" />
         <mx:State name="haloTextAreaTest" />
         <mx:State name="haloComboBoxTest" />
@@ -112,8 +112,8 @@ preloader="BasicTestsPreloader"
     <!--  STEP 2: Add an mxml component with the widgets for your test here -->
     <haloviews:ButtonTests id="haloButtonTests" includeIn="haloButtonTest" />    
     <haloviews:CheckBoxTests id="haloCheckBoxTests" includeIn="haloCheckBoxTest" /> 
-    <!--
     <haloviews:RadioButtonTests id="haloRadioButtonTests" includeIn="haloRadioButtonTest" />    
+    <!--
     <haloviews:TextInputTests id="haloTextInputTests" includeIn="haloTextInputTest" />    
     <haloviews:TextAreaTests id="haloTextAreaTests" includeIn="haloTextAreaTest" />    
     <haloviews:ComboBoxTests id="haloComboBoxTests" includeIn="haloComboBoxTest" />    
diff --git a/mustella/tests/mxtests/basicTests/halo/scripts/RadioButtonTestScript.mxml b/mustella/tests/mxtests/basicTests/halo/scripts/RadioButtonTestScript.mxml
index c138835..df2ef3d 100644
--- a/mustella/tests/mxtests/basicTests/halo/scripts/RadioButtonTestScript.mxml
+++ b/mustella/tests/mxtests/basicTests/halo/scripts/RadioButtonTestScript.mxml
@@ -22,7 +22,7 @@
 	<!-- this set of lines form a template that must be in each unit test -->
 	<mx:Script>
 	<![CDATA[
-	public static function init(o:DisplayObject):void
+	public static function init(o:Object):void
 	{
 	}
 	]]>
diff --git a/mustella/tests/mxtests/basicTests/halo/views/RadioButtonTests.mxml b/mustella/tests/mxtests/basicTests/halo/views/RadioButtonTests.mxml
index 963b3f7..0619d23 100644
--- a/mustella/tests/mxtests/basicTests/halo/views/RadioButtonTests.mxml
+++ b/mustella/tests/mxtests/basicTests/halo/views/RadioButtonTests.mxml
@@ -20,7 +20,7 @@
 <mx:VBox 
     xmlns:fx="http://ns.adobe.com/mxml/2009"
     xmlns:s="library://ns.adobe.com/flex/spark"
-    xmlns:mx="library://ns.adobe.com/flex/mx"                >
+    xmlns:mx="library://ns.apache.org/royale/mx"                >
 
 <fx:Script>
 <![CDATA[

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

[royale-asjs] 01/06: force a dependency to allow namespaces to work. Should revisit this at some point. Language can't really cause circulars

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3971a6eff8aa621b916fc400336dc738b86f597b
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Apr 2 10:22:56 2018 -0700

    force a dependency to allow namespaces to work.  Should revisit this at some point.  Language can't really cause circulars
---
 frameworks/projects/Language/src/main/royale/Namespace.as | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/frameworks/projects/Language/src/main/royale/Namespace.as b/frameworks/projects/Language/src/main/royale/Namespace.as
index 6e4a746..23b8e0c 100644
--- a/frameworks/projects/Language/src/main/royale/Namespace.as
+++ b/frameworks/projects/Language/src/main/royale/Namespace.as
@@ -143,6 +143,9 @@ package
 		{
 			return this;
 		}
+        
+        COMPILE::JS
+        private static var forceLanguageDependency:Class = Language;
 	}
 }
 

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

[royale-asjs] 03/06: fix up component/document chain

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 51816c63a90a547d479f891c8adf6b6269fc5a9e
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Apr 2 10:25:17 2018 -0700

    fix up component/document chain
---
 .../MXRoyale/src/main/royale/mx/core/UIComponent.as    | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 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 1371b81..87886e8 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -41,11 +41,11 @@ import flash.events.EventPhase;
 import flash.events.FocusEvent;
 import flash.events.IEventDispatcher;
 */
+import mx.controls.beads.ToolTipBead;
 import mx.events.FlexEvent;
 import mx.managers.ICursorManager;
 import mx.managers.IFocusManager;
 import mx.managers.ISystemManager;
-import mx.controls.beads.ToolTipBead;
 
 import org.apache.royale.core.CallLaterBead;
 import org.apache.royale.core.IStatesImpl;
@@ -53,14 +53,14 @@ import org.apache.royale.core.IStatesObject;
 import org.apache.royale.core.TextLineMetrics;
 import org.apache.royale.core.UIBase;
 import org.apache.royale.core.ValuesManager;
+import org.apache.royale.html.supportClasses.ContainerContentArea;
 import org.apache.royale.events.Event;
 import org.apache.royale.events.KeyboardEvent;
 import org.apache.royale.events.ValueChangeEvent;
 import org.apache.royale.geom.Point;
 import org.apache.royale.geom.Rectangle;
-//import org.apache.royale.html.accessories.ToolTipBead;
-import org.apache.royale.utils.loadBeadFromValuesManager;
 import org.apache.royale.utils.PointUtils;
+import org.apache.royale.utils.loadBeadFromValuesManager;
 
 /*
 import mx.managers.IToolTipManagerClient;
@@ -720,6 +720,9 @@ public class UIComponent extends UIBase
             var child:IUIComponent = getChildAt(i) as IUIComponent;
             if (!child)
                 continue;
+            // JS subtrees will point back to the component.  Ignore those.
+            if (child == this)
+                continue;
             
             if (child.component == _component ||
                 child.component == FlexGlobals.topLevelApplication)
@@ -731,6 +734,15 @@ public class UIComponent extends UIBase
         _component = value;
     }
     
+    override public function addedToParent():void
+    {
+        super.addedToParent();
+        if (!component && parent is UIComponent)
+            component = UIComponent(parent).component;
+        else if (!component && parent is ContainerContentArea)
+            component = UIComponent(ContainerContentArea(parent).parent).component;
+    }
+    
     //----------------------------------
     //  parentApplication
     //----------------------------------

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

[royale-asjs] 05/06: mx radiobutton passes checkintests

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9f46e48e3afbb2217d28afd5e6c3b813a5c39065
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Apr 2 10:26:45 2018 -0700

    mx radiobutton passes checkintests
---
 .../MXRoyale/src/main/resources/defaults.css       |   6 +
 .../src/main/royale/mx/controls/RadioButton.as     | 139 ++++++++++++++-
 .../main/royale/mx/controls/RadioButtonGroup.as    | 191 +++++++++++----------
 3 files changed, 233 insertions(+), 103 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index 0c25129..8679c05 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -106,6 +106,12 @@ NumericStepper
 		iMeasurementBead: ClassReference("org.apache.royale.html.beads.TextFieldLabelMeasurementBead");
 	}
 	
+	RadioButton
+	{
+		IBeadModel: ClassReference("org.apache.royale.html.beads.models.ValueToggleButtonModel");
+		IBeadView:  ClassReference("mx.controls.beads.RadioButtonView");			
+	}
+	
 	TextInput
 	{
 		IBeadModel: ClassReference("org.apache.royale.html.beads.models.TextModel");
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as
index 57e7ec0..5d052fa 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButton.as
@@ -22,6 +22,10 @@ package mx.controls
 COMPILE::JS
 {
     import goog.DEBUG;
+    import window.Text;
+    import org.apache.royale.core.WrappedHTMLElement;
+    import org.apache.royale.html.supportClasses.RadioButtonIcon;
+    import org.apache.royale.html.util.addElementToWrapper;
 }
 import org.apache.royale.events.Event;
 /*
@@ -31,8 +35,8 @@ import flash.events.MouseEvent;
 import flash.ui.Keyboard;
 import mx.core.IFlexDisplayObject;
 import mx.core.IFlexModuleFactory;
-import mx.core.mx_internal;
 */
+import mx.core.mx_internal;
 import mx.events.FlexEvent;
 /*
 import mx.core.FlexVersion;
@@ -46,8 +50,8 @@ import mx.styles.StyleManager;
 import flash.text.TextLineMetrics;
 import flash.utils.getQualifiedClassName;
 
-use namespace mx_internal;
 */
+use namespace mx_internal;
 
 /**
  *  The RadioButton control lets the user make a single choice
@@ -208,6 +212,91 @@ public class RadioButton extends Button
     {
     }
 
+    /**
+     * @private
+     * 
+     *  @royalesuppresspublicvarwarning
+     */
+    COMPILE::JS
+    public static var radioCounter:int = 0;
+    
+    COMPILE::JS
+    private var labelFor:HTMLLabelElement;
+    COMPILE::JS
+    private var textNode:window.Text;
+    COMPILE::JS
+    private var rbicon:RadioButtonIcon;
+    
+    /**
+     * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+     * @royaleignorecoercion HTMLInputElement
+     * @royaleignorecoercion HTMLLabelElement
+     * @royaleignorecoercion Text
+     */
+    COMPILE::JS
+    override protected function createElement():WrappedHTMLElement
+    {
+        rbicon = new RadioButtonIcon()
+        rbicon.id = '_radio_' + RadioButton.radioCounter++;
+        rbicon.element.addEventListener("change", rbChangeHandler);
+        
+        textNode = document.createTextNode('') as window.Text;
+        
+        labelFor = addElementToWrapper(this,'label') as HTMLLabelElement;
+        labelFor.appendChild(rbicon.element);
+        labelFor.appendChild(textNode);
+        
+        (textNode as WrappedHTMLElement).royale_wrapper = this;
+        (rbicon.element as WrappedHTMLElement).royale_wrapper = this;
+        
+        typeNames = 'RadioButton';
+        
+        return element;
+    }
+    
+    /**
+     * @royaleignorecoercion HTMLInputElement
+     */
+    COMPILE::JS
+    private function rbChangeHandler(event:Event):void
+    {
+        selected = (rbicon.element as HTMLInputElement).checked    
+    }
+    
+    COMPILE::JS
+    override public function set id(value:String):void
+    {
+        super.id = value;
+        labelFor.id = value;
+        rbicon.element.id = value;
+    }
+    
+    COMPILE::JS
+    override public function get label():String
+    {
+        return textNode.nodeValue as String;
+    }
+    
+    COMPILE::JS
+    override public function set label(value:String):void
+    {
+        textNode.nodeValue = value;
+    }
+    
+    /**
+     * @royaleignorecoercion HTMLInputElement
+     */
+    override public function set selected(value:Boolean):void
+    {
+        super.selected = value;
+        COMPILE::JS
+        {
+            (rbicon.element as HTMLInputElement).checked = value;
+        }
+        group.setSelection(this, false);
+        dispatchEvent(new Event("selectedChanged"));
+    }    
+    
     //--------------------------------------------------------------------------
     //
     //  Properties
@@ -236,6 +325,10 @@ public class RadioButton extends Button
      */
     public function get group():RadioButtonGroup
     {
+        if (_group == null)
+        {
+            _group = component[groupName];
+        }
         return _group;
     }
 
@@ -290,8 +383,16 @@ public class RadioButton extends Button
     {
         _groupName = value;
 
+        groupChanged = true;
+
+        COMPILE::JS
+        {
+            (rbicon.element as HTMLInputElement).name = value;
+        }
+
         dispatchEvent(new Event("groupNameChanged"));
     }
+    
 
     //----------------------------------
     //  value
@@ -328,6 +429,10 @@ public class RadioButton extends Button
     public function set value(value:Object):void
     {
         _value = value;
+        COMPILE::JS
+        {
+            (rbicon.element as HTMLInputElement).value = "" + value;
+        }
 
     }
 
@@ -337,6 +442,11 @@ public class RadioButton extends Button
     //
     //--------------------------------------------------------------------------
 
+    override public function addedToParent():void
+    {
+        super.addedToParent();
+        commitProperties();
+    }
 
     /**
      *  @private
@@ -345,6 +455,13 @@ public class RadioButton extends Button
     override protected function commitProperties():void
     {
         super.commitProperties();
+        
+        if (groupChanged)
+        {
+            addToGroup();
+            
+            groupChanged = false;
+        }
     }
 
     //--------------------------------------------------------------------------
@@ -353,12 +470,18 @@ public class RadioButton extends Button
     //
     //--------------------------------------------------------------------------
 
-    //--------------------------------------------------------------------------
-    //
-    //  Overridden event handlers: UIComponent
-    //
-    //--------------------------------------------------------------------------
-
+    /**
+     *  @private
+     *  Create radio button group if it does not exist
+     *  and add the instance to the group.
+     */
+    private function addToGroup():Object
+    {
+        var g:RadioButtonGroup = group; // Trigger getting the group
+        if (g)
+            g.addInstance(this);
+        return g;
+    }
 
 }
 
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButtonGroup.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButtonGroup.as
index 4a59ef7..bc9204e 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButtonGroup.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/RadioButtonGroup.as
@@ -38,14 +38,10 @@ import mx.core.IMXMLObject;
 import mx.core.IRawChildrenContainer;
 */
 import mx.core.UIComponent;
-/*
 import mx.core.mx_internal;
-*/
 import mx.events.FlexEvent;
 import mx.events.ItemClickEvent;
-/*
 use namespace mx_internal;
-*/
 
 //--------------------------------------
 //  Events
@@ -299,8 +295,7 @@ public class RadioButtonGroup extends EventDispatcher
      */
     public function get numRadioButtons():int
     {
-//        return radioButtons.length;
-		return 0;
+        return radioButtons.length;
     }
 
     //----------------------------------
@@ -338,12 +333,12 @@ public class RadioButtonGroup extends EventDispatcher
      */
     public function get selectedValue():Object
     {
-//         if (selection)
-//         {
-//             return selection.value != null ?
-//                    selection.value :
-//                    selection.label;
-//         }
+         if (selection)
+         {
+             return selection.value != null ?
+                    selection.value :
+                    selection.label;
+         }
 
         return null;
     }
@@ -353,28 +348,28 @@ public class RadioButtonGroup extends EventDispatcher
      */
     public function set selectedValue(value:Object):void
     {
-//         _selectedValue = value;
-//
-//         // Clear the exisiting selecton if there is one.
-//         if (value == null)
-//         {
-//             setSelection(null, false);
-//             return;
-//         }
-//
-//         // Find the radio button value specified.
-//         var n:int = numRadioButtons;
-//         for (var i:int = 0; i < n; i++)
-//         {
-//             var radioButton:RadioButton = getRadioButtonAt(i);
-//             if (radioButton.value == value ||
-//                 radioButton.label == value)
-//             {
-//                 changeSelection(i, false);
-//                 break;
-//             }
-//         }
-//
+         _selectedValue = value;
+
+         // Clear the exisiting selecton if there is one.
+         if (value == null)
+         {
+             setSelection(null, false);
+             return;
+         }
+
+         // Find the radio button value specified.
+         var n:int = numRadioButtons;
+         for (var i:int = 0; i < n; i++)
+         {
+             var radioButton:RadioButton = getRadioButtonAt(i);
+             if (radioButton.value == value ||
+                 radioButton.label == value)
+             {
+                 changeSelection(i, false);
+                 break;
+             }
+         }
+
 //         dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
     }
 
@@ -449,19 +444,19 @@ public class RadioButtonGroup extends EventDispatcher
      *  @private
      *  Add a radio button to the group.
      */
-    protected function addInstance(instance:RadioButton):void
+    mx_internal function addInstance(instance:RadioButton):void
     {
-//         instance.addEventListener(Event.REMOVED, radioButton_removedHandler);
-//         radioButtons.push(instance);
-//
-//         // Apply group indices in "tab order" or "breadth-first" order.
-//         radioButtons.sort(readOrderCompare);
-//         for (var i:int = 0; i < radioButtons.length; i++)
-//             radioButtons[i].indexNumber = i;
-//
-//         if (_selectedValue != null)
-//             selectedValue = _selectedValue;
-//
+         //instance.addEventListener(Event.REMOVED, radioButton_removedHandler);
+         radioButtons.push(instance);
+
+         // Apply group indices in "tab order" or "breadth-first" order.
+         // TODO (aharui) later: radioButtons.sort(readOrderCompare);
+         //for (var i:int = 0; i < radioButtons.length; i++)
+         //    RadioButton(radioButtons[i]).indexNumber = i;
+
+         if (_selectedValue != null)
+             selectedValue = _selectedValue;
+
 // 		dispatchEvent(new Event("numRadioButtonsChanged"));
     }
 
@@ -469,8 +464,8 @@ public class RadioButtonGroup extends EventDispatcher
      *  @private
      *  Remove a radio button from the group.
      */
-    protected function removeInstance(instance:RadioButton):void
-    {
+//    protected function removeInstance(instance:RadioButton):void
+//    {
 //         if (instance)
 //         {
 //
@@ -503,15 +498,15 @@ public class RadioButtonGroup extends EventDispatcher
 //             if (foundInstance)
 // 				dispatchEvent(new Event("numRadioButtonsChanged"));
 //         }
-    }
+//    }
 
     /**
      *  @private
      *  Return the value or the label value
      *  of the selected radio button.
      */
-    private function getValue():String
-    {
+//    private function getValue():String
+//    {
 //         if (selection)
 //         {
 //             return selection.value &&
@@ -524,37 +519,43 @@ public class RadioButtonGroup extends EventDispatcher
 //         {
 //             return null;
 //         }
-		return null;
-    }
+//		return null;
+//    }
 
+    private var inSetSelection:Boolean;
+    
     /**
      *  @private
      */
-    protected function setSelection(value:RadioButton, fireChange:Boolean = true):void
+    mx_internal function setSelection(value:RadioButton, fireChange:Boolean = true):void
     {
-//         if (value == null)
-//         {
-//             if (selection != null)
-//             {
-//                 _selection.selected = false;
-//                 _selection = null;
-//                 if (fireChange)
-//                     dispatchEvent(new Event(Event.CHANGE));
-//             }
-//         }
-//         else
-//         {
-//             var n:int = numRadioButtons;
-//             for (var i:int = 0; i < n; i++)
-//             {
-//                 if (value == getRadioButtonAt(i))
-//                 {
-//                     changeSelection(i, fireChange);
-//                     break;
-//                 }
-//             }
-//         }
-//
+         if (inSetSelection) return;
+        
+         if (value == null)
+         {
+             if (selection != null)
+             {
+                 _selection.selected = false;
+                 _selection = null;
+                 if (fireChange)
+                     dispatchEvent(new Event(Event.CHANGE));
+             }
+         }
+         else
+         {
+             var n:int = numRadioButtons;
+             for (var i:int = 0; i < n; i++)
+             {
+                 if (value == getRadioButtonAt(i))
+                 {
+                     inSetSelection = true;
+                     changeSelection(i, fireChange);
+                     inSetSelection = false;
+                     break;
+                 }
+             }
+         }
+
 //         dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
     }
 
@@ -563,21 +564,21 @@ public class RadioButtonGroup extends EventDispatcher
      */
     private function changeSelection(index:int, fireChange:Boolean = true):void
     {
-//         if (getRadioButtonAt(index))
-//         {
-//             // Unselect the currently selected radio
-//             if (selection)
-//                 selection.selected = false;
-//
-//             // Change the focus to the new radio.
-//             // Set the state of the new radio to true.
-//             // Fire a click event for the new radio.
-//             // Fire a click event for the radio group.
-//             _selection = getRadioButtonAt(index);
-//             _selection.selected = true;
-//             if (fireChange)
-//                 dispatchEvent(new Event(Event.CHANGE));
-//         }
+         if (getRadioButtonAt(index))
+         {
+             // Unselect the currently selected radio
+             if (selection)
+                 selection.selected = false;
+
+             // Change the focus to the new radio.
+             // Set the state of the new radio to true.
+             // Fire a click event for the new radio.
+             // Fire a click event for the radio group.
+             _selection = getRadioButtonAt(index);
+             _selection.selected = true;
+             if (fireChange)
+                 dispatchEvent(new Event(Event.CHANGE));
+         }
     }
 
     //--------------------------------------------------------------------------
@@ -588,15 +589,15 @@ public class RadioButtonGroup extends EventDispatcher
      /**
      *  @private
      */
-    private function radioButton_removedHandler(event:Event):void
-    {
+//    private function radioButton_removedHandler(event:Event):void
+//    {
 //         var rb:RadioButton = event.target as RadioButton;
 //         if (rb)
 //         {
 //         	rb.removeEventListener(Event.REMOVED, radioButton_removedHandler);
 //             removeInstance(RadioButton(event.target));
 //         }
-    }
+//    }
 }
 
 }

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

[royale-asjs] 02/06: mx_internal and RadioButtonView needed for RadioButton

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 296d625e6e2a875804b9a43530b359526207d887
Author: Alex Harui <ah...@apache.org>
AuthorDate: Mon Apr 2 10:24:16 2018 -0700

    mx_internal and RadioButtonView needed for RadioButton
---
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |   2 +
 .../royale/mx/controls/beads/RadioButtonView.as    | 361 +++++++++++++++++++++
 .../{MXRoyaleClasses.as => mx/core/mx_internal.as} |  39 +--
 3 files changed, 377 insertions(+), 25 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index 9c62e94..b8dd606 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -28,6 +28,7 @@ package
 internal class MXRoyaleClasses
 {
 	import mx.collections.ArrayList; ArrayList;
+    import mx.core.mx_internal; mx_internal;
     import mx.core.UIComponent; UIComponent;
 	import mx.core.Container; Container;
 	import mx.containers.beads.ApplicationLayout; ApplicationLayout;
@@ -41,6 +42,7 @@ internal class MXRoyaleClasses
     {
         import mx.controls.beads.CSSImageAndTextButtonView; CSSImageAndTextButtonView;
         import mx.controls.beads.CheckBoxView; CheckBoxView;
+        import mx.controls.beads.RadioButtonView; RadioButtonView;
     }
 }
 
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/RadioButtonView.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/RadioButtonView.as
new file mode 100644
index 0000000..0c3fbf2
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/RadioButtonView.as
@@ -0,0 +1,361 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.controls.beads
+{
+	import flash.display.Shape;
+	import flash.display.SimpleButton;
+	import flash.display.Sprite;
+	import flash.events.MouseEvent;
+	import flash.text.TextFieldAutoSize;
+	import flash.text.TextFieldType;
+	
+	import org.apache.royale.core.BeadViewBase;
+	import org.apache.royale.core.CSSTextField;
+	import org.apache.royale.core.IBeadView;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.IValueToggleButtonModel;
+	import org.apache.royale.core.UIBase;
+	import org.apache.royale.events.Event;
+	
+    import mx.controls.RadioButton;
+    
+	/**
+	 *  The RadioButtonView class creates the visual elements of the org.apache.royale.html.RadioButton 
+	 *  component. 
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.0
+	 */
+	public class RadioButtonView extends BeadViewBase implements IBeadView
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 */
+		public function RadioButtonView()
+		{
+			sprites = [ upSprite = new Sprite(),
+				        downSprite = new Sprite(),
+						overSprite = new Sprite(),
+						upAndSelectedSprite = new Sprite(),
+						downAndSelectedSprite = new Sprite(),
+						overAndSelectedSprite = new Sprite() ];
+			
+			for each( var s:Sprite in sprites )
+			{
+				var tf:CSSTextField = new CSSTextField();
+				tf.type = TextFieldType.DYNAMIC;
+				tf.autoSize = TextFieldAutoSize.LEFT;
+				tf.name = "textField";
+				var icon:Shape = new Shape();
+				icon.name = "icon";
+				s.addChild(icon);
+				s.addChild(tf);
+                s.mouseEnabled = false;
+			}
+		}
+		
+		private var upSprite:Sprite;
+		private var downSprite:Sprite;
+		private var overSprite:Sprite;
+		private var upAndSelectedSprite:Sprite;
+		private var downAndSelectedSprite:Sprite;
+		private var overAndSelectedSprite:Sprite;
+		
+		private var sprites:Array;
+		
+		private var _toggleButtonModel:IValueToggleButtonModel;
+		
+        private var host:Sprite;
+
+		/**
+		 *  The model used for the RadioButton.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 */
+		public function get toggleButtonModel() : IValueToggleButtonModel
+		{
+			return _toggleButtonModel;
+		}
+		
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 */
+		override public function set strand(value:IStrand):void
+		{
+			super.strand = value;
+			_toggleButtonModel = value.getBeadByType(IValueToggleButtonModel) as IValueToggleButtonModel;
+			_toggleButtonModel.addEventListener("textChange", textChangeHandler);
+			_toggleButtonModel.addEventListener("htmlChange", htmlChangeHandler);
+			_toggleButtonModel.addEventListener("selectedValueChange", selectedValueChangeHandler);
+			if (_toggleButtonModel.text != null)
+				text = _toggleButtonModel.text;
+			if (_toggleButtonModel.html != null)
+				html = _toggleButtonModel.html;
+            for each( var s:Sprite in sprites )
+            {
+                var tf:CSSTextField = s.getChildByName("textField") as CSSTextField;
+                tf.styleParent = value;
+            }
+			
+			layoutControl();
+			
+            UIBase(value).$addChild(upSprite);
+            UIBase(value).$addChild(downSprite);
+            UIBase(value).$addChild(overSprite);
+            UIBase(value).$addChild(upAndSelectedSprite);
+            UIBase(value).$addChild(downAndSelectedSprite);
+            UIBase(value).$addChild(overAndSelectedSprite);
+            host = Sprite(value);
+            host.mouseEnabled = true;
+            host.buttonMode = true;
+            host.mouseChildren = false;
+            host.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
+            host.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
+            host.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
+            host.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
+            host.addEventListener(MouseEvent.CLICK, mouseClickHandler);
+            
+            /* TODO switch sprites on mouse state 
+			SimpleButton(value).downState = downSprite;
+			SimpleButton(value).overState = overSprite;
+			SimpleButton(value).hitTestState = hitArea;
+            */
+            
+			if (toggleButtonModel.text !== null)
+				text = toggleButtonModel.text;
+			if (toggleButtonModel.html !== null)
+				html = toggleButtonModel.html;
+			
+			selected = (toggleButtonModel.selected && toggleButtonModel.value == value);
+            
+            host.addEventListener("selectedChanged", selectionChangeHandler);
+		}
+		
+		/**
+		 *  The string label for the org.apache.royale.html.RadioButton.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 */
+		public function get text():String
+		{
+			var tf:CSSTextField = upSprite.getChildByName('textField') as CSSTextField;
+			return tf.text;
+		}
+		public function set text(value:String):void
+		{
+			for each( var s:Sprite in sprites )
+			{
+				var tf:CSSTextField = s.getChildByName('textField') as CSSTextField;
+				tf.text = value;
+			}
+			
+			layoutControl();
+		}
+		
+		/**
+		 *  The HTML string for the org.apache.royale.html.RadioButton.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 */
+		public function get html():String
+		{
+			var tf:CSSTextField = upSprite.getChildByName('textField') as CSSTextField;
+			return tf.htmlText;
+		}
+		public function set html(value:String):void
+		{
+			for each(var s:Sprite in sprites)
+			{
+				var tf:CSSTextField = s.getChildByName('textField') as CSSTextField;
+				tf.htmlText = value;
+			}
+			
+			layoutControl();
+		}
+		
+		/**
+		 * @private
+		 */
+		private function textChangeHandler(event:Event):void
+		{
+			text = toggleButtonModel.text;
+		}
+		
+		/**
+		 * @private
+		 */
+		private function htmlChangeHandler(event:Event):void
+		{
+			html = toggleButtonModel.html;
+		}
+		
+		private var _selected:Boolean;
+		
+		/**
+		 * The selection state of the RadioButton
+		 */
+		public function get selected():Boolean
+		{
+			return _selected;
+		}
+		public function set selected(value:Boolean):void
+		{
+			_selected = value;
+			
+			if( value ) {
+                downAndSelectedSprite.visible = true;
+                upAndSelectedSprite.visible = false;
+                overAndSelectedSprite.visible = false;
+                upSprite.visible = false;
+                downSprite.visible = false;
+                overSprite.visible = false;
+			} else {
+                downAndSelectedSprite.visible = false;
+                upAndSelectedSprite.visible = false;
+                overAndSelectedSprite.visible = false;
+                upSprite.visible = false;
+                downSprite.visible = true;
+                overSprite.visible = false;
+			}
+			
+			layoutControl();
+		}
+		
+		/**
+		 * @private
+		 */
+		private function selectedValueChangeHandler(event:Event):void
+		{
+			selected = _toggleButtonModel.value == _toggleButtonModel.selectedValue;
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function layoutControl() : void
+		{
+			for each(var s:Sprite in sprites)
+			{
+				var icon:Shape = s.getChildByName("icon") as Shape;
+				var tf:CSSTextField = s.getChildByName("textField") as CSSTextField;
+				
+				drawRadioButton(icon);
+				
+				var mh:Number = Math.max(icon.height,tf.height);
+				
+				icon.x = 0;
+				icon.y = (mh - icon.height)/2;
+				
+				tf.x = icon.x + icon.width + 1;
+				tf.y = (mh - tf.height)/2;
+			}
+			
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function drawRadioButton(icon:Shape) : void
+		{
+			icon.graphics.clear();
+			icon.graphics.beginFill(0xf8f8f8);
+			icon.graphics.lineStyle(1,0x808080);
+			icon.graphics.drawEllipse(0,0,10,10);
+			icon.graphics.endFill();
+			
+			if( selected ) {
+				icon.graphics.beginFill(0);
+				icon.graphics.drawEllipse(3,3,4,4);
+				icon.graphics.endFill();
+			}
+		}
+        
+        private function mouseOverHandler(event:MouseEvent):void
+        {
+            downAndSelectedSprite.visible = false;
+            upAndSelectedSprite.visible = false;
+            overAndSelectedSprite.visible = selected;
+            upSprite.visible = false;
+            downSprite.visible = false;
+            overSprite.visible = !selected;           
+        }
+        
+        private function mouseOutHandler(event:MouseEvent):void
+        {
+            downAndSelectedSprite.visible = false;
+            upAndSelectedSprite.visible = selected;
+            overAndSelectedSprite.visible = false;
+            upSprite.visible = !selected;
+            downSprite.visible = false;
+            overSprite.visible = false;           
+        }
+
+        private function mouseUpHandler(event:MouseEvent):void
+        {
+            downAndSelectedSprite.visible = false;
+            upAndSelectedSprite.visible = selected;
+            overAndSelectedSprite.visible = false;
+            upSprite.visible = !selected;
+            downSprite.visible = false;
+            overSprite.visible = false;           
+        }
+        
+        private function mouseDownHandler(event:MouseEvent):void
+        {
+            downAndSelectedSprite.visible = selected;
+            upAndSelectedSprite.visible = false;
+            overAndSelectedSprite.visible = false;
+            upSprite.visible = false;
+            downSprite.visible = !selected;
+            overSprite.visible = false;           
+        }
+        
+        private function mouseClickHandler(event:MouseEvent):void
+        {
+            selected = !selected;
+            RadioButton(host).selected = selected;
+        }
+        
+        private function selectionChangeHandler(event:Event):void
+        {
+            selected = !selected;
+        }
+	}
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/mx_internal.as
similarity index 54%
copy from frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
copy to frameworks/projects/MXRoyale/src/main/royale/mx/core/mx_internal.as
index 9c62e94..e70b0a5 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/mx_internal.as
@@ -16,33 +16,22 @@
 //  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////
-package
+
+package mx.core
 {
 
 /**
- *  @private
- *  This class is used to link additional classes into rpc.swc
- *  beyond those that are found by dependecy analysis starting
- *  from the classes specified in manifest.xml.
+ *  This namespace is used for undocumented APIs -- usually implementation
+ *  details -- which can't be private because they need to visible
+ *  to other classes.
+ *  APIs in this namespace are completely unsupported and are likely to
+ *  change in future versions of Flex.
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
  */
-internal class MXRoyaleClasses
-{
-	import mx.collections.ArrayList; ArrayList;
-    import mx.core.UIComponent; UIComponent;
-	import mx.core.Container; Container;
-	import mx.containers.beads.ApplicationLayout; ApplicationLayout;
-	import mx.containers.beads.BoxLayout; BoxLayout;
-	import mx.containers.beads.CanvasLayout; CanvasLayout;
-	import mx.controls.ToolTip; ToolTip;
-	import mx.controls.beads.ToolTipBead; ToolTipBead;
-	import mx.utils.ArrayUtil; ArrayUtil;
-	
-    COMPILE::SWF
-    {
-        import mx.controls.beads.CSSImageAndTextButtonView; CSSImageAndTextButtonView;
-        import mx.controls.beads.CheckBoxView; CheckBoxView;
-    }
+public namespace mx_internal =
+	"http://www.adobe.com/2006/flex/mx/internal";
 }
-
-}
-

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.