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 2022/11/23 11:32:57 UTC

[royale-asjs] branch develop updated (ac9b5d2948 -> 7748faddb7)

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

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


    from ac9b5d2948 Emulation - change CP size to make it closer to Flex, plus start thinking about binding
     new bfadd5d909 Add ColorPickerView
     new f2ae7ded40 Merge branch 'color_picker_improvements' into develop
     new 7748faddb7 Emulation - add change event to ColorPicker

The 3 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.


Summary of changes:
 frameworks/projects/MXRoyale/src/main/resources/defaults.css      | 2 +-
 frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as   | 1 +
 .../src/main/royale/mx/controls}/beads/ColorPickerView.as         | 8 ++++++--
 3 files changed, 8 insertions(+), 3 deletions(-)
 copy frameworks/projects/{Basic/src/main/royale/org/apache/royale/html => MXRoyale/src/main/royale/mx/controls}/beads/ColorPickerView.as (96%)


[royale-asjs] 02/03: Merge branch 'color_picker_improvements' into develop

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f2ae7ded4074c463c13dea6256a7a1bd8ec56ec9
Merge: ac9b5d2948 bfadd5d909
Author: Yishay Weiss <yi...@hotmail.com>
AuthorDate: Wed Nov 23 13:13:19 2022 +0200

    Merge branch 'color_picker_improvements' into develop

 .../royale/mx/controls/beads/ColorPickerView.as    | 274 +++++++++++++++++++++
 1 file changed, 274 insertions(+)


[royale-asjs] 01/03: Add ColorPickerView

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit bfadd5d909a988f721716fb7ec57449bcbce314f
Author: Yishay Weiss <yi...@hotmail.com>
AuthorDate: Tue Aug 23 16:15:07 2022 +0300

    Add ColorPickerView
---
 .../royale/mx/controls/beads/ColorPickerView.as    | 274 +++++++++++++++++++++
 1 file changed, 274 insertions(+)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as
