[ease] [general] Use Ease.Color in documents and slides
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [general] Use Ease.Color in documents and slides
- Date: Sat, 24 Jul 2010 05:11:24 +0000 (UTC)
commit f54e44cb91068f4c7396a3db31b6fc4694834709
Author: Nate Stedman <natesm gmail com>
Date: Sat Jul 24 01:10:22 2010 -0400
[general] Use Ease.Color in documents and slides
- Theme and document color format when saved is now Ease.Color format.
data/theme-defaults.json | 4 +-
examples/Transitions/Document.json | 108 ++++++++++++++++++------------------
src/ease-color.vala | 15 +++--
src/ease-json-parser.vala | 2 +-
src/ease-slide-actor.vala | 5 +-
src/ease-slide.vala | 9 +--
src/ease-text-actor.vala | 4 +-
src/ease-text-element.vala | 14 ++---
src/ease-theme.vala | 6 +-
themes/Black/Theme.json | 4 +-
10 files changed, 86 insertions(+), 85 deletions(-)
---
diff --git a/data/theme-defaults.json b/data/theme-defaults.json
index 464741a..22d1c3c 100644
--- a/data/theme-defaults.json
+++ b/data/theme-defaults.json
@@ -1,6 +1,6 @@
{
"master-defaults" : {
- "background-color" : "#FFFFFFFF"
+ "background-color" : "1, 1, 1"
},
"element-defaults" : {
@@ -10,7 +10,7 @@
"text-variant" : "Normal",
"text-weight" : "500",
"text-align" : "left",
- "text-color" : "#000000FF",
+ "text-color" : "0, 0, 0",
"padding-top" : "30",
"padding-left" : "30",
diff --git a/examples/Transitions/Document.json b/examples/Transitions/Document.json
index f442136..883fc69 100644
--- a/examples/Transitions/Document.json
+++ b/examples/Transitions/Document.json
@@ -3,7 +3,7 @@
"slides" : [
{
"transition" : "1",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -21,7 +21,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -38,7 +38,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -48,7 +48,7 @@
},
{
"transition" : "2",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "2",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -66,7 +66,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -83,7 +83,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -93,7 +93,7 @@
},
{
"transition" : "3",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -111,7 +111,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -128,7 +128,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -138,7 +138,7 @@
},
{
"transition" : "4",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "7",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -156,7 +156,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -173,7 +173,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -183,7 +183,7 @@
},
{
"transition" : "5",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "13",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -201,7 +201,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -218,7 +218,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -228,7 +228,7 @@
},
{
"transition" : "6",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "2",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -246,7 +246,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -263,7 +263,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -273,7 +273,7 @@
},
{
"transition" : "7",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -291,7 +291,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -308,7 +308,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -318,7 +318,7 @@
},
{
"transition" : "8",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -336,7 +336,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -353,7 +353,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -363,7 +363,7 @@
},
{
"transition" : "10",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -381,7 +381,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -398,7 +398,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -408,7 +408,7 @@
},
{
"transition" : "11",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "6",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -426,7 +426,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -443,7 +443,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -453,7 +453,7 @@
},
{
"transition" : "12",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -471,7 +471,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -488,7 +488,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -498,7 +498,7 @@
},
{
"transition" : "13",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "2",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -516,7 +516,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -533,7 +533,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -543,7 +543,7 @@
},
{
"transition" : "15",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -561,7 +561,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -578,7 +578,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -588,7 +588,7 @@
},
{
"transition" : "16",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -606,7 +606,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -623,7 +623,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -633,7 +633,7 @@
},
{
"transition" : "14",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -651,7 +651,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -668,7 +668,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -678,7 +678,7 @@
},
{
"transition" : "17",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "15",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -696,7 +696,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -713,7 +713,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -723,7 +723,7 @@
},
{
"transition" : "9",
- "background-color" : "#222222FF",
+ "background-color" : "0.13, 0.13, 0.13, 0.13",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -741,7 +741,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -758,7 +758,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#FFFFFFFF",
+ "text-color" : "1.0, 1.0, 1.0, 1.0",
"text-font" : "Sans",
"text-size" : "16"
}
@@ -768,7 +768,7 @@
},
{
"transition" : "0",
- "background-color" : "#FFFFFFFF",
+ "background-color" : "1.0, 1.0, 1.0, 1.0",
"variant" : "0",
"automatically_advance" : "true",
"advance_delay" : "0.5",
@@ -786,7 +786,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "900",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "36"
},
@@ -803,7 +803,7 @@
"text-align" : "left",
"width" : "964",
"text-weight" : "500",
- "text-color" : "#222222FF",
+ "text-color" : "0.13, 0.13, 0.13, 0.13",
"text-font" : "Sans",
"text-size" : "16"
}
diff --git a/src/ease-color.vala b/src/ease-color.vala
index ddf5303..e0b0fc2 100644
--- a/src/ease-color.vala
+++ b/src/ease-color.vala
@@ -23,12 +23,12 @@ public class Ease.Color : GLib.Object
/**
* The format string for converting Colors to strings.
*/
- private const string STR = "%f%s%f%s%f%s%f";
+ private const string STR = "%f%s %f%s %f%s %f";
/**
* The string placed between each channel in a string representation.
*/
- private const string SPLIT = ", ";
+ private const string SPLIT = ",";
/**
* The red value of this color.
@@ -219,11 +219,14 @@ public class Ease.Color : GLib.Object
*/
public Color.from_string(string str)
{
- var split = str.split(SPLIT);
+ var split = str.replace(" ", "").split(SPLIT);
red = split[0].to_double();
green = split[1].to_double();
blue = split[2].to_double();
- alpha = split[3].to_double();
+
+ // it's ok to omit the alpha value - assumes full alpha
+ if (split.length > 3) alpha = split[3].to_double();
+ else alpha = 1;
}
/**
@@ -231,7 +234,7 @@ public class Ease.Color : GLib.Object
*/
public string to_string()
{
- return STR.printf(red, SPLIT, blue, SPLIT, green, SPLIT, alpha, SPLIT);
+ return STR.printf(red, SPLIT, blue, SPLIT, green, SPLIT, alpha);
}
/**
@@ -239,7 +242,7 @@ public class Ease.Color : GLib.Object
*
* @param cr The Cairo Context to set the color for.
*/
- public void cairo_set(Cairo.Context cr)
+ public void set_cairo(Cairo.Context cr)
{
cr.set_source_rgba(red, green, blue, alpha);
}
diff --git a/src/ease-json-parser.vala b/src/ease-json-parser.vala
index ba1f8a8..16bc490 100644
--- a/src/ease-json-parser.vala
+++ b/src/ease-json-parser.vala
@@ -100,7 +100,7 @@ public static class Ease.JSONParser
else
{
slide.background_color =
- Clutter.Color.from_string(
+ new Color.from_string(
obj.get_string_member(Theme.BACKGROUND_COLOR));
}
diff --git a/src/ease-slide-actor.vala b/src/ease-slide-actor.vala
index f574265..e94c43e 100644
--- a/src/ease-slide-actor.vala
+++ b/src/ease-slide-actor.vala
@@ -268,8 +268,9 @@ public class Ease.SlideActor : Clutter.Group
}
else // the background is a solid color
{
- background = new Clutter.Rectangle();
- ((Clutter.Rectangle)background).color = slide.background_color;
+ var rect = new Clutter.Rectangle();
+ rect.color = slide.background_color.clutter;
+ background = rect;
}
background.width = width_px;
background.height = height_px;
diff --git a/src/ease-slide.vala b/src/ease-slide.vala
index a383e1d..bc0cb23 100644
--- a/src/ease-slide.vala
+++ b/src/ease-slide.vala
@@ -66,7 +66,7 @@ public class Ease.Slide : GLib.Object
/**
* The background color, if there is no background image
*/
- public Clutter.Color background_color;
+ public Color background_color;
/**
* The background image, if one is set
@@ -259,9 +259,7 @@ public class Ease.Slide : GLib.Object
if (background_image == null)
{
context.rectangle(0, 0, w, h);
- context.set_source_rgb(background_color.red / 255f,
- background_color.green / 255f,
- background_color.blue / 255f);
+ background_color.set_cairo(context);
context.fill();
}
@@ -308,7 +306,8 @@ public class Ease.Slide : GLib.Object
{
// give the slide a background color
html += "style=\"background-color: " +
- background_color.to_string().substring(0, 7) + "\">";
+ background_color.clutter.to_string().
+ substring(0, 7) + "\">";
}
else
{
diff --git a/src/ease-text-actor.vala b/src/ease-text-actor.vala
index 07910db..e4f7a39 100644
--- a/src/ease-text-actor.vala
+++ b/src/ease-text-actor.vala
@@ -51,7 +51,7 @@ public class Ease.TextActor : Actor
text.use_markup = true;
text.line_wrap = true;
text.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
- text.color = e.color;
+ text.color = e.color.clutter;
text.line_alignment = e.text_align;
format(e);
text.set_markup(e.has_been_edited ? e.get("text") : DEFAULT_TEXT);
@@ -64,7 +64,7 @@ public class Ease.TextActor : Actor
// add notify event handlers to update when changes to the element occur
e.notify["color"].connect((sender, spec) => {
- text.color = (sender as TextElement).color;
+ text.color = (sender as TextElement).color.clutter;
});
e.notify["font-description"].connect((sender, spec) => {
diff --git a/src/ease-text-element.vala b/src/ease-text-element.vala
index 3039c58..90bda02 100644
--- a/src/ease-text-element.vala
+++ b/src/ease-text-element.vala
@@ -56,7 +56,7 @@ public class Ease.TextElement : Element
*/
public override bool set_color(Clutter.Color c)
{
- color = c;
+ color = new Color.from_clutter(c);
return true;
}
@@ -65,7 +65,7 @@ public class Ease.TextElement : Element
*/
public override Clutter.Color? get_color()
{
- return color;
+ return color.clutter;
}
@@ -118,9 +118,7 @@ public class Ease.TextElement : Element
// render
context.save();
- context.set_source_rgb(color.red / 255f,
- color.green / 255f,
- color.blue / 255f);
+ color.set_cairo(context);
Pango.cairo_update_layout(context, layout);
context.move_to((int)x, (int)y);
@@ -141,11 +139,11 @@ public class Ease.TextElement : Element
/**
* The color of the text.
*/
- public Clutter.Color color
+ public Color color
{
- get
+ owned get
{
- return Clutter.Color.from_string(data.get(Theme.TEXT_COLOR));
+ return new Color.from_string(data.get(Theme.TEXT_COLOR));
}
set
{
diff --git a/src/ease-theme.vala b/src/ease-theme.vala
index aea1ea3..62867e0 100644
--- a/src/ease-theme.vala
+++ b/src/ease-theme.vala
@@ -314,8 +314,8 @@ public class Ease.Theme : GLib.Object
Slide slide = new Slide();
// set the slide background property
- slide.background_color = Clutter.Color.from_string(master_get(master,
- BACKGROUND_COLOR));
+ slide.background_color = new Color.
+ from_string(master_get(master, BACKGROUND_COLOR));
switch (master)
{
@@ -417,7 +417,7 @@ public class Ease.Theme : GLib.Object
}
// set the color property
- text.color = Clutter.Color.from_string(element_get(type, TEXT_COLOR));
+ text.color = new Color.from_string(element_get(type, TEXT_COLOR));
// set size properties
text.x = x;
diff --git a/themes/Black/Theme.json b/themes/Black/Theme.json
index 44efcf1..1235945 100644
--- a/themes/Black/Theme.json
+++ b/themes/Black/Theme.json
@@ -3,10 +3,10 @@
"author" : "Nate Stedman <natesm gmail com>",
"master-defaults" : {
- "background-color" : "#000000FF"
+ "background-color" : "0, 0, 0"
},
"element-defaults" : {
- "text-color" : "#FFFFFFFF"
+ "text-color" : "1, 1, 1"
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]