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/03/11 10:02:31 UTC

[royale-asjs] branch color_picker created (now b985b92)

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

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


      at b985b92  Adding swatch - no styling as of yet

This branch includes the following new commits:

     new b985b92  Adding swatch - no styling as of yet

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[royale-asjs] 01/01: Adding swatch - no styling as of yet

Posted by yi...@apache.org.
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

commit b985b92209725859932ea12ecccfd83fc607f9e4
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Mon Mar 11 12:02:09 2019 +0200

    Adding swatch - no styling as of yet
---
 .../Basic/src/main/resources/basic-manifest.xml    |   2 +
 .../projects/Basic/src/main/resources/defaults.css |  13 +++
 .../royale/org/apache/royale/html/SwatchList.as    |  47 +++++++++
 .../html/supportClasses/ColorItemRenderer.as       | 105 +++++++++++++++++++++
 4 files changed, 167 insertions(+)

diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 82d2990..1a0775a 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -48,6 +48,7 @@
     <component id="DynamicList" class="org.apache.royale.html.DynamicList"/>
     <component id="PopUpList" class="org.apache.royale.html.PopUpList"/>
     <component id="SimpleList" class="org.apache.royale.html.SimpleList"/>
+    <component id="SwatchList" class="org.apache.royale.html.SwatchList"/>
     <component id="CheckBox" class="org.apache.royale.html.CheckBox"/>
     <component id="CSSCheckBox" class="org.apache.royale.html.CSSCheckBox"/>
     <component id="RadioButton" class="org.apache.royale.html.RadioButton"/>
@@ -122,6 +123,7 @@
     <component id="MXMLItemRenderer" class="org.apache.royale.html.supportClasses.MXMLItemRenderer"/>
     <component id="AlternatingBackgroundColorStringItemRenderer" class="org.apache.royale.html.supportClasses.AlternatingBackgroundColorStringItemRenderer"/>
     <component id="StringItemRenderer" class="org.apache.royale.html.supportClasses.StringItemRenderer"/>
+    <component id="ColorItemRenderer" class="org.apache.royale.html.supportClasses.ColorItemRenderer"/>
     <component id="AccordionItemRenderer" class="org.apache.royale.html.supportClasses.AccordionItemRenderer"/>
     <component id="AccordionCollapseBead" class="org.apache.royale.html.beads.AccordionCollapseBead"/>
     <component id="DispatchInputFinishedBead" class="org.apache.royale.html.beads.DispatchInputFinishedBead"/>
diff --git a/frameworks/projects/Basic/src/main/resources/defaults.css b/frameworks/projects/Basic/src/main/resources/defaults.css
index 01f60af..875f0c6 100644
--- a/frameworks/projects/Basic/src/main/resources/defaults.css
+++ b/frameworks/projects/Basic/src/main/resources/defaults.css
@@ -580,6 +580,19 @@ SimpleList
 	IViewportModel: ClassReference("org.apache.royale.html.beads.models.ViewportModel");
 }
 
+SwatchList
+{
+	IBeadModel: ClassReference("org.apache.royale.html.beads.models.ArraySelectionModel");
+	IBeadView:  ClassReference("org.apache.royale.html.beads.ListView");
+	IBeadController: ClassReference("org.apache.royale.html.beads.controllers.ListSingleSelectionMouseController");
+	IBeadLayout: ClassReference("org.apache.royale.html.beads.layouts.TileLayout");
+	IDataProviderItemRendererMapper: ClassReference("org.apache.royale.html.beads.DataItemRendererFactoryForArrayData");
+	IItemRendererClassFactory: ClassReference("org.apache.royale.core.ItemRendererClassFactory");
+	IItemRenderer: ClassReference("org.apache.royale.html.supportClasses.ColorItemRenderer");
+	IViewport: ClassReference("org.apache.royale.html.supportClasses.ScrollingViewport");
+	IViewportModel: ClassReference("org.apache.royale.html.beads.models.ViewportModel");
+}
+
 Slider
 {
 	IBeadModel: ClassReference("org.apache.royale.html.beads.models.RangeModel");
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as
new file mode 100644
index 0000000..50c9d2a
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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
+{
+
+	/**
+	 *  The SwatchList class is use in a ColorPicker. It contains a list of predefined colors.
+	 * 
+	 *
+     *  @toplevel
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.6
+	 */
+	public class SwatchList extends List
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function SwatchList()
+		{
+			super();
+		}
+	}
+}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorItemRenderer.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorItemRenderer.as
new file mode 100644
index 0000000..ff905cc
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/ColorItemRenderer.as
@@ -0,0 +1,105 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.supportClasses
+{
+	import org.apache.royale.utils.CSSUtils;
+
+	/**
+	 *  The ColorItemRenderer class displays a color as part of a color palette
+	 *
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.6
+	 */
+	public class ColorItemRenderer extends DataItemRenderer
+	{
+		/**
+		 *  constructor.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function ColorItemRenderer()
+		{
+			super();
+
+            typeNames = 'ColorItemRenderer';
+		}
+
+		/**
+		 *  Sets the data value and uses the String version of the data for display.
+		 *
+		 *  @param Object data The object being displayed by the itemRenderer instance.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 *  @royaleignorecoercion String
+		 */
+		override public function set data(value:Object):void
+		{
+			super.data = value;
+			COMPILE::JS
+			{
+				var color:uint;
+				if (!isNaN(value))
+				{
+					color = uint(value);
+				} else if (dataField)
+				{
+					color = uint(data[dataField]);
+				} else
+				{
+					color = 0x000000;
+				}
+				element.style.backgroundColor = CSSUtils.attributeFromColor(color);
+			}
+		}
+
+
+		/**
+		 * @private
+		 */
+		override public function updateRenderer():void
+		{
+			COMPILE::SWF
+			{
+				super.updateRenderer();
+
+				graphics.clear();
+				graphics.beginFill(useColor, (down||selected||hovered)?1:0);
+				graphics.drawRect(0, 0, width, height);
+				graphics.endFill();
+			}
+			COMPILE::JS
+			{
+//				if (selected)
+//					element.style.backgroundColor = '#9C9C9C';
+//				else if (hovered)
+//					element.style.backgroundColor = '#ECECEC';
+//				else
+//					element.style.backgroundColor = 'transparent';
+			}
+		}
+	}
+}