new file mode 100644
index 0000000000..4ba61cc499
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as
@@ -0,0 +1,274 @@
+
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 mx.controls.beads
+{
+	import org.apache.royale.core.BeadViewBase;
+	import org.apache.royale.core.IPopUpHost;
+	import org.apache.royale.core.IStrand;
+	import org.apache.royale.core.IStyleableObject;
+	import org.apache.royale.core.IUIBase;
+	import org.apache.royale.core.UIBase;
+	import org.apache.royale.core.ValuesManager;
+	import org.apache.royale.events.Event;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.geom.Point;
+	import org.apache.royale.html.Group;
+	import org.apache.royale.html.TextButton;
+	COMPILE::JS 
+	{
+		import org.apache.royale.utils.CSSUtils;
+		import org.apache.royale.core.IRenderedObject;
+	}
+    import org.apache.royale.utils.loadBeadFromValuesManager;
+	import org.apache.royale.utils.PointUtils;
+	import org.apache.royale.utils.UIUtils;
+	import org.apache.royale.core.IStrandWithModel;
+	import org.apache.royale.html.supportClasses.IColorPickerPopUp;
+	import org.apache.royale.core.IColorModel;
+    import org.apache.royale.core.IPopUp;
+    import org.apache.royale.html.util.getModelByType;
+	
+	/**
+	 *  The ColorPickerView class creates the visual elements of the org.apache.royale.html.ColorPicker 
+	 *  component. The job of the view bead is to put together the parts of the ComboBox such as the color container
+	 *  and org.apache.royale.html.Button to trigger the pop-up.
+	 *  
+	 *  @viewbead
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.6
+	 */
+	public class ColorPickerView extends BeadViewBase implements IComboBoxView
+	{
+		public function ColorPickerView()
+		{
+			super();
+		}
+		
+		protected var selectedColorDisplay:IUIBase;
+		
+		/**
+		 *  The TextInput component of the ComboBox.
+		 * 
+		 *  @copy org.apache.royale.html.beads.IComboBoxView#text
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function get textInputField():Object
+		{
+			return selectedColorDisplay;
+		}
+		
+		private var button:TextButton;
+		
+		/**
+		 *  The Button component of the ComboBox.
+		 * 
+		 *  @copy org.apache.royale.html.beads.IComboBoxView#text
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function get popupButton():Object
+		{
+			return button;
+		}
+		
+		private var list:IUIBase;
+		
+		/**
+		 *  The pop-up component of the ComboBox.
+		 * 
+		 *  @copy org.apache.royale.html.beads.IComboBoxView#text
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function get popUp():Object
+		{
+			return list;
+		}
+		
+		/**
+		 * @private
+		 * @royaleignorecoercion org.apache.royale.events.IEventDispatcher
+		 * @royaleignorecoercion org.apache.royale.core.UIBase
+		 */
+		override public function set strand(value:IStrand):void
+		{
+			super.strand = value;
+			
+			var host:UIBase = value as UIBase;
+			
+			selectedColorDisplay = new Group();
+			(selectedColorDisplay as IStyleableObject).className = "ColorPickerDisplayedColor";			
+			
+			button = new TextButton();
+			button.style = {
+				"padding": 0,
+				"margin": 0
+			};
+			button.text = '\u25BC';
+			
+			if (isNaN(host.width)) selectedColorDisplay.width = 25;
+			
+			COMPILE::JS 
+			{
+				// inner components are absolutely positioned so we want to make sure the host is the offset parent
+				if (!host.element.style.position)
+				{
+					host.element.style.position = "relative";
+				}
+			}
+			host.addElement(selectedColorDisplay);
+			host.addElement(button);
+			
+            loadBeadFromValuesManager(IPopUp, "iPopUp", _strand);
+			list = _strand.getBeadByType(IColorPickerPopUp) as IUIBase;
+			list.visible = false;
+			
+			var model:IEventDispatcher = (_strand as IStrandWithModel).model as IEventDispatcher;
+			(list as IColorPickerPopUp).model = model;
+			model.addEventListener("change", handleColorChange);
+			
+			IEventDispatcher(_strand).addEventListener("sizeChanged", handleSizeChange);
+			
+			// set initial value and positions using default sizes
+			colorChangeAction();
+			sizeChangeAction();
+		}
+		
+		/**
+		 *  Returns whether or not the pop-up is visible.
+		 * 
+		 *  @copy org.apache.royale.html.beads.IComboBoxView#text
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.6
+		 */
+		public function get popUpVisible():Boolean
+		{
+			if (list) return list.visible;
+			else return false;
+		}
+
+		/**
+		 * @royaleignorecoercion org.apache.royale.core.IComboBoxModel
+		 * @royaleignorecoercion org.apache.royale.core.IUIBase
+		 */
+		public function set popUpVisible(value:Boolean):void
+		{
+			if (value && !list.visible) {
+      	var model:IColorModel = getModelByType(_strand,IColorModel) as IColorModel;
+				(list as IColorPickerPopUp).model = model;
+				list.visible = true;
+				
+				var origin:Point = new Point(0, button.y+button.height);
+				var relocated:Point = PointUtils.localToGlobal(origin,_strand);
+				list.x = relocated.x
+				list.y = relocated.y;
+				COMPILE::JS {
+					(list as IRenderedObject).element.style.position = "absolute";
+				}
+					
+				var popupHost:IPopUpHost = UIUtils.findPopUpHost(_strand as IUIBase);
+				popupHost.popUpParent.addElement(list);
+			}
+			else if (list.visible) {
+				UIUtils.removePopUp(list);
+				list.visible = false;
+			}
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function handleSizeChange(event:Event):void
+		{
+			sizeChangeAction();
+		}
+		
+		/**
+		 * @private
+		 */
+		protected function handleColorChange(event:Event):void
+		{
+			colorChangeAction();
+		}
+		
+		/**
+		 * @private
+		 * @royaleignorecoercion org.apache.royale.core.IColorModel
+		 */
+		protected function colorChangeAction():void
+		{
+			var model:IColorModel = getModelByType(_strand,IColorModel) as IColorModel;
+			COMPILE::JS 
+			{
+				selectedColorDisplay.element.style.backgroundColor = CSSUtils.attributeFromColor(model.color);
+			}
+		}
+		
+		/**
+		 * @private
+		 * @royaleignorecoercion org.apache.royale.core.UIBase
+		 */
+		protected function sizeChangeAction():void
+		{
+			var host:UIBase = UIBase(_strand);
+			
+			selectedColorDisplay.x = 0;
+			selectedColorDisplay.y = 0;
+			selectedColorDisplay.height = 20;
+			if (host.isWidthSizedToContent()) {
+				selectedColorDisplay.width = 25;
+			} else {
+				selectedColorDisplay.width = host.width - 20;
+			}
+
+			button.x = selectedColorDisplay.width;
+			button.y = 0;
+			button.width = 20;
+			button.height = selectedColorDisplay.height;
+			
+			COMPILE::JS {
+				selectedColorDisplay.element.style.position = "absolute";
+				button.element.style.position = "absolute";
+			}
+				
+			if (host.isHeightSizedToContent()) {
+				host.height = selectedColorDisplay.height;
+			}
+			if (host.isWidthSizedToContent()) {
+				host.width = selectedColorDisplay.width + button.width;
+			}
+		}
+	}
+}
\ No newline at end of file


[royale-asjs] 03/03: Emulation - add change event to ColorPicker

Posted by yi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7748faddb76986068d201185df2b895c10a91153
Author: Yishay Weiss <yi...@hotmail.com>
AuthorDate: Wed Nov 23 13:32:45 2022 +0200

    Emulation - add change event to ColorPicker
---
 frameworks/projects/MXRoyale/src/main/resources/defaults.css           | 2 +-
 frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as        | 1 +
 .../MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as      | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index b9e881aaff..a181ee9d2a 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -208,7 +208,7 @@ CheckBox
 ColorPicker
 {
 	IBeadModel: ClassReference("org.apache.royale.html.beads.models.ArrayListColorSelectionModel");
-	IBeadView: ClassReference("org.apache.royale.html.beads.ColorPickerView");
+	IBeadView: ClassReference("mx.controls.beads.ColorPickerView");
 	IBeadController: ClassReference("org.apache.royale.html.beads.controllers.ComboBoxController");
 	IPopUp: ClassReference("mx.controls.beads.ColorPickerPopUp");
 }
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index bf581a3f38..b64f43d1da 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -436,6 +436,7 @@ internal class MXRoyaleClasses
 
 
 	import mx.controls.SimpleTextHighlighter;SimpleTextHighlighter;
+	import mx.controls.beads.ColorPickerView; ColorPickerView;
 }
 
 }
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as
index 4ba61cc499..92623545b5 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/ColorPickerView.as
@@ -44,6 +44,8 @@ package mx.controls.beads
 	import org.apache.royale.core.IColorModel;
     import org.apache.royale.core.IPopUp;
     import org.apache.royale.html.util.getModelByType;
+    import mx.events.ColorPickerEvent;
+    import org.apache.royale.html.beads.IComboBoxView;
 	
 	/**
 	 *  The ColorPickerView class creates the visual elements of the org.apache.royale.html.ColorPicker 
@@ -221,6 +223,7 @@ package mx.controls.beads
 		protected function handleColorChange(event:Event):void
 		{
 			colorChangeAction();
+			(_strand as IEventDispatcher).dispatchEvent(new ColorPickerEvent("change"));
 		}
 		
 		/**