[ease: 10/10] [text] Text elements render the default text in Cairo
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease: 10/10] [text] Text elements render the default text in Cairo
- Date: Fri, 30 Jul 2010 07:31:30 +0000 (UTC)
commit c298de2f46562362f5cae7109ddb927bfc946249
Author: Nate Stedman <natesm gmail com>
Date: Fri Jul 30 03:30:10 2010 -0400
[text] Text elements render the default text in Cairo
Previously, text elements showing the default text in
Clutter were blank in any Cairo renderings. This has
been fixed.
ease-core/ease-text-actor.vala | 11 +++--------
ease-core/ease-text-element.vala | 20 +++++++++++++++++---
src/ease-welcome-actor.vala | 1 +
3 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/ease-core/ease-text-actor.vala b/ease-core/ease-text-actor.vala
index 4ef96fd..407d5df 100644
--- a/ease-core/ease-text-actor.vala
+++ b/ease-core/ease-text-actor.vala
@@ -23,11 +23,6 @@
public class Ease.TextActor : Actor
{
/**
- * The text shown for unedited Elements.
- */
- private const string DEFAULT_TEXT = _("Double Click to Edit");
-
- /**
* The opacity of the selection highlight.
*/
private const uchar SELECTION_ALPHA = 200;
@@ -64,7 +59,7 @@ public class Ease.TextActor : Actor
text.color = e.color.clutter;
text.line_alignment = e.text_align;
text.font_name = e.font_description.to_string();
- text.set_markup(e.has_been_edited ? e.text : DEFAULT_TEXT);
+ text.set_markup(e.display_text);
add_actor(contents);
contents.width = e.width;
@@ -92,7 +87,7 @@ public class Ease.TextActor : Actor
e.notify["text"].connect((sender, spec) => {
if (!text.editable)
{
- text.set_markup(e.has_been_edited ? e.text : DEFAULT_TEXT);
+ text.set_markup((element as TextElement).display_text);
}
});
}
@@ -158,7 +153,7 @@ public class Ease.TextActor : Actor
// if the text has not been edited, restore default text
if (text.text == "" && !element.has_been_edited)
{
- text.text = DEFAULT_TEXT;
+ text.text = (element as TextElement).display_text;
}
else // otherwise, the element has been edited
{
diff --git a/ease-core/ease-text-element.vala b/ease-core/ease-text-element.vala
index bcd24e6..3fd0797 100644
--- a/ease-core/ease-text-element.vala
+++ b/ease-core/ease-text-element.vala
@@ -22,6 +22,7 @@ public class Ease.TextElement : Element
{
private const string UI_FILE_PATH = "inspector-element-text.ui";
private bool freeze = false;
+ private const string DEFAULT_TEXT = _("Double click to edit");
/**
* Creates a new TextElement.
@@ -234,10 +235,12 @@ public class Ease.TextElement : Element
* Renders a text Element with Cairo.
*/
public override void cairo_render(Cairo.Context context) throws Error
- {
+ {
+ var t = display_text;
+
// create the layout
var layout = Pango.cairo_create_layout(context);
- layout.set_text(text, (int)text.length);
+ layout.set_text(t, (int)t.length);
layout.set_width((int)(width * Pango.SCALE));
layout.set_height((int)(height * Pango.SCALE));
layout.set_font_description(font_description);
@@ -246,7 +249,6 @@ public class Ease.TextElement : Element
// render
color.set_cairo(context);
Pango.cairo_update_layout(context, layout);
-// context.move_to((int)x, (int)y);
Pango.cairo_show_layout(context, layout);
}
@@ -256,6 +258,18 @@ public class Ease.TextElement : Element
public string text { get; set; }
/**
+ * Gets the text this Element should display. This might not be the same as
+ * { link text}.
+ */
+ public string display_text
+ {
+ get
+ {
+ return has_been_edited || text.length > 0 ? text : DEFAULT_TEXT;
+ }
+ }
+
+ /**
* The color of the text.
*/
public Color color { get; set; }
diff --git a/src/ease-welcome-actor.vala b/src/ease-welcome-actor.vala
index 42d0ead..9b7b2f2 100644
--- a/src/ease-welcome-actor.vala
+++ b/src/ease-welcome-actor.vala
@@ -227,6 +227,7 @@ internal class Ease.WelcomeActor : Clutter.Group
foreach (var element in slide)
{
+ element.has_been_edited = true;
switch (element.identifier)
{
case Theme.TITLE_TEXT:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]