You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2009/09/08 14:09:54 UTC

svn commit: r812476 - in /incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials: KitchenSink.java TerraTheme_dark.json

Author: smartini
Date: Tue Sep  8 12:09:54 2009
New Revision: 812476

URL: http://svn.apache.org/viewvc?rev=812476&view=rev
Log:
PIVOT-243: Add Startup Property in KitchenSink Tutorial to load a custom json file for the Skin Colors to use

Added:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/TerraTheme_dark.json
Modified:
    incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java

Modified: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java?rev=812476&r1=812475&r2=812476&view=diff
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java (original)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/KitchenSink.java Tue Sep  8 12:09:54 2009
@@ -67,6 +67,7 @@
 import org.apache.pivot.wtk.TableView;
 import org.apache.pivot.wtk.TableViewHeader;
 import org.apache.pivot.wtk.TextArea;
+import org.apache.pivot.wtk.Theme;
 import org.apache.pivot.wtk.TreeView;
 import org.apache.pivot.wtk.Visual;
 import org.apache.pivot.wtk.Window;
@@ -80,6 +81,7 @@
 import org.apache.pivot.wtk.effects.ReflectionDecorator;
 import org.apache.pivot.wtk.effects.WatermarkDecorator;
 import org.apache.pivot.wtk.media.Image;
+import org.apache.pivot.wtk.skin.terra.TerraTheme;
 import org.apache.pivot.wtk.text.Document;
 import org.apache.pivot.wtk.text.PlainTextSerializer;
 import org.apache.pivot.wtkx.WTKXSerializer;
@@ -903,6 +905,22 @@
 
     @Override
     public void startup(Display display, Map<String, String> properties) throws Exception {
+        
+        // if the (optional) argument terraColors has been given from the command line, 
+        // use it to load a custom Color definition for the Terra skin.
+        // example: --terraColors=org/apache/pivot/wtk/skin/terra/TerraTheme_test.json
+        // example: --terraColors=org/apache/pivot/tutorials/TerraTheme_dark.json
+        String terraCustomColorsFile = properties.get("terraColors");
+        try {
+            if (terraCustomColorsFile != null) {
+                Theme.setTheme(new TerraTheme(terraCustomColorsFile));
+                System.out.println("Terra Custom Colors File successfully loaded."); 
+            }
+        } catch (Exception exception) {
+            System.err.println("Unable to Load Terra Custom Colors File from \"" 
+                + terraCustomColorsFile + "\": " + exception.getMessage());
+        }
+
         WTKXSerializer wtkxSerializer = new WTKXSerializer();
         window = (Window)wtkxSerializer.readObject(this, "kitchen_sink.wtkx");
         wtkxSerializer.bind(this, KitchenSink.class);

Added: incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/TerraTheme_dark.json
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/TerraTheme_dark.json?rev=812476&view=auto
==============================================================================
--- incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/TerraTheme_dark.json (added)
+++ incubator/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/TerraTheme_dark.json Tue Sep  8 12:09:54 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+{   font: "Verdana 11",
+
+    colors: [
+    	// hex color // number of this color in the generated palette [0..23] and description of its usage in TerraTheme
+        "#f2f2f2",  //  1: foreground for label etc
+        "#2b2b2b",  //  4: background for groups
+        "#998e8a",  //  7: borders, and some disabled elements
+        "#0a0a0a",  // 10: background in input elements, tabs, etc  // (overridden in KitchenSink) this + 10% for background (= #242424)
+        "#f0751c",  // 13: selection, link, expanders text, and labels (overridden in KitchenSink)
+        "#ff7300",  // 16: background in option buttons, title bars, etc
+        "#f08234",  // 19: selection background
+        "#c13719"   // 22: errors, invalid elements, etc
+    ]
+ }