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

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


The following commit(s) were added to refs/heads/color_picker by this push:
     new e0cbd54  Add button to color spectrum
e0cbd54 is described below

commit e0cbd542f33212d7cafc86f0f3c507adddbeb81a
Author: DESKTOP-RH4S838\Yishay <[email protected]>
AuthorDate: Sun Apr 14 16:54:15 2019 +0300

    Add button to color spectrum
---
 .../apache/royale/html/beads/ColorSpectrumView.as  | 49 ++++++++++++++++++++--
 1 file changed, 46 insertions(+), 3 deletions(-)

diff --git 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorSpectrumView.as
 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorSpectrumView.as
index f0a4570..81380f9 100644
--- 
a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorSpectrumView.as
+++ 
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorSpectrumView.as
@@ -19,13 +19,18 @@ package org.apache.royale.html.beads
 {
     import org.apache.royale.core.BeadViewBase;
     import org.apache.royale.core.IColorSpectrumModel;
+    import org.apache.royale.core.IParent;
     import org.apache.royale.core.IRenderedObject;
     import org.apache.royale.core.IStrand;
     import org.apache.royale.core.IStrandWithModel;
+    import org.apache.royale.core.IUIBase;
     import org.apache.royale.events.Event;
     import org.apache.royale.events.IEventDispatcher;
     import org.apache.royale.html.Button;
+    import org.apache.royale.html.TextButton;
     import org.apache.royale.utils.CSSUtils;
+    import org.apache.royale.utils.HSV;
+    import org.apache.royale.utils.rgbToHsv;
        
     /**
      *  The ColorSpectrumView class is the view for
@@ -36,9 +41,9 @@ package org.apache.royale.html.beads
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.9.6
      */
-       public class ColorSpectrumView extends BeadViewBase
+       public class ColorSpectrumView extends BeadViewBase implements 
ISliderView
        {
-               private var _button:Button;
+               private var _thumb:TextButton;
         /**
          *  Constructor.
          *  
@@ -58,8 +63,13 @@ package org.apache.royale.html.beads
                override public function set strand(value:IStrand):void
                {
                        super.strand = value;
-                       _button = new Button();
+                       _thumb = new TextButton();
+                       _thumb.className = "SliderThumb";
+                       _thumb.style = {"position" : "absolute", "padding" : 0};
+                       _thumb.text = '\u29BF';
+                       (value as IParent).addElement(_thumb);
                        (colorModel as 
IEventDispatcher).addEventListener("baseColorChange", changeHandler);
+                       (colorModel as 
IEventDispatcher).addEventListener("hsvModifiedColorChange", changeHandler);
                        updateSpectrum();
                }
                
@@ -68,6 +78,32 @@ package org.apache.royale.html.beads
                        updateSpectrum();
                }
                
+               /**
+                *  The track component.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.0
+                */
+               public function get track():IUIBase
+               {
+                       return _strand as IUIBase;
+               }
+
+               /**
+                *  The thumb component.
+                *
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.6
+                */
+               public function get thumb():IUIBase
+               {
+                       return _thumb;
+               }
+               
                private function updateSpectrum():void
                {
                        var color:String = 
CSSUtils.attributeFromColor(colorModel.baseColor);
@@ -75,6 +111,13 @@ package org.apache.royale.html.beads
                        {
                                (host as 
IRenderedObject).element.style.background = "linear-gradient(to top, #000000, 
transparent), linear-gradient(to left, " + color + ", #ffffff)";
                        }
+                       var hsvModifiedColor:uint = colorModel.hsvModifiedColor;
+                       var r:uint = (hsvModifiedColor >> 16 ) & 255;
+                       var g:uint = (hsvModifiedColor >> 8 ) & 255;
+                       var b:uint = hsvModifiedColor & 255;
+                       var hsv:HSV = rgbToHsv(r,g,b);
+                       _thumb.x = (hsv.s / 100) * host.width - _thumb.width / 
2;
+                       _thumb.y = host.height - hsv.v * host.height / 100 - 
_thumb.height / 2;
                }
                
                private function get colorModel():IColorSpectrumModel

Reply via email to