You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/03/03 22:38:47 UTC

[royale-asjs] branch develop updated: jewel button: add multiline text label bead

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 a178bee  jewel button: add multiline text label bead
a178bee is described below

commit a178bee2b1cd06bad40c6d36916f6283a57a88c3
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Sun Mar 3 23:38:40 2019 +0100

    jewel button: add multiline text label bead
---
 .../src/main/royale/ButtonPlayGround.mxml          |  5 ++
 .../projects/Jewel/src/main/resources/defaults.css |  3 +
 .../Jewel/src/main/resources/jewel-manifest.xml    |  1 +
 .../jewel/beads/controls/button/MultilineLabel.as  | 96 ++++++++++++++++++++++
 .../Jewel/src/main/sass/components/_button.sass    |  4 +
 5 files changed, 109 insertions(+)

diff --git a/examples/royale/TourDeJewel/src/main/royale/ButtonPlayGround.mxml b/examples/royale/TourDeJewel/src/main/royale/ButtonPlayGround.mxml
index c41c37a..ff41b6d 100644
--- a/examples/royale/TourDeJewel/src/main/royale/ButtonPlayGround.mxml
+++ b/examples/royale/TourDeJewel/src/main/royale/ButtonPlayGround.mxml
@@ -62,6 +62,11 @@ limitations under the License.
 						<j:Disabled/>
 					</j:beads>
 				</j:Button>
+				<j:Button text="A Button with multiline text" emphasis="{Button.PRIMARY}" width="200">
+					<j:beads>
+						<j:MultilineLabel multiline="true"/>
+					</j:beads>
+				</j:Button>
 			</j:Card>
 		</j:GridCell>
 		<j:GridCell desktopNumerator="1" desktopDenominator="2" tabletNumerator="1" tabletDenominator="2" phoneNumerator="1" phoneDenominator="1">
diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css b/frameworks/projects/Jewel/src/main/resources/defaults.css
index e390570..eb438cd 100644
--- a/frameworks/projects/Jewel/src/main/resources/defaults.css
+++ b/frameworks/projects/Jewel/src/main/resources/defaults.css
@@ -234,6 +234,9 @@ j|Alert {
 .jewel.button[disabled] {
   cursor: default;
 }
+.jewel.button.multiline {
+  white-space: pre-wrap;
+}
 .jewel.button .fonticon {
   cursor: inherit;
 }
diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 7cfe7ec..b67b343 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -123,6 +123,7 @@
     
     <component id="ResponsiveDrawer" class="org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer"/>
     
+    <component id="MultilineLabel" class="org.apache.royale.jewel.beads.controls.button.MultilineLabel"/>
     <component id="DispatchChangeOnStartup" class="org.apache.royale.jewel.beads.controls.DispatchChangeOnStartup"/>
     <component id="DropDownListTextPrompt" class="org.apache.royale.jewel.beads.controls.dropdownlist.DropDownListTextPrompt"/>
     <component id="RequireSelection" class="org.apache.royale.jewel.beads.controls.dropdownlist.RequireSelection"/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/button/MultilineLabel.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/button/MultilineLabel.as
new file mode 100644
index 0000000..1bc457c
--- /dev/null
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/button/MultilineLabel.as
@@ -0,0 +1,96 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.beads.controls.button
+{
+	import org.apache.royale.core.IBead;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.jewel.Button;
+	
+	/**
+	 *  The MultilineLabel bead is a specialty bead that can be used with
+	 *  any DropDownList control to force a data item always be selected in the control
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.6
+	 */
+	public class MultilineLabel implements IBead
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function MultilineLabel()
+		{
+		}
+		
+		private var button:Button;
+		
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function set strand(value:IStrand):void
+		{
+			button = value as Button;
+			updateHost();
+		}	
+
+		private var _multiline:Boolean;
+        /**
+		 *  A boolean flag to activate "multiline" effect selector.
+		 *  Allow the Button to have more than one line label if needed
+         *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+        public function get multiline():Boolean
+        {
+            return _multiline;
+        }
+
+        public function set multiline(value:Boolean):void
+        {
+            if (_multiline != value)
+            {
+                _multiline = value;
+				updateHost();
+            }
+        }
+
+		protected function updateHost():void
+		{
+			if (button)
+			{
+                button.toggleClass("multiline", _multiline);
+            }
+		}
+	}
+}
diff --git a/frameworks/projects/Jewel/src/main/sass/components/_button.sass b/frameworks/projects/Jewel/src/main/sass/components/_button.sass
index 01293c2..bdd0d87 100644
--- a/frameworks/projects/Jewel/src/main/sass/components/_button.sass
+++ b/frameworks/projects/Jewel/src/main/sass/components/_button.sass
@@ -52,9 +52,13 @@ $button-padding: 0.68em 1.12em !default
     &[disabled]
         cursor: default
 
+    &.multiline
+        white-space: pre-wrap
+
     .fonticon
         cursor: inherit
 
+
 @media -royale-swf
     j|Button
         IBeadModel: ClassReference("org.apache.royale.jewel.beads.models.TextModel")