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 2018/07/17 21:15:25 UTC
[royale-asjs] branch develop updated: extract icon from Button to
IconButton, and make ToggleButton extend IconButton
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 182337e extract icon from Button to IconButton, and make ToggleButton extend IconButton
182337e is described below
commit 182337ee6c4f1a9c08e685f7f0664f5e3759e01f
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Tue Jul 17 23:15:20 2018 +0200
extract icon from Button to IconButton, and make ToggleButton extend IconButton
---
.../src/main/royale/ButtonPlayGround.mxml | 8 +--
.../JewelExample/src/main/royale/MainContent.mxml | 8 +--
.../Jewel/src/main/resources/jewel-manifest.xml | 1 +
.../main/royale/org/apache/royale/jewel/Button.as | 61 +----------------
.../royale/org/apache/royale/jewel/IconButton.as | 80 ++++++++++++++++++++++
.../royale/org/apache/royale/jewel/ToggleButton.as | 2 +-
6 files changed, 92 insertions(+), 68 deletions(-)
diff --git a/examples/royale/JewelExample/src/main/royale/ButtonPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/ButtonPlayGround.mxml
index e9b8164..4b098b4 100644
--- a/examples/royale/JewelExample/src/main/royale/ButtonPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/ButtonPlayGround.mxml
@@ -87,16 +87,16 @@ limitations under the License.
<j:Card>
<html:H4 text="Button with Icons"/>
- <j:Button text="print" emphasis="primary">
+ <j:IconButton text="print" emphasis="primary">
<j:icon>
<js:FontIcon text="{MaterialIconType.PRINT}" material="true"/>
</j:icon>
- </j:Button>
- <j:Button emphasis="primary">
+ </j:IconButton>
+ <j:IconButton emphasis="primary">
<j:icon>
<js:FontIcon text="{MaterialIconType.FACE}" material="true"/>
</j:icon>
- </j:Button>
+ </j:IconButton>
</j:Card>
</j:GridCell>
</j:Grid>
diff --git a/examples/royale/JewelExample/src/main/royale/MainContent.mxml b/examples/royale/JewelExample/src/main/royale/MainContent.mxml
index 41cff0f..8b777af 100644
--- a/examples/royale/JewelExample/src/main/royale/MainContent.mxml
+++ b/examples/royale/JewelExample/src/main/royale/MainContent.mxml
@@ -83,22 +83,22 @@ limitations under the License.
<j:TopAppBar id="topappbar" fixed="true" hasDrawer="{drawer.fixed && drawer.isOpen}">
<j:TopAppBarRow>
<j:TopAppBarSection>
- <j:Button click="drawer.isOpen ? drawer.close() : drawer.open()">
+ <j:IconButton click="drawer.isOpen ? drawer.close() : drawer.open()">
<js:beads>
<j:ResponsiveVisibility desktopVisible="false" wideScreenVisible="false"/>
</js:beads>
<j:icon>
<js:FontIcon text="{MaterialIconType.MENU}" material="true"/>
</j:icon>
- </j:Button>
+ </j:IconButton>
<j:TopAppBarTitle text="Apache Royale Jewel UI Set Theme Showcase"/>
</j:TopAppBarSection>
<j:TopAppBarSection alignRight="true">
- <j:Button click="drawer.fixed = !drawer.fixed">
+ <j:IconButton click="drawer.fixed = !drawer.fixed">
<j:icon>
<js:FontIcon text="{MaterialIconType.VISIBILITY}" material="true"/>
</j:icon>
- </j:Button>
+ </j:IconButton>
<j:ToggleButton click="toggleTopAppBarFixed()">
<j:icon>
<js:ToggleFontIcon text="{MaterialIconType.LOCK}" selectedText="{MaterialIconType.LOCK_OPEN}" material="true"/>
diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 3a79892..d2852d0 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -31,6 +31,7 @@
<component id="GridCell" class="org.apache.royale.jewel.GridCell"/>
<component id="Button" class="org.apache.royale.jewel.Button"/>
+ <component id="IconButton" class="org.apache.royale.jewel.IconButton"/>
<component id="ToggleButton" class="org.apache.royale.jewel.ToggleButton"/>
<component id="Label" class="org.apache.royale.jewel.Label"/>
<component id="TextInput" class="org.apache.royale.jewel.TextInput"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as
index 72026ac..fb59004 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Button.as
@@ -22,8 +22,6 @@ package org.apache.royale.jewel
import org.apache.royale.core.ITextModel;
import org.apache.royale.core.IStrand;
import org.apache.royale.core.IUIBase;
- import org.apache.royale.core.IIconSupport;
- import org.apache.royale.core.IIcon;
import org.apache.royale.events.IEventDispatcher;
COMPILE::SWF
@@ -172,7 +170,7 @@ package org.apache.royale.jewel
* @productversion Royale 0.9.3
*/
COMPILE::SWF
- public class Button extends UIButtonBase implements IStrand, IEventDispatcher, IUIBase, IIconSupport, IClassSelectorListSupport
+ public class Button extends UIButtonBase implements IStrand, IEventDispatcher, IUIBase, IClassSelectorListSupport
{
public static const PRIMARY:String = "primary";
public static const SECONDARY:String = "secondary";
@@ -269,28 +267,6 @@ package org.apache.royale.jewel
}
}
- private var _icon:IIcon;
- /**
- * The icon to use with the button.
- * Optional
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.3
- */
- public function get icon():IIcon
- {
- return _icon;
- }
- public function set icon(value:IIcon):void
- {
- _icon = value;
-
- classSelectorList.toggle("icon", (_icon != null));
- // todo set up icon on swf
- }
-
/**
* Add a class selector to the list.
*
@@ -376,7 +352,7 @@ package org.apache.royale.jewel
* @productversion Royale 0.9.3
*/
COMPILE::JS
- public class Button extends StyledUIBase implements IStrand, IEventDispatcher, IUIBase, IIconSupport
+ public class Button extends StyledUIBase implements IStrand, IEventDispatcher, IUIBase
{
public static const PRIMARY:String = "primary";
public static const SECONDARY:String = "secondary";
@@ -471,39 +447,6 @@ package org.apache.royale.jewel
}
}
- private var _icon:IIcon;
- /**
- * The icon to use with the button.
- * Optional
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion Royale 0.9.3
- */
- public function get icon():IIcon
- {
- return _icon;
- }
- public function set icon(value:IIcon):void
- {
- _icon = value;
-
- var iconClass:String = "icon";
- if(text != "")
- {
- iconClass += "WithSpace";
- }
-
- toggleClass(iconClass, (_icon != null));
-
- COMPILE::JS
- {
- // insert the icon before the text
- addElementAt(_icon, 0);
- }
- }
-
/**
* @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
*/
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/IconButton.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/IconButton.as
new file mode 100644
index 0000000..0d33165
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/IconButton.as
@@ -0,0 +1,80 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import org.apache.royale.core.IIconSupport;
+ import org.apache.royale.core.IIcon;
+
+ public class IconButton extends Button implements IIconSupport
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.3
+ */
+ public function IconButton()
+ {
+ super();
+
+ //typeNames = "jewel button";
+ }
+
+ private var _icon:IIcon;
+ /**
+ * The icon to use with the button.
+ * Optional
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.3
+ */
+ public function get icon():IIcon
+ {
+ return _icon;
+ }
+ public function set icon(value:IIcon):void
+ {
+ _icon = value;
+
+ var iconClass:String = "icon";
+ if(text != "")
+ {
+ iconClass += "WithSpace";
+ }
+
+ toggleClass(iconClass, (_icon != null));
+
+ COMPILE::JS
+ {
+ // insert the icon before the text
+ addElementAt(_icon, 0);
+ }
+
+ COMPILE::SWF
+ {
+ classSelectorList.toggle("icon", (_icon != null));
+ // todo set up icon on swf
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
index 1aef80c..559170e 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ToggleButton.as
@@ -66,7 +66,7 @@ package org.apache.royale.jewel
* @playerversion AIR 2.6
* @productversion Royale 0.9.3
*/
- public class ToggleButton extends Button implements ISelectable
+ public class ToggleButton extends IconButton implements ISelectable
{
/**
* Constructor.