[ease/serialize: 51/52] Use pango scale, some other stuff



commit 8750c9f1df623e283ddbe970c9d58cebc086001c
Author: Nate Stedman <natesm gmail com>
Date:   Tue Feb 22 17:28:28 2011 -0500

    Use pango scale, some other stuff

 ease-core/ease-text-actor.vala   |    2 +-
 ease-core/ease-text-element.vala |    2 +-
 ease-core/ease-text.vala         |   15 +++++++++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/ease-core/ease-text-actor.vala b/ease-core/ease-text-actor.vala
index df1c04b..d2823d2 100644
--- a/ease-core/ease-text-actor.vala
+++ b/ease-core/ease-text-actor.vala
@@ -440,7 +440,7 @@ public class Ease.TextActor : Actor
 		
 		// render the text
 		cr.restore();
-		(element as TextElement).text.render(cr, !editing);
+		(element as TextElement).text.render(cr, (int)(element.width), !editing);
 	}
 }
 
diff --git a/ease-core/ease-text-element.vala b/ease-core/ease-text-element.vala
index 3659fe4..f0a7ddd 100644
--- a/ease-core/ease-text-element.vala
+++ b/ease-core/ease-text-element.vala
@@ -171,7 +171,7 @@ public class Ease.TextElement : Element
 	public override void cairo_render(Cairo.Context context,
 	                                  bool use_small) throws Error
 	{
-		text.render(context, true);
+		text.render(context, (int)width, true);
 	}
 	
 	/**
diff --git a/ease-core/ease-text.vala b/ease-core/ease-text.vala
index 794cf00..14bbf46 100644
--- a/ease-core/ease-text.vala
+++ b/ease-core/ease-text.vala
@@ -94,8 +94,9 @@ public class Ease.Text : GLib.Object
 	 * @param index The index of the cursor, this value is set on out.
 	 * @param layout_index The layout index, this value is set on out.
 	 * @param chars The number of characters to advance or retreat.
+	 * @return Whether or not the index or layout index (or both) was altered.
 	 */
-	public void move_cursor(ref int index, ref int layout_index, int chars)
+	public bool move_cursor(ref int index, ref int layout_index, int chars)
 	{
 		var current = layouts.get(layout_index);
 		
@@ -107,11 +108,13 @@ public class Ease.Text : GLib.Object
 				{
 					layout_index++;
 					index = index + chars - current.length;
+					return true;
 				}
 			}
 			else
 			{
 				index++;
+				return true;
 			}
 		}
 		else if (chars < 0)
@@ -122,13 +125,17 @@ public class Ease.Text : GLib.Object
 				{
 					layout_index--;
 					index = layouts.get(layout_index).length;
+					return true;
 				}
 			}
 			else
 			{
 				index--;
+				return true;
 			}
 		}
+		
+		return false;
 	}
 	
 	/**
@@ -155,16 +162,20 @@ public class Ease.Text : GLib.Object
 	 * Renders the Text to a Cairo Context.
 	 *
 	 * @param cr The context to render to.
+	 * @param width The width to render at.
 	 * @param use_default If the text is empty, the default string will be
 	 * rendered instead of an empty string.
 	 */
-	public void render(Cairo.Context cr, bool use_default)
+	public void render(Cairo.Context cr, int width, bool use_default)
 	{
 		int y = 0;
 		cr.save();
 		
 		// render each layout, if it's within the bounds of the rectangle
 		@foreach((layout) => {
+			// set the layout width
+			layout.layout.set_width(width * Pango.SCALE);
+
 			// render the layout
 			layout.render(cr, use_default);
 			



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]