[ease] Added default text for new TextElement/TextActors.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Added default text for new TextElement/TextActors.
- Date: Fri, 11 Jun 2010 05:11:30 +0000 (UTC)
commit f257da3516e2836845a964b3997b1ab0503ee620
Author: Nate Stedman <natesm gmail com>
Date: Fri Jun 11 01:11:08 2010 -0400
Added default text for new TextElement/TextActors.
src/Document.vala | 2 +-
src/EditorWindow.vala | 2 +-
src/Element.vala | 16 +++++++++++++++-
src/Slide.vala | 6 ++++--
src/TextActor.vala | 10 +++++++++-
src/WelcomeActor.vala | 2 +-
6 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/src/Document.vala b/src/Document.vala
index 3f6a2a5..3bb48c4 100644
--- a/src/Document.vala
+++ b/src/Document.vala
@@ -79,7 +79,7 @@ public class Ease.Document : SlideSet
var master = theme.slide_by_title(DEFAULT_SLIDE);
// add the first slide
- append_slide(new Slide.from_master(master, this, width, height));
+ append_slide(new Slide.from_master(master, this, width, height, true));
}
/**
diff --git a/src/EditorWindow.vala b/src/EditorWindow.vala
index 853ffe7..8d5078d 100644
--- a/src/EditorWindow.vala
+++ b/src/EditorWindow.vala
@@ -147,7 +147,7 @@ public class Ease.EditorWindow : Gtk.Window
var slide = new Slide.from_master(master, document,
document.width,
- document.height);
+ document.height, true);
var index = document.index_of(slide) + 1;
diff --git a/src/Element.vala b/src/Element.vala
index 595b3ce..f711c1e 100644
--- a/src/Element.vala
+++ b/src/Element.vala
@@ -177,8 +177,10 @@ public abstract class Ease.Element : GLib.Object
* part of.
* @param w The height of the { link Document} the new Element will be a
* part of.
+ * @param is_new If this Element is part of a new { link Document}. Sets
+ * the has_been_edited property to false.
*/
- public Element sized_element(float w, float h)
+ public Element sized_element(float w, float h, bool is_new)
{
// copy this element
var element = copy();
@@ -191,6 +193,9 @@ public abstract class Ease.Element : GLib.Object
element.width = THEME_WIDTH - left - right;
element.height = THEME_HEIGHT - top - bottom;
+ // this is a new element, so it hasn't been edited
+ element.has_been_edited = !is_new;
+
// handle binding to the left
if (bind_left)
{
@@ -330,6 +335,15 @@ public abstract class Ease.Element : GLib.Object
}
/**
+ * If the Element has been edited by the user in the past.
+ */
+ public bool has_been_edited
+ {
+ get { return data.get("has_been_edited").to_bool(); }
+ set { data.set("has_been_edited", value.to_string()); }
+ }
+
+ /**
* If the Element should maintain "top" when resized.
*
* To scale to different resolutions, MasterElement tracks the distance of
diff --git a/src/Slide.vala b/src/Slide.vala
index 33f3e97..5e18a33 100644
--- a/src/Slide.vala
+++ b/src/Slide.vala
@@ -168,9 +168,11 @@ public class Ease.Slide : GLib.Object
* @param document The { link Document} this slide is being inserted into.
* @param width The width, in pixels, of the Slide.
* @param height The height, in pixels, of the Slide.
+ * @param is_new If this Slide is part of a new { link Document}. Sets
+ * the has_been_edited property of { link Element}s to false.
*/
public Slide.from_master(Slide master, Document? document,
- int width, int height)
+ int width, int height, bool is_new)
{
// set basic properties
transition = master.transition;
@@ -198,7 +200,7 @@ public class Ease.Slide : GLib.Object
// add all of the master Slide's elements
foreach (var e in master.elements)
{
- elements.add(e.sized_element(width, height));
+ elements.add(e.sized_element(width, height, is_new));
}
}
diff --git a/src/TextActor.vala b/src/TextActor.vala
index 7a447b7..36cc4c5 100644
--- a/src/TextActor.vala
+++ b/src/TextActor.vala
@@ -22,6 +22,8 @@
*/
public class Ease.TextActor : Actor
{
+ private const string DEFAULT_TEXT = _("Double Click to Edit");
+
/**
* Instantiates a new TextActor from an Element.
*
@@ -41,7 +43,7 @@ public class Ease.TextActor : Actor
text.line_wrap = true;
text.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
text.color = e.color;
- text.set_markup(e.get("text"));
+ text.set_markup(e.has_been_edited ? e.get("text") : DEFAULT_TEXT);
text.font_name = e.font_description.to_string();
text.line_alignment = e.text_align;
@@ -70,6 +72,12 @@ public class Ease.TextActor : Actor
// grab key focus
((Clutter.Stage)get_stage()).set_key_focus(text);
sender.key_focus();
+
+ // if the element hasn't been edited, empty it
+ if (!element.has_been_edited)
+ {
+ text.text = "";
+ }
}
/**
diff --git a/src/WelcomeActor.vala b/src/WelcomeActor.vala
index 408824b..020731c 100644
--- a/src/WelcomeActor.vala
+++ b/src/WelcomeActor.vala
@@ -80,7 +80,7 @@ public class Ease.WelcomeActor : Clutter.Group
}
slide = new Slide.from_master(master, null,
- (int)WIDTH, (int)slide_height);
+ (int)WIDTH, (int)slide_height, false);
slide.theme = theme;
slide_actor = new SlideActor.with_dimensions(w, h, slide, true,
ActorContext.PRESENTATION);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]