store the original aspect ratio. Let the Ctrl key toggle the aspect ratio
2006-12-29 Sven Neumann <sven@gimp.org> * app/tools/gimptransformtool.[ch]: store the original aspect ratio. Let the Ctrl key toggle the aspect ratio constraint also while the mouse is being pressed. * app/tools/gimpscaletool.c (gimp_scale_tool_motion): use the original aspect ratio when applying the constraint.
This commit is contained in:

committed by
Sven Neumann

parent
c60d6fd58b
commit
4cbb8d7fad
@ -1,3 +1,12 @@
|
||||
2006-12-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimptransformtool.[ch]: store the original aspect ratio.
|
||||
Let the Ctrl key toggle the aspect ratio constraint also while the
|
||||
mouse is being pressed.
|
||||
|
||||
* app/tools/gimpscaletool.c (gimp_scale_tool_motion): use the
|
||||
original aspect ratio when applying the constraint.
|
||||
|
||||
2006-12-29 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/print/print.c: show print status information.
|
||||
|
@ -250,31 +250,34 @@ gimp_scale_tool_motion (GimpTransformTool *tr_tool,
|
||||
return;
|
||||
}
|
||||
|
||||
*x1 += diff_x;
|
||||
*y1 += diff_y;
|
||||
|
||||
/* if control is being held, constrain the aspect ratio */
|
||||
if (options->constrain)
|
||||
{
|
||||
gdouble mag;
|
||||
gdouble dot;
|
||||
/* FIXME: improve this */
|
||||
gdouble w = tr_tool->trans_info[X1] - tr_tool->trans_info[X0];
|
||||
gdouble h = tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0];
|
||||
|
||||
mag = hypot ((gdouble) (tr_tool->x2 - tr_tool->x1),
|
||||
(gdouble) (tr_tool->y2 - tr_tool->y1));
|
||||
|
||||
dot = (dir_x * diff_x * (tr_tool->x2 - tr_tool->x1) +
|
||||
dir_y * diff_y * (tr_tool->y2 - tr_tool->y1));
|
||||
|
||||
if (mag > 0.0)
|
||||
switch (tr_tool->function)
|
||||
{
|
||||
diff_x = dir_x * (tr_tool->x2 - tr_tool->x1) * dot / (mag * mag);
|
||||
diff_y = dir_y * (tr_tool->y2 - tr_tool->y1) * dot / (mag * mag);
|
||||
}
|
||||
else
|
||||
{
|
||||
diff_x = diff_y = 0;
|
||||
}
|
||||
}
|
||||
case TRANSFORM_HANDLE_NW:
|
||||
case TRANSFORM_HANDLE_SW:
|
||||
tr_tool->trans_info[X0] =
|
||||
tr_tool->trans_info[X1] - tr_tool->aspect * h;
|
||||
break;
|
||||
|
||||
*x1 += diff_x;
|
||||
*y1 += diff_y;
|
||||
case TRANSFORM_HANDLE_NE:
|
||||
case TRANSFORM_HANDLE_SE:
|
||||
tr_tool->trans_info[X1] =
|
||||
tr_tool->trans_info[X0] + tr_tool->aspect * h;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dir_x > 0)
|
||||
{
|
||||
|
@ -175,6 +175,7 @@ gimp_transform_tool_class_init (GimpTransformToolClass *klass)
|
||||
tool_class->motion = gimp_transform_tool_motion;
|
||||
tool_class->key_press = gimp_transform_tool_key_press;
|
||||
tool_class->modifier_key = gimp_transform_tool_modifier_key;
|
||||
tool_class->active_modifier_key = gimp_transform_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_transform_tool_oper_update;
|
||||
tool_class->cursor_update = gimp_transform_tool_cursor_update;
|
||||
|
||||
@ -1512,6 +1513,9 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool,
|
||||
tr_tool->cx = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
|
||||
tr_tool->cy = (gdouble) (tr_tool->y1 + tr_tool->y2) / 2.0;
|
||||
|
||||
tr_tool->aspect = ((gdouble) (tr_tool->x2 - tr_tool->x1) /
|
||||
(gdouble) (tr_tool->y2 - tr_tool->y1));
|
||||
|
||||
/* changing the bounds invalidates any grid we may have */
|
||||
if (tr_tool->use_grid)
|
||||
gimp_transform_tool_grid_recalc (tr_tool);
|
||||
|
@ -59,6 +59,7 @@ struct _GimpTransformTool
|
||||
gint x1, y1; /* upper left hand coordinate */
|
||||
gint x2, y2; /* lower right hand coords */
|
||||
gdouble cx, cy; /* center point (for rotation) */
|
||||
gdouble aspect; /* original aspect ratio */
|
||||
|
||||
gdouble tx1, ty1; /* transformed coords */
|
||||
gdouble tx2, ty2;
|
||||
|
Reference in New Issue
Block a user