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

renamed parameter "center" to "auto_center" and removed

2004-11-02  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/drawable_transform.pdb (flip): renamed
	parameter "center" to "auto_center" and removed
	"transform_direction". Renamed rotate() to rotate_free() and
	added a "gboolean auto_center" parameter. Added new function
	rotate() which takes enum GimpRotationType instead of an
	arbiatrary angle so the flip and rotate APIs are symmetric.

	* libgimp/gimp.def: added the gimp_drawable_transform_* stuff.

	* app/pdb/drawable_transform_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpdrawabletransform_pdb.[ch]: regenerated.
parent fabdf25d
2004-11-02 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/drawable_transform.pdb (flip): renamed
parameter "center" to "auto_center" and removed
"transform_direction". Renamed rotate() to rotate_free() and
added a "gboolean auto_center" parameter. Added new function
rotate() which takes enum GimpRotationType instead of an
arbiatrary angle so the flip and rotate APIs are symmetric.
* libgimp/gimp.def: added the gimp_drawable_transform_* stuff.
* app/pdb/drawable_transform_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpdrawabletransform_pdb.[ch]: regenerated.
2004-11-02 Sven Neumann <sven@gimp.org>
 
* app/dialogs/image-scale-dialog.c (image_scale_callback): actually
......
......@@ -41,6 +41,7 @@ static ProcRecord drawable_transform_flip_proc;
static ProcRecord drawable_transform_flip_free_proc;
static ProcRecord drawable_transform_perspective_proc;
static ProcRecord drawable_transform_rotate_proc;
static ProcRecord drawable_transform_rotate_free_proc;
static ProcRecord drawable_transform_scale_proc;
static ProcRecord drawable_transform_shear_proc;
static ProcRecord drawable_transform_2d_proc;
......@@ -53,6 +54,7 @@ register_drawable_transform_procs (Gimp *gimp)
procedural_db_register (gimp, &drawable_transform_flip_free_proc);
procedural_db_register (gimp, &drawable_transform_perspective_proc);
procedural_db_register (gimp, &drawable_transform_rotate_proc);
procedural_db_register (gimp, &drawable_transform_rotate_free_proc);
procedural_db_register (gimp, &drawable_transform_scale_proc);
procedural_db_register (gimp, &drawable_transform_shear_proc);
procedural_db_register (gimp, &drawable_transform_2d_proc);
......@@ -69,9 +71,8 @@ drawable_transform_flip_invoker (Gimp *gimp,
Argument *return_args;
GimpDrawable *drawable;
gint32 flip_type;
gboolean center;
gboolean auto_center;
gdouble axis;
gint32 transform_direction;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
......@@ -82,15 +83,11 @@ drawable_transform_flip_invoker (Gimp *gimp,
if (flip_type < GIMP_ORIENTATION_HORIZONTAL || flip_type > GIMP_ORIENTATION_VERTICAL)
success = FALSE;
center = args[2].value.pdb_int ? TRUE : FALSE;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
axis = args[3].value.pdb_float;
transform_direction = args[4].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
clip_result = args[5].value.pdb_int ? TRUE : FALSE;
clip_result = args[4].value.pdb_int ? TRUE : FALSE;
if (success)
{
......@@ -102,8 +99,8 @@ drawable_transform_flip_invoker (Gimp *gimp,
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
success = gimp_drawable_transform_flip (drawable, context,
transform_direction,
center, axis,
flip_type,
auto_center, axis,
clip_result);
}
}
......@@ -130,19 +127,14 @@ static ProcArg drawable_transform_flip_inargs[] =
},
{
GIMP_PDB_INT32,
"center",
"Whether to automatically position the axis in the image center"
"auto_center",
"Whether to automatically position the axis in the selection center"
},
{
GIMP_PDB_FLOAT,
"axis",
"coord. of flip axis"
},
{
GIMP_PDB_INT32,
"transform_direction",
"Direction of Transformation: { GIMP_TRANSFORM_FORWARD (0), GIMP_TRANSFORM_BACKWARD (1) }"
},
{
GIMP_PDB_INT32,
"clip_result",
......@@ -163,13 +155,13 @@ static ProcRecord drawable_transform_flip_proc =
{
"gimp_drawable_transform_flip",
"Flip the specified drawable either vertically or horizontally.",
"This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If center is set to true, the flip is around the image center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable.",
"This procedure flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If auto_center is set to true, the flip is around the selection's center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipped drawable.",
"João S. O. Bueno Calligaris",
"João S. O. Bueno Calligaris",
"2004",
NULL,
GIMP_INTERNAL,
6,
5,
drawable_transform_flip_inargs,
1,
drawable_transform_flip_outargs,
......@@ -244,13 +236,10 @@ drawable_transform_flip_free_invoker (Gimp *gimp,
/* Transform the selection */
success = gimp_drawable_transform_affine (drawable, context,
&matrix,
transform_direction,
interpolation,
supersample,
&matrix, transform_direction,
interpolation, supersample,
recursion_level,
clip_result,
progress);
clip_result, progress);
if (progress)
gimp_progress_end (progress);
}
......@@ -420,12 +409,10 @@ drawable_transform_perspective_invoker (Gimp *gimp,
/* Perspective the selection */
success = gimp_drawable_transform_affine (drawable, context,
&matrix,
transform_direction,
&matrix, transform_direction,
interpolation, supersample,
recursion_level,
clip_result,
progress);
clip_result, progress);
if (progress)
gimp_progress_end (progress);
......@@ -545,11 +532,127 @@ drawable_transform_rotate_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gint32 rotate_type;
gboolean auto_center;
gint32 center_x;
gint32 center_y;
gboolean clip_result;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable))))
success = FALSE;
rotate_type = args[1].value.pdb_int;
if (rotate_type < GIMP_ROTATE_90 || rotate_type > GIMP_ROTATE_270)
success = FALSE;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
center_x = args[3].value.pdb_int;
center_y = args[4].value.pdb_int;
clip_result = args[5].value.pdb_int ? TRUE : FALSE;
if (success)
{
gint x, y, width, height;
success = gimp_item_is_attached (GIMP_ITEM (drawable));
if (success &&
gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
success = gimp_drawable_transform_rotate (drawable, context,
rotate_type,
auto_center, center_x, center_y,
clip_result);
}
}
return_args = procedural_db_return_args (&drawable_transform_rotate_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
return return_args;
}
static ProcArg drawable_transform_rotate_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_INT32,
"rotate_type",
"Type of rotation: GIMP_ROTATE_90 (0), GIMP_ROTATE_180 (1), GIMP_ROTATE_270 (2)"
},
{
GIMP_PDB_INT32,
"auto_center",
"Whether to automatically rotate around the selection center"
},
{
GIMP_PDB_INT32,
"center_x",
"The hor. coordinate of the center of rotation"
},
{
GIMP_PDB_INT32,
"center_y",
"The vert. coordinate of the center of rotation"
},
{
GIMP_PDB_INT32,
"clip_result",
"Whether to clip results"
}
};
static ProcArg drawable_transform_rotate_outargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The rotated drawable"
}
};
static ProcRecord drawable_transform_rotate_proc =
{
"gimp_drawable_transform_rotate",
"Rotate the specified drawable about given coordinates through the specified angle.",
"This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
"João S. O. Bueno Calligaris",
"João S. O. Bueno Calligaris",
"2004",
NULL,
GIMP_INTERNAL,
6,
drawable_transform_rotate_inargs,
1,
drawable_transform_rotate_outargs,
{ { drawable_transform_rotate_invoker } }
};
static Argument *
drawable_transform_rotate_free_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gdouble angle;
gboolean auto_center;
gint32 center_x;
gint32 center_y;
gint32 transform_direction;
......@@ -564,25 +667,27 @@ drawable_transform_rotate_invoker (Gimp *gimp,
angle = args[1].value.pdb_float;
center_x = args[2].value.pdb_int;
auto_center = args[2].value.pdb_int ? TRUE : FALSE;
center_y = args[3].value.pdb_int;
center_x = args[3].value.pdb_int;
transform_direction = args[4].value.pdb_int;
center_y = args[4].value.pdb_int;
transform_direction = args[5].value.pdb_int;
if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD)
success = FALSE;
interpolation = args[5].value.pdb_int;
interpolation = args[6].value.pdb_int;
if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC)
success = FALSE;
supersample = args[6].value.pdb_int ? TRUE : FALSE;
supersample = args[7].value.pdb_int ? TRUE : FALSE;
recursion_level = args[7].value.pdb_int;
recursion_level = args[8].value.pdb_int;
if (recursion_level <= 0)
success = FALSE;
clip_result = args[8].value.pdb_int ? TRUE : FALSE;
clip_result = args[9].value.pdb_int ? TRUE : FALSE;
if (success)
{
......@@ -596,8 +701,12 @@ drawable_transform_rotate_invoker (Gimp *gimp,
GimpMatrix3 matrix;
/* Assemble the transformation matrix */
gimp_transform_matrix_rotate_center (center_x, center_y, angle,
&matrix);
if (auto_center)
gimp_transform_matrix_rotate (x, y, width, height, angle,
&matrix);
else
gimp_transform_matrix_rotate_center (center_x, center_y, angle,
&matrix);
if (progress)
gimp_progress_start (progress, _("Rotating..."), FALSE);
......@@ -614,7 +723,7 @@ drawable_transform_rotate_invoker (Gimp *gimp,
}
}
return_args = procedural_db_return_args (&drawable_transform_rotate_proc, success);
return_args = procedural_db_return_args (&drawable_transform_rotate_free_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_item_get_ID (GIMP_ITEM (drawable));
......@@ -622,7 +731,7 @@ drawable_transform_rotate_invoker (Gimp *gimp,
return return_args;
}
static ProcArg drawable_transform_rotate_inargs[] =
static ProcArg drawable_transform_rotate_free_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
......@@ -634,6 +743,11 @@ static ProcArg drawable_transform_rotate_inargs[] =
"angle",
"The angle of rotation (radians)"
},
{
GIMP_PDB_INT32,
"auto_center",
"Whether to automatically rotate around the selection center"
},
{
GIMP_PDB_INT32,
"center_x",
......@@ -671,7 +785,7 @@ static ProcArg drawable_transform_rotate_inargs[] =
}
};
static ProcArg drawable_transform_rotate_outargs[] =
static ProcArg drawable_transform_rotate_free_outargs[] =
{
{
GIMP_PDB_DRAWABLE,
......@@ -680,9 +794,9 @@ static ProcArg drawable_transform_rotate_outargs[] =
}
};
static ProcRecord drawable_transform_rotate_proc =
static ProcRecord drawable_transform_rotate_free_proc =
{
"gimp_drawable_transform_rotate",
"gimp_drawable_transform_rotate_free",
"Rotate the specified drawable about given coordinates through the specified angle.",
"This function rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
"João S. O. Bueno Calligaris",
......@@ -690,11 +804,11 @@ static ProcRecord drawable_transform_rotate_proc =
"2004",
NULL,
GIMP_INTERNAL,
9,
drawable_transform_rotate_inargs,
10,
drawable_transform_rotate_free_inargs,
1,
drawable_transform_rotate_outargs,
{ { drawable_transform_rotate_invoker } }
drawable_transform_rotate_free_outargs,
{ { drawable_transform_rotate_free_invoker } }
};
static Argument *
......@@ -767,11 +881,10 @@ drawable_transform_scale_invoker (Gimp *gimp,
/* Scale the selection */
success = gimp_drawable_transform_affine (drawable, context,
&matrix,
transform_direction,
&matrix, transform_direction,
interpolation, supersample,
recursion_level,
clip_result, progress);
clip_result, progress);
if (progress)
gimp_progress_end (progress);
......@@ -930,8 +1043,7 @@ drawable_transform_shear_invoker (Gimp *gimp,
/* Shear the selection */
success = gimp_drawable_transform_affine (drawable, context,
&matrix,
transform_direction,
&matrix, transform_direction,
interpolation, supersample,
recursion_level,
clip_result, progress);
......
......@@ -74,7 +74,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 422 procedures registered total */
/* 423 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -95,7 +95,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Channel"), 0.04);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.062);
(* status_callback) (NULL, _("Color"), 0.061);
register_color_procs (gimp);
(* status_callback) (NULL, _("Context"), 0.097);
......@@ -107,58 +107,58 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Display procedures"), 0.156);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.166);
(* status_callback) (NULL, _("Drawable procedures"), 0.165);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Transformation procedures"), 0.244);
(* status_callback) (NULL, _("Transformation procedures"), 0.243);
register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.263);
(* status_callback) (NULL, _("Edit procedures"), 0.265);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.282);
(* status_callback) (NULL, _("File Operations"), 0.284);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.303);
(* status_callback) (NULL, _("Floating selections"), 0.305);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.318);
(* status_callback) (NULL, _("Font UI"), 0.319);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.325);
(* status_callback) (NULL, _("Fonts"), 0.326);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.329);
(* status_callback) (NULL, _("Gimprc procedures"), 0.331);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.344);
(* status_callback) (NULL, _("Gradient"), 0.345);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.412);
(* status_callback) (NULL, _("Gradient UI"), 0.414);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.419);
(* status_callback) (NULL, _("Gradients"), 0.421);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.431);
(* status_callback) (NULL, _("Guide procedures"), 0.433);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.445);
(* status_callback) (NULL, _("Help procedures"), 0.447);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.448);
(* status_callback) (NULL, _("Image"), 0.449);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.595);
(* status_callback) (NULL, _("Layer"), 0.596);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.656);
(* status_callback) (NULL, _("Message procedures"), 0.657);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.664);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.668);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.669);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.704);
......@@ -167,22 +167,22 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Palette UI"), 0.73);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.737);
(* status_callback) (NULL, _("Palettes"), 0.738);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.746);
(* status_callback) (NULL, _("Parasite procedures"), 0.747);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.775);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.81);
(* status_callback) (NULL, _("Pattern"), 0.811);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.815);
(* status_callback) (NULL, _("Pattern UI"), 0.816);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.822);
(* status_callback) (NULL, _("Patterns"), 0.823);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.832);
......@@ -197,7 +197,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Image mask"), 0.877);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.919);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.92);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.931);
......
......@@ -131,6 +131,15 @@ EXPORTS
gimp_drawable_set_pixel
gimp_drawable_set_tattoo
gimp_drawable_set_visible
gimp_drawable_transform_flip
gimp_drawable_transform_flip_free
gimp_drawable_transform_perspective
gimp_drawable_transform_rotate
gimp_drawable_transform_rotate_free
gimp_drawable_transform_scale
gimp_drawable_transform_shear
gimp_drawable_transform_2d
gimp_drawable_transform_matrix
gimp_drawable_type
gimp_drawable_type_with_alpha
gimp_drawable_update
......
......@@ -29,9 +29,8 @@
* gimp_drawable_transform_flip:
* @drawable_ID: The affected drawable.
* @flip_type: Type of flip.
* @center: Whether to automatically position the axis in the image center.
* @auto_center: Whether to automatically position the axis in the selection center.
* @axis: coord. of flip axis.
* @transform_direction: Direction of Transformation.
* @clip_result: Whether to clip results.
*
* Flip the specified drawable either vertically or horizontally.
......@@ -39,11 +38,11 @@
* This procedure flips the specified drawable if no selection exists.
* If a selection exists, the portion of the drawable which lies under
* the selection is cut from the drawable and made into a floating
* selection which is then flipped. If center is set to true, the flip
* is around the image center. Otherwise, the coordinate of the axis
* needs to be specified. The return value is the ID of the flipped
* drawable. If there was no selection, this will be equal to the
* drawable ID supplied as input. Otherwise, this will be the newly
* selection which is then flipped. If auto_center is set to true, the
* flip is around the selection's center. Otherwise, the coordinate of
* the axis needs to be specified. The return value is the ID of the
* flipped drawable. If there was no selection, this will be equal to
* the drawable ID supplied as input. Otherwise, this will be the newly
* created and flipped drawable.
*
* Returns: The flipped drawable.
......@@ -51,12 +50,11 @@
* Since: GIMP 2.2
*/
gint32
gimp_drawable_transform_flip (gint32 drawable_ID,
GimpOrientationType flip_type,
gboolean center,
gdouble axis,
GimpTransformDirection transform_direction,
gboolean clip_result)
gimp_drawable_transform_flip (gint32 drawable_ID,
GimpOrientationType flip_type,
gboolean auto_center,
gdouble axis,
gboolean clip_result)
{
GimpParam *return_vals;
gint nreturn_vals;
......@@ -66,9 +64,8 @@ gimp_drawable_transform_flip (gint32 drawable_ID,
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_INT32, flip_type,
GIMP_PDB_INT32, center,
GIMP_PDB_INT32, auto_center,
GIMP_PDB_FLOAT, axis,
GIMP_PDB_INT32, transform_direction,
GIMP_PDB_INT32, clip_result,
GIMP_PDB_END);
......@@ -237,7 +234,62 @@ gimp_drawable_transform_perspective (gint32 drawable_ID,
/**
* gimp_drawable_transform_rotate:
* @drawable_ID: The affected drawable.
* @rotate_type: Type of rotation.
* @auto_center: Whether to automatically rotate around the selection center.
* @center_x: The hor. coordinate of the center of rotation.
* @center_y: The vert. coordinate of the center of rotation.
* @clip_result: Whether to clip results.
*
* Rotate the specified drawable about given coordinates through the
* specified angle.