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/11/08 09:36:32 UTC

[royale-asjs] branch develop updated: Add ColorPickerExample

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


The following commit(s) were added to refs/heads/develop by this push:
     new 4544185  Add ColorPickerExample
4544185 is described below

commit 454418585e9e7a19635d87ddbac95e75509f3243
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Fri Nov 8 11:36:13 2019 +0200

    Add ColorPickerExample
---
 .../royale/ColorPickerExample/HelloWorld.as3proj   | 89 ++++++++++++++++++++
 examples/royale/ColorPickerExample/asconfig.json   | 31 +++++++
 examples/royale/ColorPickerExample/build.xml       | 54 ++++++++++++
 examples/royale/ColorPickerExample/pom.xml         | 97 ++++++++++++++++++++++
 .../src/main/royale/ColorPicker.mxml               | 51 ++++++++++++
 .../src/main/royale/ColorPickerPopUpWithPalette.as | 53 ++++++++++++
 6 files changed, 375 insertions(+)

diff --git a/examples/royale/ColorPickerExample/HelloWorld.as3proj b/examples/royale/ColorPickerExample/HelloWorld.as3proj
new file mode 100644
index 0000000..65df891
--- /dev/null
+++ b/examples/royale/ColorPickerExample/HelloWorld.as3proj
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+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.
+
+-->
+<project>
+  <output>
+    <movie version="11"/>
+    <movie disabled="False"/>
+    <movie height="600"/>
+    <movie fps="60"/>
+    <movie background="#FFFFFF"/>
+    <movie path="bin-debug/ColorPicker.swf"/>
+    <movie width="800"/>
+    <movie input=""/>
+  </output>
+  &lt;!-- Other classes to be compiled into your SWF --&gt;
+  <classpaths>
+    <class path="src/main/royale"/>
+  </classpaths>
+  <moonshineResourcePaths></moonshineResourcePaths>
+  <build>
+    <option customSDK=""/>
+    <option strict="True"/>
+    <option accessible="False"/>
+    <option useNetwork="True"/>
+    <option allowSourcePathOverlap="False"/>
+    <option useResourceBundleMetadata="True"/>
+    <option benchmark="False"/>
+    <option warnings="True"/>
+    <option additional=""/>
+    <option es="False"/>
+    <option locale=""/>
+    <option loadConfig=""/>
+    <option linkReport=""/>
+    <option optimize="False"/>
+    <option verboseStackTraces="False"/>
+    <option staticLinkRSL="False"/>
+    <option showBindingWarnings="True"/>
+    <option compilerConstants=""/>
+    <option showDeprecationWarnings="True"/>
+    <option antBuildPath="build/build.xml"/>
+    <option showActionScriptWarnings="True"/>
+    <option showUnusedTypeSelectorWarnings="True"/>
+  </build>
+  <includeLibraries></includeLibraries>
+  <libraryPaths></libraryPaths>
+  <externalLibraryPaths></externalLibraryPaths>
+  <rslPaths></rslPaths>
+  <intrinsics></intrinsics>
+  <library></library>
+  <compileTargets>
+    <compile path="src/main/royale/ColorPicker.mxml"/>
+  </compileTargets>
+  <hiddenPaths></hiddenPaths>
+  <preBuildCommand>null</preBuildCommand>
+  <postBuildCommand alwaysRun="False">null</postBuildCommand>
+  <options>
+    <option defaultBuildTargets=""/>
+    <option testMovie=""/>
+    <option testMovieCommand=""/>
+    <option showHiddenPaths="False"/>
+  </options>
+  <moonshineRunCustomization>
+    <option deviceSimulator="null"/>
+    <option targetPlatform="2"/>
+    <option projectType="2"/>
+    <option launchMethod="Simulator"/>
+    <option urlToLaunch=""/>
+    <deviceSimulator>null</deviceSimulator>
+    <certAndroid>null</certAndroid>
+    <certIos>null</certIos>
+    <certIosProvisioning>null</certIosProvisioning>
+  </moonshineRunCustomization>
+</project>
diff --git a/examples/royale/ColorPickerExample/asconfig.json b/examples/royale/ColorPickerExample/asconfig.json
new file mode 100644
index 0000000..d6a0245
--- /dev/null
+++ b/examples/royale/ColorPickerExample/asconfig.json
@@ -0,0 +1,31 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+////////////////////////////////////////////////////////////////////////////////
+{
+    "config": "royale",
+    "compilerOptions": {
+        "debug": false,
+        "targets": ["JSRoyale","SWF"],
+        "source-map": true
+    },
+    "additionalOptions": "-remove-circulars -js-output-optimization=skipAsCoercions",
+    "files":
+    [
+        "src/main/royale/ColorPicker.mxml"
+    ]
+}
diff --git a/examples/royale/ColorPickerExample/build.xml b/examples/royale/ColorPickerExample/build.xml
new file mode 100644
index 0000000..a1007cf
--- /dev/null
+++ b/examples/royale/ColorPickerExample/build.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+
+  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.
+
+-->
+
+
+<project name="colorpicker" default="main" basedir=".">
+    <property name="ROYALE_HOME" location="../../.."/>
+    <property name="example" value="ColorPicker" />
+    
+    <property file="${ROYALE_HOME}/env.properties"/>
+    <property environment="env"/>
+    <property file="${ROYALE_HOME}/build.properties"/>
+    <property name="ROYALE_HOME" value="${ROYALE_HOME}"/>
+
+    <include file="${basedir}/../../build_example.xml" />
+    
+    <target name="main" depends="clean,build_example.compile" description="Clean build of ${example}">
+    </target>
+    
+    <target name="clean">
+        <delete dir="${basedir}/bin" failonerror="false" />
+        <delete dir="${basedir}/bin-debug" failonerror="false" />
+        <delete dir="${basedir}/bin-release" failonerror="false" />
+        <delete dir="${basedir}/target" failonerror="false" />
+    </target>
+
+    <target name="examine" depends="build_example.get.browser">
+        <property name="which" value="debug" />
+        <echo message="Make sure label appears."/>
+        <exec executable="${browser}" dir="${basedir}/bin-${which}" failonerror="true">
+            <arg value="${basedir}/bin-${which}/${example}.html"/>
+        </exec>
+        <exec executable="${browser}" dir="${basedir}/bin/js-${which}" failonerror="true">
+            <arg value="${basedir}/bin/js-${which}/index.html"/>
+        </exec>
+    </target>
+
+</project>
diff --git a/examples/royale/ColorPickerExample/pom.xml b/examples/royale/ColorPickerExample/pom.xml
new file mode 100644
index 0000000..4becb1d
--- /dev/null
+++ b/examples/royale/ColorPickerExample/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+  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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.royale.examples</groupId>
+    <artifactId>examples-royale</artifactId>
+    <version>0.9.7-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>ColorPicker</artifactId>
+  <version>0.9.7-SNAPSHOT</version>
+  <packaging>swf</packaging>
+
+  <name>Apache Royale: Examples: Royale: ColorPicker</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.royale.compiler</groupId>
+        <artifactId>royale-maven-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <mainClass>ColorPicker.mxml</mainClass>
+          <additionalCompilerOptions>
+            -js-complex-implicit-coercions=false;
+            -js-vector-index-checks=false;
+            -js-resolve-uncertain=false;
+          </additionalCompilerOptions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <profiles>
+      <profile>
+          <id>swf-dependencies</id>
+          <activation>
+              <property>
+                  <name>generate.swf</name>
+              </property>
+          </activation>
+          <dependencies>
+              <dependency>
+                  <groupId>org.apache.royale.framework</groupId>
+                  <artifactId>Basic</artifactId>
+                  <version>0.9.7-SNAPSHOT</version>
+                  <type>swc</type>
+                  <classifier>swf</classifier>
+              </dependency>
+              <dependency>
+                  <groupId>com.adobe.flash.framework</groupId>
+                  <artifactId>playerglobal</artifactId>
+                  <version>${flash.version}</version>
+                  <type>swc</type>
+                  <scope>provided</scope>
+              </dependency>
+          </dependencies>
+      </profile>
+  </profiles>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.royale.framework</groupId>
+      <artifactId>Basic</artifactId>
+      <version>0.9.7-SNAPSHOT</version>
+      <type>swc</type>
+      <classifier>js</classifier>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.royale.framework</groupId>
+      <artifactId>BasicTheme</artifactId>
+      <version>0.9.7-SNAPSHOT</version>
+      <type>swc</type>
+      <scope>theme</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/examples/royale/ColorPickerExample/src/main/royale/ColorPicker.mxml b/examples/royale/ColorPickerExample/src/main/royale/ColorPicker.mxml
new file mode 100644
index 0000000..0fa702d
--- /dev/null
+++ b/examples/royale/ColorPickerExample/src/main/royale/ColorPicker.mxml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+				applicationComplete="application1_applicationCompleteHandler(event)"
+				xmlns:js="library://ns.apache.org/royale/basic"
+				xmlns:local="*"
+				>
+	<fx:Script>
+		<![CDATA[
+			import org.apache.royale.html.Container;
+			private var newContainer:Container;
+
+			protected function application1_applicationCompleteHandler(event:Event):void
+			{
+				var dp:Array = [];
+				for (var i:int = 0; i < 30; i++)
+				{
+					var color:uint = uint(Math.random() * 0xFFFFFF);
+					dp.push(color);
+				}
+				arrayColorSelectionModel.dataProvider = dp;
+			}
+			
+			private function changeHandler():void
+			{
+//				myColorSpectrum.baseColor = uint(myColorPicker.selectedItem);
+			}
+
+			private function newColorHandler():void
+			{
+				
+			}
+			
+		]]>
+	</fx:Script>
+	
+	<js:valuesImpl>
+		<js:SimpleCSSValuesImpl />
+	</js:valuesImpl>	
+	
+	<js:initialView>
+		<js:View id="myView">
+			<js:ColorPicker change="changeHandler()" id="myColorPicker">
+				<js:beads>
+					<js:ArrayColorSelectionModel id="arrayColorSelectionModel"/>
+					<local:ColorPickerPopUpWithPalette/>
+					<js:ColorPickerWithEmptyView/>
+				</js:beads>
+			</js:ColorPicker>
+		</js:View>
+	</js:initialView>
+</js:Application>
diff --git a/examples/royale/ColorPickerExample/src/main/royale/ColorPickerPopUpWithPalette.as b/examples/royale/ColorPickerExample/src/main/royale/ColorPickerPopUpWithPalette.as
new file mode 100644
index 0000000..5d1db54
--- /dev/null
+++ b/examples/royale/ColorPickerExample/src/main/royale/ColorPickerPopUpWithPalette.as
@@ -0,0 +1,53 @@
+package 
+{
+	import org.apache.royale.events.Event;
+	import org.apache.royale.events.IEventDispatcher;
+	import org.apache.royale.html.beads.HideColorSpectrumThumbWhenEmpty;
+	import org.apache.royale.html.beads.layouts.TileLayout;
+	import org.apache.royale.html.supportClasses.ColorPalette;
+	import org.apache.royale.html.supportClasses.ColorPickerPopUp;
+	import org.apache.royale.core.IColorSpectrumModel;
+	import org.apache.royale.utils.loadBeadFromValuesManager;
+
+	public class ColorPickerPopUpWithPalette extends ColorPickerPopUp
+	{
+		protected var colorPalette:ColorPalette;
+		public function ColorPickerPopUpWithPalette()
+		{
+			super();
+			colorSpectrum.addBead(new HideColorSpectrumThumbWhenEmpty());
+			style = {padding: 10};
+			colorPalette = new ColorPalette();
+			var colorPaletteLayout:TileLayout = loadBeadFromValuesManager(TileLayout, "iBeadLayout", colorPalette) as TileLayout;
+			colorPaletteLayout.rowHeight = colorPaletteLayout.columnWidth = 30;
+			var pwidth:Number = 100;
+			var margin:Number = 10;
+			colorPalette.width =  pwidth;
+			colorSpectrum.x = pwidth + margin;
+			COMPILE::JS 
+			{
+				colorSpectrum.element.style.position = "absolute";
+			}
+			hueSelector.x += pwidth + margin;
+			
+		}
+		
+		override public function set model(value:Object):void
+		{
+			super.model = value;
+			colorPalette.model = value;
+			(value as IEventDispatcher).addEventListener("change", changeHandler);
+			
+			if (getElementIndex(colorPalette) < 0)
+			{
+				addElement(colorPalette);
+			}
+		}
+		
+		private function changeHandler(event:org.apache.royale.events.Event):void
+		{
+			var model:IColorSpectrumModel = colorSpectrum.model as IColorSpectrumModel;
+			model.baseColor = model.hsvModifiedColor = colorPalette.selectedItem as Number;
+		}
+	}
+}