Commit 42bc755c authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

applied (modified) patch from Ari Pollak which enables controlling the

2004-08-06  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpsheartool.[ch]: applied (modified) patch from Ari
	Pollak which enables controlling the shear direction from the
	dialog and changing the shear direction without hitting "Reset".
	Fixes bug #149467.

	Also moved all static variables to the GimpShearTool struct and
	converted tabs to spaces.
parent 91cf50ae
2004-08-06 Michael Natterer <mitch@gimp.org>
* app/tools/gimpsheartool.[ch]: applied (modified) patch from Ari
Pollak which enables controlling the shear direction from the
dialog and changing the shear direction without hitting "Reset".
Fixes bug #149467.
Also moved all static variables to the GimpShearTool struct and
converted tabs to spaces.
2004-08-06 DindinX <david@dindinx.org>
* plug-ins/common/nova.c: ported to GimpPreviewArea.
......
......@@ -58,7 +58,7 @@
#define MIN_MOVE 5
/* forward function declarations */
/* local function prototypes */
static void gimp_shear_tool_class_init (GimpShearToolClass *klass);
static void gimp_shear_tool_init (GimpShearTool *shear_tool);
......@@ -79,14 +79,12 @@ static void shear_y_mag_changed (GtkWidget *widget,
GimpTransformTool *tr_tool);
/* variables local to this file */
static gdouble xshear_val;
static gdouble yshear_val;
/* private variables */
static GimpTransformToolClass *parent_class = NULL;
/* Public functions */
/* public functions */
void
gimp_shear_tool_register (GimpToolRegisterCallback callback,
......@@ -162,16 +160,18 @@ gimp_shear_tool_init (GimpShearTool *shear_tool)
static void
gimp_shear_tool_dialog (GimpTransformTool *tr_tool)
{
GimpShearTool *shear = GIMP_SHEAR_TOOL (tr_tool);
info_dialog_add_spinbutton (tr_tool->info_dialog,
_("Shear magnitude X:"),
&xshear_val,
&shear->xshear_val,
-65536, 65536, 1, 15, 1, 1, 0,
G_CALLBACK (shear_x_mag_changed),
tr_tool);
info_dialog_add_spinbutton (tr_tool->info_dialog,
_("Shear magnitude Y:"),
&yshear_val,
&shear->yshear_val,
-65536, 65536, 1, 15, 1, 1, 0,
G_CALLBACK (shear_y_mag_changed),
tr_tool);
......@@ -203,24 +203,24 @@ gimp_shear_tool_motion (GimpTransformTool *tr_tool,
if (tr_tool->trans_info[HORZ_OR_VERT] == GIMP_ORIENTATION_UNKNOWN)
{
if (abs (diffx) > MIN_MOVE || abs (diffy) > MIN_MOVE)
{
if (abs (diffx) > abs (diffy))
{
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_HORIZONTAL;
tr_tool->trans_info[XSHEAR] = 0.0;
}
else
{
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_VERTICAL;
tr_tool->trans_info[XSHEAR] = 0.0;
}
}
{
if (abs (diffx) > abs (diffy))
{
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_HORIZONTAL;
tr_tool->trans_info[XSHEAR] = 0.0;
}
else
{
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_VERTICAL;
tr_tool->trans_info[XSHEAR] = 0.0;
}
}
/* set the current coords to the last ones */
else
{
tr_tool->curx = tr_tool->lastx;
tr_tool->cury = tr_tool->lasty;
}
{
tr_tool->curx = tr_tool->lastx;
tr_tool->cury = tr_tool->lasty;
}
}
/* if the direction is known, keep track of the magnitude */
......@@ -229,38 +229,38 @@ gimp_shear_tool_motion (GimpTransformTool *tr_tool,
dir = tr_tool->trans_info[HORZ_OR_VERT];
switch (tr_tool->function)
{
case TRANSFORM_HANDLE_1:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] -= diffx;
else
tr_tool->trans_info[YSHEAR] -= diffy;
break;
case TRANSFORM_HANDLE_2:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] -= diffx;
else
tr_tool->trans_info[YSHEAR] += diffy;
break;
case TRANSFORM_HANDLE_3:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] += diffx;
else
tr_tool->trans_info[YSHEAR] -= diffy;
break;
case TRANSFORM_HANDLE_4:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] += diffx;
else
tr_tool->trans_info[YSHEAR] += diffy;
break;
default:
break;
}
{
case TRANSFORM_HANDLE_1:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] -= diffx;
else
tr_tool->trans_info[YSHEAR] -= diffy;
break;
case TRANSFORM_HANDLE_2:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] -= diffx;
else
tr_tool->trans_info[YSHEAR] += diffy;
break;
case TRANSFORM_HANDLE_3:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] += diffx;
else
tr_tool->trans_info[YSHEAR] -= diffy;
break;
case TRANSFORM_HANDLE_4:
if (dir == GIMP_ORIENTATION_HORIZONTAL)
tr_tool->trans_info[XSHEAR] += diffx;
else
tr_tool->trans_info[YSHEAR] += diffy;
break;
default:
break;
}
}
}
......@@ -270,6 +270,10 @@ gimp_shear_tool_recalc (GimpTransformTool *tr_tool,
{
gdouble amount;
if (tr_tool->trans_info[XSHEAR] == 0.0 &&
tr_tool->trans_info[YSHEAR] == 0.0)
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_UNKNOWN;
if (tr_tool->trans_info[HORZ_OR_VERT] == GIMP_ORIENTATION_HORIZONTAL)
amount = tr_tool->trans_info[XSHEAR];
else
......@@ -293,8 +297,10 @@ gimp_shear_tool_recalc (GimpTransformTool *tr_tool,
static void
shear_info_update (GimpTransformTool *tr_tool)
{
xshear_val = tr_tool->trans_info[XSHEAR];
yshear_val = tr_tool->trans_info[YSHEAR];
GimpShearTool *shear = GIMP_SHEAR_TOOL (tr_tool);
shear->xshear_val = tr_tool->trans_info[XSHEAR];
shear->yshear_val = tr_tool->trans_info[YSHEAR];
info_dialog_update (tr_tool->info_dialog);
info_dialog_show (tr_tool->info_dialog);
......@@ -312,6 +318,9 @@ shear_x_mag_changed (GtkWidget *widget,
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tr_tool));
if (tr_tool->trans_info[HORZ_OR_VERT] == GIMP_ORIENTATION_UNKNOWN)
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_HORIZONTAL;
tr_tool->trans_info[XSHEAR] = value;
gimp_shear_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
......@@ -334,6 +343,9 @@ shear_y_mag_changed (GtkWidget *widget,
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tr_tool));
if (tr_tool->trans_info[HORZ_OR_VERT] == GIMP_ORIENTATION_UNKNOWN)
tr_tool->trans_info[HORZ_OR_VERT] = GIMP_ORIENTATION_VERTICAL;
tr_tool->trans_info[YSHEAR] = value;
gimp_shear_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
......
......@@ -37,6 +37,9 @@ typedef struct _GimpShearToolClass GimpShearToolClass;
struct _GimpShearTool
{
GimpTransformTool parent_instance;
gdouble xshear_val;
gdouble yshear_val;
};
struct _GimpShearToolClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment