[ease] Added handles to the selection rectangle, not functional yet.



commit 41abd3e1b42ccbb4e6d70afa7b3648b1a04643f3
Author: Nate Stedman <natesm gmail com>
Date:   Wed May 19 00:18:14 2010 -0400

    Added handles to the selection rectangle, not functional yet.
    
    Renamed DraggableRectangle to Handle, which is slightly more reasonable.
    Handle is currently undocumented, this should be fixed.

 src/libease/EditorEmbed.vala                       |   24 +++++
 src/libease/Enums.vala                             |   18 ++--
 .../{DraggableRectangle.vala => Handle.vala}       |  100 ++++++++------------
 3 files changed, 71 insertions(+), 71 deletions(-)
---
diff --git a/src/libease/EditorEmbed.vala b/src/libease/EditorEmbed.vala
index cc614da..5284287 100644
--- a/src/libease/EditorEmbed.vala
+++ b/src/libease/EditorEmbed.vala
@@ -36,6 +36,9 @@ namespace Ease
 		
 		// selection rectangle
 		private Clutter.Rectangle selection_rectangle;
+		
+		// handles
+		private Handle[] handles;
 
 		// the current slide's actor
 		private SlideActor slide_actor;
@@ -157,6 +160,10 @@ namespace Ease
 			if (selection_rectangle != null)
 			{
 				contents.remove_actor(selection_rectangle);
+				foreach (var h in handles)
+				{
+					contents.remove_actor(h);
+				}
 			}
 			
 			// create a new SlideActor
@@ -220,6 +227,11 @@ namespace Ease
 				                             zoom * selected.y + slide_actor.y);
 			selection_rectangle.set_size(zoom * selected.width,
 			                             zoom * selected.height);
+			
+			foreach (var h in handles)
+			{
+				h.reposition(selection_rectangle);
+			}
 		}
 		
 		/**
@@ -248,6 +260,10 @@ namespace Ease
 			// remove the selection rectangle
 			if (selection_rectangle != null)
 			{
+				foreach (var h in handles)
+				{
+					contents.remove_actor(h);
+				}
 				contents.remove_actor(selection_rectangle);
 			}
 			
@@ -261,6 +277,14 @@ namespace Ease
 			position_selection();
 			contents.add_actor(selection_rectangle);
 			
+			handles = new Handle[8];
+			for (int i = 0; i < 8; i++)
+			{
+				handles[i] = new Handle((HandlePosition)i);
+				handles[i].reposition(selection_rectangle);
+				contents.add_actor(handles[i]);
+			}
+			
 			return true;
 		}
 		
diff --git a/src/libease/Enums.vala b/src/libease/Enums.vala
index 8d7f555..3ea8d77 100644
--- a/src/libease/Enums.vala
+++ b/src/libease/Enums.vala
@@ -17,16 +17,16 @@
 
 namespace Ease
 {
-	public enum RectanglePosition
+	public enum HandlePosition
 	{
-		TopLeft,
-		TopRight,
-		Top,
-		Left,
-		Right,
-		BottomLeft,
-		BottomRight,
-		Bottom
+		TopLeft = 0,
+		TopRight = 1,
+		Top = 2,
+		Left = 3,
+		Right = 4,
+		BottomLeft = 5,
+		BottomRight = 6,
+		Bottom = 7
 	}
 
 	public enum ActorContext
diff --git a/src/libease/DraggableRectangle.vala b/src/libease/Handle.vala
similarity index 54%
rename from src/libease/DraggableRectangle.vala
rename to src/libease/Handle.vala
index 09b8ee0..67d6f47 100644
--- a/src/libease/DraggableRectangle.vala
+++ b/src/libease/Handle.vala
@@ -17,13 +17,13 @@
 
 namespace Ease
 {
-	public class DraggableRectangle : Clutter.Group
+	public class Handle : Clutter.Group
 	{
 		// the graphical element of the rectangle
 		private Clutter.Rectangle rectangle;
 		
 		// the position of this rectangle
-		private RectanglePosition position;
+		private HandlePosition position;
 
 		// the offset of the pointer, so things don't jump
 		private int pointer_offset_x;
@@ -32,7 +32,7 @@ namespace Ease
 		// constants
 		public static const float SIZE = 10;
 		
-		public DraggableRectangle(RectanglePosition pos)
+		public Handle(HandlePosition pos)
 		{
 			// set the rectangle's position
 			position = pos;
@@ -41,14 +41,11 @@ namespace Ease
 			rectangle = new Clutter.Rectangle();
 
 			// set the rectangle's color
-			Clutter.Color color = Clutter.Color();
-			color.from_string("Black");
-			rectangle.color = color;
+			rectangle.color = {0, 0, 0, 255};
 
 			// set the rectangle's border
-			rectangle.border_width = 1;
-			color.from_string("White");
-			rectangle.border_color = color;
+			rectangle.border_width = 2;
+			rectangle.border_color = {255, 255, 255, 255};
 
 			// set the rectangle's size
 			rectangle.width = SIZE;
@@ -59,71 +56,50 @@ namespace Ease
 			add_actor(rectangle);
 			
 			reactive = true;
-			button_press_event.connect(e => {
-				//if (e.get_button() == 1)
-				{
-					start_drag();
-				}
-				return false;
-			});
-			
-			button_release_event.connect(e => {
-				//if (e.get_button() == 1)
-				{
-					stop_drag();
-				}
-				return false;
-			});
-			
-			motion_event.connect(e => {
-				if (Clutter.get_pointer_grab() == this)
-				{
-					drag(e.motion);
-				}
-				return false;
-			});
-			
-			reposition();
-		}
-		
-		public void start_drag()
-		{
-			Clutter.grab_pointer(this);
-			
-			//TODO: actually set the offsets
-			pointer_offset_x = 0;
-			pointer_offset_y = 0;
-		}
-		
-		private void stop_drag()
-		{
-			Clutter.ungrab_pointer();
-		}
-		
-		private void drag(Clutter.MotionEvent m)
-		{
-			
 		}
 		
-		public void reposition()
+		public void reposition(Clutter.Actor selection)
 		{
 			switch (position)
 			{
-				case RectanglePosition.TopLeft:
+				case HandlePosition.TopLeft:
+					x = selection.x;
+					y = selection.y;
 					break;
-				case RectanglePosition.TopRight:
+					
+				case HandlePosition.TopRight:
+					x = selection.x + selection.width;
+					y = selection.y;
 					break;
-				case RectanglePosition.Top:
+					
+				case HandlePosition.Top:
+					x = selection.x + selection.width / 2;
+					y = selection.y;
 					break;
-				case RectanglePosition.Left:
+					
+				case HandlePosition.Left:
+					x = selection.x;
+					y = selection.y + selection.height / 2;
 					break;
-				case RectanglePosition.Right:
+					
+				case HandlePosition.Right:
+					x = selection.x + selection.width;
+					y = selection.y + selection.height / 2;
 					break;
-				case RectanglePosition.BottomLeft:
+					
+				case HandlePosition.BottomLeft:
+					x = selection.x;
+					y = selection.y + selection.height;
 					break;
-				case RectanglePosition.BottomRight:
+					
+				case HandlePosition.BottomRight:
+					x = selection.x + selection.width;
+					y = selection.y + selection.height;
 					break;
-				case RectanglePosition.Bottom:
+					
+				case HandlePosition.Bottom:
+					x = selection.x + selection.width / 2;
+					y = selection.y + selection.height;
 					break;
 			}
 		}



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