You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2019/04/16 14:22:36 UTC

[royale-asjs] branch color_picker updated: Add color picker with palette, but still not displayed.

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 666734d  Add color picker with palette, but still not displayed.
666734d is described below

commit 666734df29fc234d6ed387942a1e5e51916d04bd
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Tue Apr 16 17:22:19 2019 +0300

    Add color picker with palette, but still not displayed.
---
 .../Basic/src/main/resources/basic-manifest.xml    |  2 +
 .../html/beads/models/ArrayColorSelectionModel.as  | 65 ++++++++++++++++++++++
 .../royale/html/supportClasses/ColorPickerPopUp.as |  4 +-
 ...watchList.as => ColorPickerPopUpWithPalette.as} | 25 +++++++--
 .../royale/html/supportClasses/SwatchList.as       |  4 --
 5 files changed, 88 insertions(+), 12 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index df9c023..8fd129c 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -52,6 +52,7 @@
     <component id="ColorSpectrum" class="org.apache.royale.html.supportClasses.ColorSpectrum"/>
     <component id="ColorPicker" class="org.apache.royale.html.ColorPicker"/>
     <component id="HueSelector" class="org.apache.royale.html.HueSelector"/>
+    <component id="ColorPickerPopUpWithPalette" class="org.apache.royale.html.supportClasses.ColorPickerPopUpWithPalette"/>
     <component id="ColorPickerPopUp" class="org.apache.royale.html.supportClasses.ColorPickerPopUp"/>
     <component id="CheckBox" class="org.apache.royale.html.CheckBox"/>
     <component id="CSSCheckBox" class="org.apache.royale.html.CSSCheckBox"/>
@@ -79,6 +80,7 @@
     <component id="TitleBarTitle" class="org.apache.royale.html.beads.TitleBarTitle"/>
     <component id="ImageModel" class="org.apache.royale.html.beads.models.ImageModel"/>
     <component id="ArraySelectionModel" class="org.apache.royale.html.beads.models.ArraySelectionModel"/>
+    <component id="ArrayColorSelectionModel" class="org.apache.royale.html.beads.models.ArrayColorSelectionModel"/>
     <component id="TitleBarModel" class="org.apache.royale.html.beads.models.TitleBarModel"/>
     <component id="ToolTip" class="org.apache.royale.html.ToolTip"/>
     <component id="Tree" class="org.apache.royale.html.Tree"/>
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/models/ArrayColorSelectionModel.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/models/ArrayColorSelectionModel.as
new file mode 100644
index 0000000..b690790
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/models/ArrayColorSelectionModel.as
@@ -0,0 +1,65 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.html.beads.models
+{
+	import org.apache.royale.core.IColorModel;
+	import org.apache.royale.events.Event;
+
+    /**
+     *  The ArrayColorSelectionModel class is a color selection model for
+     *  a dataProvider that is an array.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.6
+     */
+	public class ArrayColorSelectionModel extends ArraySelectionModel implements IColorModel
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.6
+         */
+		public function ArrayColorSelectionModel()
+		{
+			super();
+			addEventListener("selectedItemChanged", dispatchChangeEvent);
+			addEventListener("selectedIndexChanged", dispatchChangeEvent);
+		}
+		
+		private function dispatchChangeEvent(event:Event):void
+		{
+			dispatchEvent(new Event("change"));
+		}
+		
+		public function get color():uint
+		{
+			return uint(selectedItem);
+		}
+		public function set color(value:uint):void
+		{
+			selectedItem = value;
+		}
+		
+	}
+}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as
index 4c92d79..b312ca5 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUp.as
@@ -39,8 +39,8 @@ package org.apache.royale.html.supportClasses
 	 */
 	public class ColorPickerPopUp extends UIBase implements IColorPickerPopUp
 	{
-		private var colorSpectrum:ColorSpectrum;
-		private var hueSelector:HueSelector;
+		protected var colorSpectrum:ColorSpectrum;
+		protected var hueSelector:HueSelector;
 		/**
 		 *  constructor.
 		 *
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUpWithPalette.as
similarity index 59%
copy from frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
copy to frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUpWithPalette.as
index faab9d5..335e65e 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorPickerPopUpWithPalette.as
@@ -18,10 +18,17 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.html.supportClasses
 {
-	import org.apache.royale.html.List;
+	import org.apache.royale.core.IColorModel;
+	import org.apache.royale.core.IColorSpectrumModel;
+	import org.apache.royale.core.UIBase;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.html.HueSelector;
+	import org.apache.royale.utils.hsvToHex;
+	import org.apache.royale.utils.loadBeadFromValuesManager;
 
 	/**
-	 *  The SwatchList class is use in a ColorPicker. It contains a list of predefined colors.
+	 *  The ColorPickerPopUpWithPalette class is used in ColorPicker. It contains a set of controls for picking a color, incluse a color palette.
 	 * 
 	 *
      *  @toplevel
@@ -30,8 +37,9 @@ package org.apache.royale.html.supportClasses
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.9.6
 	 */
-	public class SwatchList extends List
+	public class ColorPickerPopUpWithPalette extends ColorPickerPopUp
 	{
+		protected var colorPalette:SwatchList;
 		/**
 		 *  constructor.
 		 *
@@ -40,13 +48,18 @@ package org.apache.royale.html.supportClasses
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.6
 		 */
-		public function SwatchList()
+		public function ColorPickerPopUpWithPalette()
 		{
 			super();
-			if (!width)
+			colorPalette = new SwatchList();
+			COMPILE::JS 
 			{
-				width = 300;
+				colorPalette.element.style.position = "absolute";
 			}
+			colorPalette.y = colorSpectrum.height + 10;
+			colorPalette.x = colorSpectrum.x;
+			colorPalette.width =  300;
+			addElement(colorPalette);
 		}
 	}
 }
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
index faab9d5..997d5b7 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
@@ -43,10 +43,6 @@ package org.apache.royale.html.supportClasses
 		public function SwatchList()
 		{
 			super();
-			if (!width)
-			{
-				width = 300;
-			}
 		}
 	}
 }