[gimp/soc-2012-unified-transformation: 18/39] transformtool: implement fromcenter constraint for shearing
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2012-unified-transformation: 18/39] transformtool: implement fromcenter constraint for shearing
- Date: Tue, 7 Aug 2012 18:32:31 +0000 (UTC)
commit 67b86a71396e8bfbaec2a51ce49c7e45ce81f8c6
Author: Mikael Magnusson <mikachu src gnome org>
Date: Fri Jun 15 11:16:15 2012 +0200
transformtool: implement fromcenter constraint for shearing
app/tools/gimpunifiedtransformtool.c | 40 +++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index 455525d..2cd1bda 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -867,8 +867,11 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
function == TRANSFORM_HANDLE_S_S ||
function == TRANSFORM_HANDLE_W_S)
{
- gint left, right;
+ /* o for the opposite edge, for fromcenter */
+ gint left, right, lefto, righto;
+ gdouble dxo, dyo;
+ /* set up indices for this edge and the opposite edge */
if (function == TRANSFORM_HANDLE_N_S) {
left = 1; right = 0;
} else if (function == TRANSFORM_HANDLE_W_S) {
@@ -879,6 +882,19 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
left = 3; right = 1;
} else g_assert_not_reached ();
+ lefto = 3 - left;
+ righto = 3 - right;
+
+ if (fromcenter)
+ {
+ dxo = -dx;
+ dyo = -dy;
+ }
+ else
+ {
+ dxo = dyo = 0;
+ }
+
if (constrain)
{
/* restrict to movement along the side */
@@ -893,11 +909,33 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
dy = p.y;
}
+ if (constrain && fromcenter)
+ {
+ /* restrict to movement along the opposite side */
+ GimpVector2 lp = { .x = px[lefto], .y = py[lefto] },
+ rp = { .x = px[righto], .y = py[righto] },
+ p = { .x = dxo, .y = dyo },
+ side = vectorsubtract (rp, lp);
+
+ p = vectorproject (p, side);
+
+ dxo = p.x;
+ dyo = p.y;
+ }
+
*x[left] = px[left] + dx;
*y[left] = py[left] + dy;
*x[right] = px[right] + dx;
*y[right] = py[right] + dy;
+
+ /* We have to set these unconditionally, or the opposite edge will stay
+ * in place when you toggle the fromcenter constraint during an action */
+ *x[lefto] = px[lefto] + dxo;
+ *y[lefto] = py[lefto] + dyo;
+
+ *x[righto] = px[righto] + dxo;
+ *y[righto] = py[righto] + dyo;
}
/* perspective transform */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]