This is an automated email from the ASF dual-hosted git repository. pent pushed a commit to branch feature/MXRoyale in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/feature/MXRoyale by this push: new 469db58 Partially working. 469db58 is described below commit 469db5814077df1dc3bdd4a325b5b8aaca9d65e1 Author: Peter Ent <p...@apache.org> AuthorDate: Tue Mar 13 17:21:00 2018 -0400 Partially working. --- .../HellowWorld/src/main/royale/HelloWorld.mxml | 15 +- .../src/main/config/compile-swf-config.xml | 23 +- .../MXRoyale/src/main/resources/defaults.css | 12 + .../src/main/resources/mx-royale-as-manifest.xml | 26 ++ .../MXRoyale/src/main/royale/mx/controls/Button.as | 399 +++++++++++++++++---- 5 files changed, 396 insertions(+), 79 deletions(-) diff --git a/examples/mxroyale/HellowWorld/src/main/royale/HelloWorld.mxml b/examples/mxroyale/HellowWorld/src/main/royale/HelloWorld.mxml index a1278a1..fc75030 100644 --- a/examples/mxroyale/HellowWorld/src/main/royale/HelloWorld.mxml +++ b/examples/mxroyale/HellowWorld/src/main/royale/HelloWorld.mxml @@ -17,7 +17,18 @@ See the License for the specific language governing permissions and limitations under the License. --> -<mx:Application xmlns:mx="library://ns.apache.org/royale/mx" > +<mx:Application xmlns:mx="library://ns.apache.org/royale/mx" + xmlns:js="library://ns.apache.org/royale/basic" + width="600" height="400" > <!-- to do: layout="absolute" minWidth="955" minHeight="600" --> - <mx:Label text="Hello World" /> + + + <!-- temporary until we can get this worked out --> + <js:initialView> + <js:View> + <mx:Label text="Hello World" x="20" y="20" /> + <mx:Button label="Push Me" x="20" y="60" /> + </js:View> + </js:initialView> + </mx:Application> \ No newline at end of file diff --git a/frameworks/projects/MXRoyale/src/main/config/compile-swf-config.xml b/frameworks/projects/MXRoyale/src/main/config/compile-swf-config.xml index 918c8ad..d6fbb4e 100644 --- a/frameworks/projects/MXRoyale/src/main/config/compile-swf-config.xml +++ b/frameworks/projects/MXRoyale/src/main/config/compile-swf-config.xml @@ -30,23 +30,23 @@ <external-library-path> <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> - <path-element>../../../../../libs/Core.swc</path-element> <path-element>../../../../../libs/Binding.swc</path-element> - <path-element>../../../../../libs/Basic.swc</path-element> - <path-element>../../../../../libs/Collections.swc</path-element> + <path-element>../../../../../libs/Core.swc</path-element> <path-element>../../../../../libs/Graphics.swc</path-element> + <path-element>../../../../../libs/Collections.swc</path-element> + <path-element>../../../../../libs/Basic.swc</path-element> + <path-element>../../../../../libs/DragDrop.swc</path-element> <path-element>../../../../../libs/Express.swc</path-element> </external-library-path> <allow-subclass-overrides>true</allow-subclass-overrides> - <mxml> <children-as-data>true</children-as-data> </mxml> <binding-value-change-event>org.apache.royale.events.ValueChangeEvent</binding-value-change-event> <binding-value-change-event-kind>org.apache.royale.events.ValueChangeEvent</binding-value-change-event-kind> <binding-value-change-event-type>valueChange</binding-value-change-event-type> - + <define> <name>COMPILE::SWF</name> <value>true</value> @@ -73,6 +73,10 @@ <uri>library://ns.apache.org/royale/mx</uri> <manifest>../resources/mx-royale-manifest.xml</manifest> </namespace> + <namespace> + <uri>library://ns.apache.org/royale/mx</uri> + <manifest>../resources/mx-royale-as-manifest.xml</manifest> + </namespace> </namespaces> <source-path> @@ -82,13 +86,20 @@ <warn-no-constructor>false</warn-no-constructor> </compiler> + <include-file> + <name>defaults.css</name> + <path>../resources/defaults.css</path> + </include-file> + + <include-lookup-only>true</include-lookup-only> + <include-classes> <class>MXRoyaleClasses</class> </include-classes> <include-namespaces> <uri>library://ns.apache.org/royale/mx</uri> - </include-namespaces> + </include-namespaces> <target-player>${playerglobal.version}</target-player> diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css index 2c4999d..32a0e4e 100644 --- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css +++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css @@ -30,6 +30,12 @@ * ------------------------------------------------------- */ + +Button +{ + IBeadModel: ClassReference("org.apache.royale.html.beads.models.ImageAndTextModel"); +} + TextInput { border: 1px solid #808080; @@ -48,6 +54,12 @@ TextInput { /* Global style declaration for Flash only. This will effectively be the same as the browser defaults */ + + Button + { + IBeadView: ClassReference("org.apache.royale.html.beads.CSSImageAndTextButtonView"); + } + Label { IBeadModel: ClassReference("org.apache.royale.html.beads.models.TextModel"); diff --git a/frameworks/projects/MXRoyale/src/main/resources/mx-royale-as-manifest.xml b/frameworks/projects/MXRoyale/src/main/resources/mx-royale-as-manifest.xml new file mode 100644 index 0000000..629cc54 --- /dev/null +++ b/frameworks/projects/MXRoyale/src/main/resources/mx-royale-as-manifest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<!-- + + 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. + +--> + + +<componentPackage> + + + +</componentPackage> diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as index af2cf11..cdad3f9 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as @@ -22,50 +22,18 @@ package mx.controls COMPILE::JS { import goog.DEBUG; + import org.apache.royale.core.WrappedHTMLElement; + import org.apache.royale.html.util.addElementToWrapper; } -import org.apache.royale.events.Event; -/* -import flash.display.DisplayObject; -import flash.events.Event; -import flash.events.FocusEvent; -import flash.events.KeyboardEvent; -import flash.events.MouseEvent; -import flash.events.TimerEvent; -import flash.text.TextFormatAlign; -import flash.text.TextLineMetrics; -import flash.ui.Keyboard; -import flash.utils.Timer; - -import mx.controls.dataGridClasses.DataGridListData; -*/ import mx.controls.listClasses.BaseListData; -/* -import mx.controls.listClasses.IDropInListItemRenderer; -import mx.controls.listClasses.IListItemRenderer; -import mx.core.EdgeMetrics; -import mx.core.FlexVersion; -import mx.core.IBorder; -import mx.core.IButton; -*/ import mx.core.IDataRenderer; -/* -import mx.core.IFlexAsset; -import mx.core.IFlexDisplayObject; -import mx.core.IFlexModuleFactory; -import mx.core.IFontContextComponent; -import mx.core.IInvalidating; -import mx.core.ILayoutDirectionElement; -import mx.core.IProgrammaticSkin; -import mx.core.IStateClient; -import mx.core.IUIComponent; -import mx.core.IUITextField; -*/ import mx.core.UIComponent; -/* -import mx.core.UITextField; -import mx.core.mx_internal; -*/ import mx.events.FlexEvent; + +import org.apache.royale.events.Event; +import org.apache.royale.html.accessories.ToolTipBead; +import org.apache.royale.html.beads.models.ImageAndTextModel; + /* import mx.events.MoveEvent; import mx.events.SandboxMouseEvent; @@ -81,6 +49,16 @@ use namespace mx_internal; //-------------------------------------- /** + * Dispatched when the user clicks on a button. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ +[Event(name="click", type="org.apache.royale.events.MouseEvent")] + +/** * Dispatched when the user presses the Button control. * If the <code>autoRepeat</code> property is <code>true</code>, * this event is dispatched repeatedly as long as the button stays down. @@ -264,6 +242,296 @@ use namespace mx_internal; * @playerversion AIR 1.1 * @productversion Flex 3 */ +COMPILE::JS +public class Button extends UIComponent implements IDataRenderer +{ + + public function Button() + { + super(); + typeNames = "ImageAndTextButton"; + } + + // ------------------------------------------------ + // icon + // ------------------------------------------------ + + /** + * The URL of an icon to use in the button + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.0 + */ + public function get icon():String + { + return ImageAndTextModel(model).image; + } + + /** + * @private + */ + public function set icon(value:String):void + { + ImageAndTextModel(model).image = value; + setInnerHTML(); + } + + + //---------------------------------- + // label + //---------------------------------- + + public function get label():String + { + return ImageAndTextModel(model).text; + } + + /** + * @private + */ + public function set label(value:String):void + { + ImageAndTextModel(model).text = value; + setInnerHTML(); + } + + //---------------------------------- + // toolTip + //---------------------------------- + + /** + * @private + */ + private var _toolTipBead:ToolTipBead; + + [Inspectable(category="General", defaultValue="null")] + + /** + * @private + */ + override public function set toolTip(value:String):void + { + super.toolTip = value; + + _toolTipBead = getBeadByType(ToolTipBead) as ToolTipBead; + if (_toolTipBead == null) { + _toolTipBead = new ToolTipBead(); + addBead(_toolTipBead); + } + _toolTipBead.toolTip = value; + } + + override public function get toolTip():String + { + if (_toolTipBead) { + return _toolTipBead.toolTip; + } + return null; + } + + + //---------------------------------- + // data + //---------------------------------- + + /** + * @private + * Storage for the data property; + */ + private var _data:Object; + + [Bindable("dataChange")] + [Inspectable(environment="none")] + + /** + * The <code>data</code> property lets you pass a value + * to the component when you use it as an item renderer or item editor. + * You typically use data binding to bind a field of the <code>data</code> + * property to a property of this component. + * + * <p>When you use the control as a drop-in item renderer or drop-in + * item editor, Flex automatically writes the current value of the item + * to the <code>selected</code> property of this control.</p> + * + * <p>You do not set this property in MXML.</p> + * + * @default null + * @see mx.core.IDataRenderer + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function get data():Object + { + return _data; + } + + /** + * @private + */ + public function set data(value:Object):void + { + _data = value; + dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE)); + } + + //---------------------------------- + // selected + //---------------------------------- + + private var _selected:Boolean = false; + + public function get selected():Boolean + { + return _selected; + } + + /** + * @private + */ + public function set selected(value:Boolean):void + { + _selected = value; + } + + //---------------------------------- + // labelPlacement + //---------------------------------- + + /** + * @private + * Storage for labelPlacement property. + */ + private var _labelPlacement:String = "right";//ButtonLabelPlacement.RIGHT; + + [Bindable("labelPlacementChanged")] + [Inspectable(category="General", enumeration="left,right,top,bottom", defaultValue="right")] + + /** + * Orientation of the label in relation to a specified icon. + * Valid MXML values are <code>right</code>, <code>left</code>, + * <code>bottom</code>, and <code>top</code>. + * + * <p>In ActionScript, you can use the following constants + * to set this property: + * <code>ButtonLabelPlacement.RIGHT</code>, + * <code>ButtonLabelPlacement.LEFT</code>, + * <code>ButtonLabelPlacement.BOTTOM</code>, and + * <code>ButtonLabelPlacement.TOP</code>.</p> + * + * @default ButtonLabelPlacement.RIGHT + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function get labelPlacement():String + { + return _labelPlacement; + } + + /** + * @private + */ + public function set labelPlacement(value:String):void + { + _labelPlacement = value; + dispatchEvent(new Event("labelPlacementChanged")); + } + + + //---------------------------------- + // toggle + //---------------------------------- + + /** + * @private + * Storage for toggle property. + */ + private var _toggle:Boolean = false; + + /** + * @private + */ + private var toggleChanged:Boolean = false; + + [Bindable("toggleChanged")] + [Inspectable(category="General", defaultValue="false")] + + /** + * Controls whether a Button is in a toggle state or not. + * + * If <code>true</code>, clicking the button toggles it + * between a selected and an unselected state. + * You can get or set this state programmatically + * by using the <code>selected</code> property. + * + * If <code>false</code>, the button does not stay pressed + * after the user releases it. + * In this case, its <code>selected</code> property + * is always <code>false</code>. + * Buttons like this are used for performing actions. + * + * When <code>toggle</code> is set to <code>false</code>, + * <code>selected</code> is forced to <code>false</code> + * because only toggle buttons can be selected. + * + * @default false + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function get toggle():Boolean + { + return _toggle; + } + + /** + * @private + */ + public function set toggle(value:Boolean):void + { + _toggle = value; + toggleChanged = true; + dispatchEvent(new Event("toggleChanged")); + } + + + //---------------------------------- + // internal + //---------------------------------- + + /** + * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement + */ + override protected function createElement():WrappedHTMLElement + { + addElementToWrapper(this,'button'); + element.setAttribute('type', 'button'); + return element; + } + + /** + */ + protected function setInnerHTML():void + { + var inner:String = ''; + if (icon != null) + inner += "<img src='" + icon + "'/>"; + inner += ' '; + inner += label; + element.innerHTML = inner; + }; +} + +COMPILE::SWF public class Button extends UIComponent implements IDataRenderer { @@ -290,7 +558,7 @@ public class Button extends UIComponent public function Button() { super(); - typeNames = "Button"; + typeNames = "ImageAndTextButton"; } //-------------------------------------------------------------------------- @@ -436,8 +704,8 @@ public class Button extends UIComponent /** * @private - */ - private var toolTipSet:Boolean = false; + */ + private var _toolTipBead:ToolTipBead; [Inspectable(category="General", defaultValue="null")] @@ -447,17 +715,22 @@ public class Button extends UIComponent override public function set toolTip(value:String):void { super.toolTip = value; - - if (value) - { - toolTipSet = true; - } - else - { - toolTipSet = false; - invalidateDisplayList(); - } + + _toolTipBead = getBeadByType(ToolTipBead) as ToolTipBead; + if (_toolTipBead == null) { + _toolTipBead = new ToolTipBead(); + addBead(_toolTipBead); + } + _toolTipBead.toolTip = value; } + + override public function get toolTip():String + { + if (_toolTipBead) { + return _toolTipBead.toolTip; + } + return null; + } //-------------------------------------------------------------------------- // @@ -519,12 +792,7 @@ public class Button extends UIComponent // label //---------------------------------- - /** - * @private - * Storage for label property. - */ - private var _label:String = ""; - + /** * @private */ @@ -552,7 +820,7 @@ public class Button extends UIComponent */ public function get label():String { - return _label; + return ImageAndTextModel(model).text; } /** @@ -560,18 +828,7 @@ public class Button extends UIComponent */ public function set label(value:String):void { - labelSet = true; - - if (_label != value) - { - _label = value; - labelChanged = true; - - invalidateSize(); - invalidateDisplayList(); - - dispatchEvent(new Event("labelChanged")); - } + ImageAndTextModel(model).text = value; } //---------------------------------- -- To stop receiving notification emails like this one, please contact p...@apache.org.