[ease] Use Control+Drag to resize while maintaining the center point of an Actor.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Use Control+Drag to resize while maintaining the center point of an Actor.
- Date: Thu, 20 May 2010 04:42:41 +0000 (UTC)
commit 0126ff71ea267671b3a18be70ab29e2502f1360a
Author: Nate Stedman <natesm gmail com>
Date: Thu May 20 00:42:38 2010 -0400
Use Control+Drag to resize while maintaining the center point of an Actor.
src/libease/EditorEmbed.vala | 18 ++++++++++++---
src/libease/Handle.vala | 47 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/src/libease/EditorEmbed.vala b/src/libease/EditorEmbed.vala
index cae6292..2624752 100644
--- a/src/libease/EditorEmbed.vala
+++ b/src/libease/EditorEmbed.vala
@@ -466,11 +466,21 @@ public class Ease.EditorEmbed : ScrollableEmbed
float factor = 1 / zoom;
var motion = event.motion;
var p = (motion.modifier_state & Clutter.ModifierType.SHIFT_MASK) != 0;
+ float change_x = motion.x - mouse_x;
+ float change_y = motion.y - mouse_y;
- handle.drag(factor * (motion.x - mouse_x),
- factor * (motion.y - mouse_y),
- selected,
- p);
+ // if control is held, resize from the center
+ if ((motion.modifier_state & Clutter.ModifierType.CONTROL_MASK) != 0)
+ {
+ handle.drag_from_center(factor * change_x, factor * change_y,
+ selected, p);
+ }
+
+ // otherwise, drag normally
+ else
+ {
+ handle.drag(factor * change_x, factor * change_y, selected, p);
+ }
mouse_x = motion.x;
mouse_y = motion.y;
diff --git a/src/libease/Handle.vala b/src/libease/Handle.vala
index cbd21cf..04238d1 100644
--- a/src/libease/Handle.vala
+++ b/src/libease/Handle.vala
@@ -89,6 +89,53 @@ public class Ease.Handle : Clutter.Rectangle
}
}
+ public void drag_from_center(float change_x, float change_y, Actor target,
+ bool prop)
+ {
+ switch (position)
+ {
+ case HandlePosition.TOP_LEFT:
+ target.translate(change_x, change_y);
+ target.resize(-change_x * 2, -change_y * 2, false);
+ break;
+
+ case HandlePosition.TOP_RIGHT:
+ target.translate(-change_x, change_y);
+ target.resize(change_x * 2, -change_y * 2, prop);
+ break;
+
+ case HandlePosition.TOP:
+ target.translate(0, change_y);
+ target.resize(0, -change_y * 2, false);
+ break;
+
+ case HandlePosition.BOTTOM:
+ target.translate(0, -change_y);
+ target.resize(0, change_y * 2, false);
+ break;
+
+ case HandlePosition.LEFT:
+ target.translate(change_x, 0);
+ target.resize(-change_x * 2, 0, false);
+ break;
+
+ case HandlePosition.RIGHT:
+ target.translate(-change_x, 0);
+ target.resize(change_x * 2, 0, false);
+ break;
+
+ case HandlePosition.BOTTOM_LEFT:
+ target.translate(change_x, -change_y);
+ target.resize(-change_x * 2, change_y * 2, prop);
+ break;
+
+ case HandlePosition.BOTTOM_RIGHT:
+ target.translate(-change_x, -change_y);
+ target.resize(change_x * 2, change_y * 2, prop);
+ break;
+ }
+ }
+
public void reposition(Clutter.Actor selection)
{
switch (position)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]