diff --git a/ChangeLog b/ChangeLog index 8def2926f8..0d2293edd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-12-29 Sven Neumann + + * 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 * plug-ins/print/print.c: show print status information. diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c index 8be615171e..d626321226 100644 --- a/app/tools/gimpscaletool.c +++ b/app/tools/gimpscaletool.c @@ -250,32 +250,35 @@ 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; + + 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; } } - *x1 += diff_x; - *y1 += diff_y; - if (dir_x > 0) { if (*x1 >= *x2) diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 06dec78960..ae065c8094 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -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); diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h index c011e4735d..fc6241dc53 100644 --- a/app/tools/gimptransformtool.h +++ b/app/tools/gimptransformtool.h @@ -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;