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/12 13:48:13 UTC
[royale-asjs] branch color_picker updated: Added ColorPicker as a
combobox derivative.
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 d65b3ac Added ColorPicker as a combobox derivative.
d65b3ac is described below
commit d65b3ac39e26d57128231f17d4618434c22171d1
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Tue Mar 12 15:46:59 2019 +0200
Added ColorPicker as a combobox derivative.
---
.../Basic/src/main/resources/basic-manifest.xml | 3 +-
.../projects/Basic/src/main/resources/defaults.css | 8 +++
.../projects/Basic/src/main/royale/BasicClasses.as | 1 +
.../royale/html/{SwatchList.as => ColorPicker.as} | 14 ++--
.../apache/royale/html/beads/ColorPickerView.as | 78 ++++++++++++++++++++++
.../royale/html/{ => supportClasses}/SwatchList.as | 7 +-
6 files changed, 102 insertions(+), 9 deletions(-)
diff --git a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
index 1a0775a..0f80e7a 100644
--- a/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Basic/src/main/resources/basic-manifest.xml
@@ -48,7 +48,8 @@
<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="SwatchList" class="org.apache.royale.html.supportClasses.SwatchList"/>
+ <component id="ColorPicker" class="org.apache.royale.html.ColorPicker"/>
<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"/>
diff --git a/frameworks/projects/Basic/src/main/resources/defaults.css b/frameworks/projects/Basic/src/main/resources/defaults.css
index 875f0c6..eb74391 100644
--- a/frameworks/projects/Basic/src/main/resources/defaults.css
+++ b/frameworks/projects/Basic/src/main/resources/defaults.css
@@ -59,6 +59,14 @@ ButtonBar
border-style: none;
}
+ColorPicker
+{
+ IBeadModel: ClassReference("org.apache.royale.html.beads.models.ComboBoxModel");
+ IBeadView: ClassReference("org.apache.royale.html.beads.ColorPickerView");
+ IBeadController: ClassReference("org.apache.royale.html.beads.controllers.ComboBoxController");
+ IPopUp: ClassReference("org.apache.royale.html.supportClasses.SwatchList");
+}
+
ComboBox
{
IBeadModel: ClassReference("org.apache.royale.html.beads.models.ComboBoxModel");
diff --git a/frameworks/projects/Basic/src/main/royale/BasicClasses.as b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
index beabf2e..c1871f8 100644
--- a/frameworks/projects/Basic/src/main/royale/BasicClasses.as
+++ b/frameworks/projects/Basic/src/main/royale/BasicClasses.as
@@ -81,6 +81,7 @@ internal class BasicClasses
import org.apache.royale.html.beads.CheckBoxView; CheckBoxView;
}
import org.apache.royale.html.beads.ComboBoxView; ComboBoxView;
+ import org.apache.royale.html.beads.ColorPickerView; ColorPickerView;
import org.apache.royale.html.MXMLBeadView; MXMLBeadView;
import org.apache.royale.html.beads.GroupView; GroupView;
import org.apache.royale.html.beads.ContainerView; ContainerView;
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/ColorPicker.as
similarity index 80%
copy from frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as
copy to frameworks/projects/Basic/src/main/royale/org/apache/royale/html/ColorPicker.as
index 50c9d2a..e9aa511 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/ColorPicker.as
@@ -18,30 +18,30 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.html
{
-
/**
- * The SwatchList class is use in a ColorPicker. It contains a list of predefined colors.
+ * The ColorPicker class is a component that displays an input field and
+ * pop-up List with some optional controls, such as a swatch and a color gradient.
*
- *
- * @toplevel
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.9.6
*/
- public class SwatchList extends List
+ public class ColorPicker extends ComboBox
{
/**
- * constructor.
+ * Constructor.
*
* @langversion 3.0
* @playerversion Flash 10.2
* @playerversion AIR 2.6
* @productversion Royale 0.9.6
*/
- public function SwatchList()
+ public function ColorPicker()
{
super();
+
+ typeNames = "ColorPicker";
}
}
}
diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorPickerView.as b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorPickerView.as
new file mode 100644
index 0000000..eac6c12
--- /dev/null
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/ColorPickerView.as
@@ -0,0 +1,78 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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
+{
+ import org.apache.royale.core.IComboBoxModel;
+ import org.apache.royale.core.IPopUpHost;
+ import org.apache.royale.core.IUIBase;
+ import org.apache.royale.core.UIBase;
+ import org.apache.royale.geom.Point;
+ import org.apache.royale.utils.PointUtils;
+ import org.apache.royale.utils.UIUtils;
+
+ /**
+ * 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 ColorPicler such as the TextInput
+ * control 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 ComboBoxView
+ {
+ public function ColorPickerView()
+ {
+ super();
+ }
+
+ /**
+ * @royaleignorecoercion org.apache.royale.core.IComboBoxModel
+ * @royaleignorecoercion org.apache.royale.core.IUIBase
+ */
+ override public function set popUpVisible(value:Boolean):void
+ {
+ var list:UIBase = popUp as UIBase;
+ var button:UIBase = popupButton as UIBase;
+ if (value && !list.visible) {
+ var model:IComboBoxModel = _strand.getBeadByType(IComboBoxModel) as IComboBoxModel;
+ list.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.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;
+ }
+ }
+ }
+}
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/supportClasses/SwatchList.as
similarity index 92%
rename from frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as
rename to frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
index 50c9d2a..faab9d5 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/SwatchList.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/supportClasses/SwatchList.as
@@ -16,8 +16,9 @@
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
-package org.apache.royale.html
+package org.apache.royale.html.supportClasses
{
+ import org.apache.royale.html.List;
/**
* The SwatchList class is use in a ColorPicker. It contains a list of predefined colors.
@@ -42,6 +43,10 @@ package org.apache.royale.html
public function SwatchList()
{
super();
+ if (!width)
+ {
+ width = 300;
+ }
}
}
}