[ease/text: 4/4] [text] Cursor polish.



commit f01305fcb1456da008230dd174a73232db3c6c00
Author: Nate Stedman <natesm gmail com>
Date:   Sun Nov 28 23:52:49 2010 -0500

    [text] Cursor polish.
    
    * Cursor blinks, not fades, the animation looked bad
    * Cursor stays visible when moving around.

 ease-core/ease-text-actor.vala |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/ease-core/ease-text-actor.vala b/ease-core/ease-text-actor.vala
index c0d9f42..2b2a5f0 100644
--- a/ease-core/ease-text-actor.vala
+++ b/ease-core/ease-text-actor.vala
@@ -48,11 +48,6 @@ public class Ease.TextActor : Actor
 	private Clutter.Timeline cursor_timeline;
 	
 	/**
-	 * The cursor's animation.
-	 */
-	private Clutter.Animation cursor_anim;
-	
-	/**
 	 * The index of the cursor.
 	 */
 	private int cursor_index = 0;
@@ -91,6 +86,7 @@ public class Ease.TextActor : Actor
 		x = e.x;
 		y = e.y;
 		
+		// position the cursor when the actor is resized
 		contents.notify["width"].connect(() => position_cursor());
 		contents.notify["height"].connect(() => position_cursor());
 	}
@@ -112,7 +108,7 @@ public class Ease.TextActor : Actor
 		// add and animate the cursor
 		add_actor(cursor);
 		position_cursor();
-		cursor.opacity = 255;
+		cursor.opacity = 0;
 		cursor_timeline = new Clutter.Timeline(
 			(uint)(Gtk.Settings.get_default().gtk_cursor_blink_time / 2));
 		cursor_timeline.completed.connect(on_cursor_timeline_completed);
@@ -141,11 +137,15 @@ public class Ease.TextActor : Actor
 				
 				case Key.LEFT:
 					cursor_index = int.max(cursor_index - 1, 0);
+					cursor.opacity = 255;
+					cursor_timeline.rewind();
 					break;
 				
 				case Key.RIGHT:
 					cursor_index = int.min(cursor_index + 1,
 					                       (int)text.layout.get_text().length);
+					cursor.opacity = 255;
+					cursor_timeline.rewind();
 					break;
 				
 				default: {
@@ -195,14 +195,9 @@ public class Ease.TextActor : Actor
 	 */
 	private void on_cursor_timeline_completed(Clutter.Timeline timeline)
 	{
-		// remove the current animation
-		if (cursor_anim != null) cursor_anim.completed();
-		
 		// rewind the timeline and fade in the other direction
 		timeline.rewind();
-		cursor_anim = cursor.animate_with_timeline(
-			Clutter.AnimationMode.EASE_OUT_EXPO, timeline,
-			"opacity", cursor.opacity == 255 ? 0 : 255, null);
+		cursor.opacity = cursor.opacity == 0 ? 255 : 0;
 		timeline.start();
 	}
 	



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