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 40f7e0d add Jewel ToolTip and ToolTipLabel and styles
40f7e0d is described below
commit 40f7e0d9991b8037fa68a0baddd426cf46f2cad6
Author: Carlos Rovira <[email protected]>
AuthorDate: Fri Sep 7 12:29:35 2018 +0200
add Jewel ToolTip and ToolTipLabel and styles
---
.../projects/Jewel/src/main/resources/defaults.css | 7 +
.../Jewel/src/main/resources/jewel-manifest.xml | 2 +
.../apache/royale/jewel/beads/controls/ToolTip.as | 209 +++++++++++++++++++++
.../jewel/supportClasses/tooltip/ToolTipLabel.as | 79 ++++++++
.../Jewel/src/main/sass/components/_tooltip.sass | 6 +-
.../JewelTheme/src/main/resources/defaults.css | 5 +
.../src/main/sass/components-primary/_tooltip.sass | 5 +-
7 files changed, 311 insertions(+), 2 deletions(-)
diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css
b/frameworks/projects/Jewel/src/main/resources/defaults.css
index 3fc72b1..2dfc3b3 100644
--- a/frameworks/projects/Jewel/src/main/resources/defaults.css
+++ b/frameworks/projects/Jewel/src/main/resources/defaults.css
@@ -3361,6 +3361,13 @@ j|TitleBar {
cursor: unset;
}
+.jewel.tooltip {
+ padding: 6px;
+ position: absolute;
+ pointer-events: none;
+ z-index: 5;
+}
+
.jewel.errorTip {
padding: 6px;
z-index: 5;
diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 8683727..cbf9ea0 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -64,6 +64,7 @@
<component id="DateField" class="org.apache.royale.jewel.DateField"/>
<component id="DataContainer"
class="org.apache.royale.jewel.DataContainer" />
<component id="DataGroup"
class="org.apache.royale.jewel.supportClasses.list.DataGroup" />
+ <component id="ToolTipLabel"
class="org.apache.royale.jewel.supportClasses.tooltip.ToolTipLabel" />
<component id="Form" class="org.apache.royale.jewel.Form"/>
<component id="ErrorTip" class="org.apache.royale.jewel.ErrorTip"/>
@@ -97,6 +98,7 @@
<component id="DropDownListList"
class="org.apache.royale.jewel.supportClasses.dropdownlist.DropDownListList"/>
+ <component id="ToolTip"
class="org.apache.royale.jewel.beads.controls.ToolTip"/>
<component id="Disabled"
class="org.apache.royale.jewel.beads.controls.Disabled"/>
<component id="SizeControl"
class="org.apache.royale.jewel.beads.controls.SizeControl"/>
<component id="TextAlign"
class="org.apache.royale.jewel.beads.controls.TextAlign"/>
diff --git
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/ToolTip.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/ToolTip.as
new file mode 100644
index 0000000..5ad42ac
--- /dev/null
+++
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/ToolTip.as
@@ -0,0 +1,209 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import org.apache.royale.core.IBead;
+ import org.apache.royale.core.IPopUpHost;
+ import org.apache.royale.core.IStrand;
+ import org.apache.royale.core.IUIBase;
+ import org.apache.royale.events.IEventDispatcher;
+ import org.apache.royale.events.MouseEvent;
+ import org.apache.royale.geom.Point;
+ import org.apache.royale.jewel.supportClasses.tooltip.ToolTipLabel;
+ import org.apache.royale.utils.PointUtils;
+ import org.apache.royale.utils.UIUtils;
+
+ /**
+ * The ToolTip class is a specialty bead that can be used with
+ * any control. The bead floats a string over a control if
+ * the user hovers over the control with a mouse.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public class ToolTip implements IBead
+ {
+ /**
+ * constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public function ToolTip()
+ {
+ }
+
+ public static const TOP:int = 10000;
+ public static const BOTTOM:int = 10001;
+ public static const LEFT:int = 10002;
+ public static const RIGHT:int = 10003;
+ public static const MIDDLE:int = 10004;
+
+ private var _toolTip:String;
+ private var tt:ToolTipLabel;
+ private var host:IPopUpHost;
+ private var _xPos:int = RIGHT;
+ private var _yPos:int = BOTTOM;
+
+ /**
+ * The string to use as the toolTip.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public function get toolTip():String
+ {
+ return _toolTip;
+ }
+ public function set toolTip(value:String):void
+ {
+ _toolTip = value;
+ }
+
+ /**
+ * Sets the tooltip y relative position to one of
+ * LEFT, MIDDLE or RIGHT.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public function set xPos(pos:int):void
+ {
+ _xPos = pos;
+ }
+
+ /**
+ * Sets the tooltip y relative position to one of
+ * TOP, MIDDLE or BOTTOM.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public function set yPos(pos:int):void
+ {
+ _yPos = pos;
+ }
+
+ 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.9.4
+ * @royaleignorecoercion
org.apache.royale.events.IEventDispatcher
+ */
+ public function set strand(value:IStrand):void
+ {
+ _strand = value;
+
+ IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_OVER,
rollOverHandler, false);
+ }
+
+ /**
+ * @private
+ * @royaleignorecoercion org.apache.royale.core.IUIBase
+ * @royaleignorecoercion
org.apache.royale.events.IEventDispatcher
+ */
+ protected function rollOverHandler(event:MouseEvent):void
+ {
+ if (!toolTip || tt)
+ return;
+
+ IEventDispatcher(_strand).addEventListener(MouseEvent.MOUSE_OUT,
rollOutHandler, false);
+
+ var comp:IUIBase = _strand as IUIBase
+ host = UIUtils.findPopUpHost(comp);
+ if (tt) host.popUpParent.removeElement(tt);
+
+ tt = new ToolTipLabel();
+ tt.text = toolTip;
+ var pt:Point = determinePosition(event, event.target);
+ tt.x = pt.x;
+ tt.y = pt.y;
+ host.popUpParent.addElement(tt, false); // don't trigger a layout
+ }
+
+ /**
+ * @private
+ * Determines the position of the toolTip.
+ * @royaleignorecoercion org.apache.royale.core.IUIBase
+ */
+ protected function determinePosition(event:MouseEvent,
base:Object):Point
+ {
+ var comp:IUIBase = _strand as IUIBase;
+ var xFactor:Number = 1;
+ var yFactor:Number = 1;
+ var pt:Point;
+ var relative:Boolean = _xPos > TOP && _yPos > TOP;
+
+ if (_xPos == LEFT) {
+ xFactor = Number.POSITIVE_INFINITY;
+ }
+ else if (_xPos == MIDDLE) {
+ xFactor = 2;
+ }
+ else if (_xPos == RIGHT) {
+ xFactor = 1;
+ }
+ if (_yPos == TOP) {
+ yFactor = Number.POSITIVE_INFINITY;
+ }
+ else if (_yPos == MIDDLE) {
+ yFactor = 2;
+ }
+ else if (_yPos == BOTTOM) {
+ yFactor = 1;
+ }
+
+ pt = new Point(comp.width/xFactor, comp.height/yFactor);
+ pt = PointUtils.localToGlobal(pt, comp);
+
+ return pt;
+ }
+
+ /**
+ * @private
+ * @royaleignorecoercion org.apache.royale.core.IUIBase
+ */
+ protected function rollOutHandler(event:MouseEvent):void
+ {
+
IEventDispatcher(_strand).removeEventListener(MouseEvent.MOUSE_OUT,
rollOutHandler, false);
+
+ var comp:IUIBase = _strand as IUIBase;
+ if (tt) {
+ host.popUpParent.removeElement(tt);
+ tt = null;
+ }
+ }
+ }
+}
+
diff --git
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/tooltip/ToolTipLabel.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/tooltip/ToolTipLabel.as
new file mode 100644
index 0000000..c6e3d5f
--- /dev/null
+++
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/tooltip/ToolTipLabel.as
@@ -0,0 +1,79 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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.supportClasses.tooltip
+{
+ import org.apache.royale.jewel.Label;
+
+ COMPILE::SWF
+ {
+ import flash.display.InteractiveObject;
+ }
+ COMPILE::JS
+ {
+ import org.apache.royale.core.WrappedHTMLElement;
+ }
+
+ /*
+ * Label probably should extend TextField directly,
+ * but the player's APIs for TextLine do not allow
+ * direct instantiation, and we might want to allow
+ * Labels to be declared and have their actual
+ * view be swapped out.
+ */
+
+ /**
+ * The ToolTipLabel class is the control used for ToolTip bead to popup
+ * a text over a control
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public class ToolTipLabel extends Label
+ {
+ /**
+ * Constructor.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10.2
+ * @playerversion AIR 2.6
+ * @productversion Royale 0.9.4
+ */
+ public function ToolTipLabel()
+ {
+ super();
+ typeNames = "jewel tooltip";
+ COMPILE::SWF
+ {
+ mouseEnabled = false;
+ }
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.WrappedHTMLElement
+ */
+ COMPILE::JS
+ override protected function createElement():WrappedHTMLElement
+ {
+ super.createElement();
+ return element;
+ }
+ }
+}
diff --git a/frameworks/projects/Jewel/src/main/sass/components/_tooltip.sass
b/frameworks/projects/Jewel/src/main/sass/components/_tooltip.sass
index dd81997..65ea79c 100644
--- a/frameworks/projects/Jewel/src/main/sass/components/_tooltip.sass
+++ b/frameworks/projects/Jewel/src/main/sass/components/_tooltip.sass
@@ -20,7 +20,11 @@
// Jewel ToolTip
// ToolTip variables
-
+.jewel.tooltip
+ padding: 6px
+ position: absolute
+ pointer-events: none
+ z-index: 5
.jewel
&.errorTip
diff --git a/frameworks/themes/JewelTheme/src/main/resources/defaults.css
b/frameworks/themes/JewelTheme/src/main/resources/defaults.css
index 4ca4faa..409430c 100644
--- a/frameworks/themes/JewelTheme/src/main/resources/defaults.css
+++ b/frameworks/themes/JewelTheme/src/main/resources/defaults.css
@@ -763,6 +763,11 @@ a:active {
margin-right: 8px;
}
+.jewel.tooltip {
+ color: #FFFFFF;
+ background: #1198e9;
+}
+
.jewel.errorTip {
color: #FFFFFF;
background: #EC1C24;
diff --git
a/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tooltip.sass
b/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tooltip.sass
index 031bb44..9464217 100644
---
a/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tooltip.sass
+++
b/frameworks/themes/JewelTheme/src/main/sass/components-primary/_tooltip.sass
@@ -20,7 +20,10 @@
// Jewel ToolTip
// ToolTip variables
-
+.jewel
+ &.tooltip
+ color: $font-theme-color
+ background: darken($primary-color, 10%)
.jewel
&.errorTip