[ease/themes] [general] Simplify saving/loading of colors.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/themes] [general] Simplify saving/loading of colors.
- Date: Fri, 23 Jul 2010 21:36:39 +0000 (UTC)
commit 2b8eb9f7ae4b0e7d3d08cdb1bcd589c80b9894d9
Author: Nate Stedman <natesm gmail com>
Date: Fri Jul 23 17:36:01 2010 -0400
[general] Simplify saving/loading of colors.
- Instead of r/g/b properties, a single property.
examples/Transitions/Document.json | 216 +++++++++---------------------------
src/ease-json-parser.vala | 21 +---
src/ease-text-element.vala | 9 +-
3 files changed, 61 insertions(+), 185 deletions(-)
---
diff --git a/examples/Transitions/Document.json b/examples/Transitions/Document.json
index a23095b..f442136 100644
--- a/examples/Transitions/Document.json
+++ b/examples/Transitions/Document.json
@@ -3,7 +3,7 @@
"slides" : [
{
"transition" : "1",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -18,12 +18,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -37,24 +35,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "2",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "2",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -69,12 +63,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -88,24 +80,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "3",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -120,12 +108,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -139,24 +125,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "4",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "7",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -171,12 +153,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -190,24 +170,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "5",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "13",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -222,12 +198,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -241,24 +215,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "6",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "2",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -273,12 +243,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -292,24 +260,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "7",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -324,12 +288,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -343,24 +305,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "8",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -375,12 +333,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -394,24 +350,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "10",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -426,12 +378,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -445,24 +395,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "11",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "6",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -477,12 +423,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -496,24 +440,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "12",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -528,12 +468,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -547,24 +485,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "13",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "2",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -579,12 +513,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -598,24 +530,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "15",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -630,12 +558,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -649,24 +575,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "16",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -681,12 +603,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -700,24 +620,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "14",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -732,12 +648,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -751,24 +665,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "17",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "15",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -783,12 +693,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -802,24 +710,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
},
{
"transition" : "9",
- "green" : "34",
+ "background-color" : "#222222FF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -834,12 +738,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "900",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -853,24 +755,20 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "255",
"text-align" : "left",
"width" : "964",
- "blue" : "255",
"text-weight" : "500",
- "red" : "255",
+ "text-color" : "#FFFFFFFF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "34",
"title" : "Standard",
- "red" : "34",
"transition_time" : "1"
},
{
"transition" : "0",
- "green" : "255",
+ "background-color" : "#FFFFFFFF",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -885,12 +783,10 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "header-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "900",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -904,19 +800,15 @@
"element_type" : "EaseTextElement",
"has_been_edited" : "true",
"identifier" : "content-text",
- "green" : "34",
"text-align" : "left",
"width" : "964",
- "blue" : "34",
"text-weight" : "500",
- "red" : "34",
+ "text-color" : "#222222FF",
"text-font" : "Sans",
"text-size" : "16"
}
],
- "blue" : "255",
"title" : "Standard",
- "red" : "255",
"transition_time" : "1"
}
],
diff --git a/src/ease-json-parser.vala b/src/ease-json-parser.vala
index 14fb45a..7d4c30e 100644
--- a/src/ease-json-parser.vala
+++ b/src/ease-json-parser.vala
@@ -89,16 +89,9 @@ public static class Ease.JSONParser
}
else
{
- slide.background_color.red =
- (uchar)(obj.get_string_member("red").to_int());
-
- slide.background_color.green =
- (uchar)(obj.get_string_member("green").to_int());
-
- slide.background_color.blue =
- (uchar)(obj.get_string_member("blue").to_int());
-
- slide.background_color.alpha = 255;
+ slide.background_color =
+ Clutter.Color.from_string(
+ obj.get_string_member(Theme.BACKGROUND_COLOR));
}
// parse the elements
@@ -201,12 +194,8 @@ public static class Ease.JSONParser
}
else
{
- obj.set_string_member("red",
- slide.background_color.red.to_string());
- obj.set_string_member("green",
- slide.background_color.green.to_string());
- obj.set_string_member("blue",
- slide.background_color.blue.to_string());
+ obj.set_string_member(Theme.BACKGROUND_COLOR,
+ slide.background_color.to_string());
}
// add the slide's elements
diff --git a/src/ease-text-element.vala b/src/ease-text-element.vala
index 8f101d9..3039c58 100644
--- a/src/ease-text-element.vala
+++ b/src/ease-text-element.vala
@@ -145,16 +145,11 @@ public class Ease.TextElement : Element
{
get
{
- return { (uchar)data.get("red").to_int(),
- (uchar)data.get("green").to_int(),
- (uchar)data.get("blue").to_int(),
- 255};
+ return Clutter.Color.from_string(data.get(Theme.TEXT_COLOR));
}
set
{
- data.set("red", ((int)value.red).to_string());
- data.set("green", ((int)value.green).to_string());
- data.set("blue", ((int)value.blue).to_string());
+ data.set(Theme.TEXT_COLOR, value.to_string());
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]