diff --git a/ChangeLog b/ChangeLog index e324acfa86..e13faea42c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2004-11-02 Michael Natterer + + * 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 * app/dialogs/image-scale-dialog.c (image_scale_callback): actually diff --git a/app/pdb/drawable_transform_cmds.c b/app/pdb/drawable_transform_cmds.c index 2901555756..f52c87e354 100644 --- a/app/pdb/drawable_transform_cmds.c +++ b/app/pdb/drawable_transform_cmds.c @@ -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); @@ -549,40 +536,27 @@ drawable_transform_rotate_invoker (Gimp *gimp, gboolean success = TRUE; Argument *return_args; GimpDrawable *drawable; - gdouble angle; + gint32 rotate_type; + gboolean auto_center; gint32 center_x; gint32 center_y; - gint32 transform_direction; - gint32 interpolation; - gboolean supersample; - gint32 recursion_level; 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; - angle = args[1].value.pdb_float; - - center_x = args[2].value.pdb_int; - - center_y = args[3].value.pdb_int; - - transform_direction = args[4].value.pdb_int; - if (transform_direction < GIMP_TRANSFORM_FORWARD || transform_direction > GIMP_TRANSFORM_BACKWARD) + rotate_type = args[1].value.pdb_int; + if (rotate_type < GIMP_ROTATE_90 || rotate_type > GIMP_ROTATE_270) success = FALSE; - interpolation = args[5].value.pdb_int; - if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC) - success = FALSE; + auto_center = args[2].value.pdb_int ? TRUE : FALSE; - supersample = args[6].value.pdb_int ? TRUE : FALSE; + center_x = args[3].value.pdb_int; - recursion_level = args[7].value.pdb_int; - if (recursion_level <= 0) - success = FALSE; + center_y = args[4].value.pdb_int; - clip_result = args[8].value.pdb_int ? TRUE : FALSE; + clip_result = args[5].value.pdb_int ? TRUE : FALSE; if (success) { @@ -593,24 +567,10 @@ drawable_transform_rotate_invoker (Gimp *gimp, if (success && gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height)) { - GimpMatrix3 matrix; - - /* Assemble the transformation matrix */ - gimp_transform_matrix_rotate_center (center_x, center_y, angle, - &matrix); - - if (progress) - gimp_progress_start (progress, _("Rotating..."), FALSE); - - /* Rotate the selection */ - success = gimp_drawable_transform_affine (drawable, context, - &matrix, transform_direction, - interpolation, supersample, - recursion_level, - clip_result, progress); - - if (progress) - gimp_progress_end (progress); + success = gimp_drawable_transform_rotate (drawable, context, + rotate_type, + auto_center, center_x, center_y, + clip_result); } } @@ -623,6 +583,155 @@ drawable_transform_rotate_invoker (Gimp *gimp, } 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; + gint32 interpolation; + gboolean supersample; + gint32 recursion_level; + 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; + + angle = args[1].value.pdb_float; + + auto_center = args[2].value.pdb_int ? TRUE : FALSE; + + center_x = args[3].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[6].value.pdb_int; + if (interpolation < GIMP_INTERPOLATION_NONE || interpolation > GIMP_INTERPOLATION_CUBIC) + success = FALSE; + + supersample = args[7].value.pdb_int ? TRUE : FALSE; + + recursion_level = args[8].value.pdb_int; + if (recursion_level <= 0) + success = FALSE; + + clip_result = args[9].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)) + { + GimpMatrix3 matrix; + + /* Assemble the transformation 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); + + /* Rotate the selection */ + success = gimp_drawable_transform_affine (drawable, context, + &matrix, transform_direction, + interpolation, supersample, + recursion_level, + clip_result, progress); + + if (progress) + gimp_progress_end (progress); + } + } + + 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)); + + return return_args; +} + +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); diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index a207a394e0..f8521a91fa 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -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); diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 40a0e506c4..936c3fe878 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -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 diff --git a/libgimp/gimpdrawabletransform_pdb.c b/libgimp/gimpdrawabletransform_pdb.c index 19e07420a9..1d33afd4e5 100644 --- a/libgimp/gimpdrawabletransform_pdb.c +++ b/libgimp/gimpdrawabletransform_pdb.c @@ -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. + * + * 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. + * + * Returns: The rotated drawable. + * + * Since: GIMP 2.2 + */ +gint32 +gimp_drawable_transform_rotate (gint32 drawable_ID, + GimpRotationType rotate_type, + gboolean auto_center, + gint center_x, + gint center_y, + gboolean clip_result) +{ + GimpParam *return_vals; + gint nreturn_vals; + gint32 ret_drawable_ID = -1; + + return_vals = gimp_run_procedure ("gimp_drawable_transform_rotate", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, rotate_type, + GIMP_PDB_INT32, auto_center, + GIMP_PDB_INT32, center_x, + GIMP_PDB_INT32, center_y, + GIMP_PDB_INT32, clip_result, + GIMP_PDB_END); + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + ret_drawable_ID = return_vals[1].data.d_drawable; + + gimp_destroy_params (return_vals, nreturn_vals); + + return ret_drawable_ID; +} + +/** + * gimp_drawable_transform_rotate_free: + * @drawable_ID: The affected drawable. * @angle: The angle of rotation (radians). + * @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. * @transform_direction: Direction of Transformation. @@ -262,24 +314,26 @@ gimp_drawable_transform_perspective (gint32 drawable_ID, * Since: GIMP 2.2 */ gint32 -gimp_drawable_transform_rotate (gint32 drawable_ID, - gdouble angle, - gint center_x, - gint center_y, - GimpTransformDirection transform_direction, - GimpInterpolationType interpolation, - gboolean supersample, - gint recursion_level, - gboolean clip_result) +gimp_drawable_transform_rotate_free (gint32 drawable_ID, + gdouble angle, + gboolean auto_center, + gint center_x, + gint center_y, + GimpTransformDirection transform_direction, + GimpInterpolationType interpolation, + gboolean supersample, + gint recursion_level, + gboolean clip_result) { GimpParam *return_vals; gint nreturn_vals; gint32 ret_drawable_ID = -1; - return_vals = gimp_run_procedure ("gimp_drawable_transform_rotate", + return_vals = gimp_run_procedure ("gimp_drawable_transform_rotate_free", &nreturn_vals, GIMP_PDB_DRAWABLE, drawable_ID, GIMP_PDB_FLOAT, angle, + GIMP_PDB_INT32, auto_center, GIMP_PDB_INT32, center_x, GIMP_PDB_INT32, center_y, GIMP_PDB_INT32, transform_direction, diff --git a/libgimp/gimpdrawabletransform_pdb.h b/libgimp/gimpdrawabletransform_pdb.h index e5ade84e4d..ab6ea91bf0 100644 --- a/libgimp/gimpdrawabletransform_pdb.h +++ b/libgimp/gimpdrawabletransform_pdb.h @@ -31,9 +31,8 @@ G_BEGIN_DECLS gint32 gimp_drawable_transform_flip (gint32 drawable_ID, GimpOrientationType flip_type, - gboolean center, + gboolean auto_center, gdouble axis, - GimpTransformDirection transform_direction, gboolean clip_result); gint32 gimp_drawable_transform_flip_free (gint32 drawable_ID, gdouble x0, @@ -60,7 +59,14 @@ gint32 gimp_drawable_transform_perspective (gint32 drawable_ID, gint recursion_level, gboolean clip_result); gint32 gimp_drawable_transform_rotate (gint32 drawable_ID, + GimpRotationType rotate_type, + gboolean auto_center, + gint center_x, + gint center_y, + gboolean clip_result); +gint32 gimp_drawable_transform_rotate_free (gint32 drawable_ID, gdouble angle, + gboolean auto_center, gint center_x, gint center_y, GimpTransformDirection transform_direction, diff --git a/tools/pdbgen/pdb/drawable_transform.pdb b/tools/pdbgen/pdb/drawable_transform.pdb index 59da4a2456..49ed7e4e52 100644 --- a/tools/pdbgen/pdb/drawable_transform.pdb +++ b/tools/pdbgen/pdb/drawable_transform.pdb @@ -68,9 +68,9 @@ BLURB 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. +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. @@ -83,12 +83,10 @@ HELP &drawable_arg, { name => 'flip_type', type => &std_orientation_enum, desc => 'Type of flip: %%desc%%' }, - { name => 'center', type => 'boolean', - desc => 'Whether to automatically position the axis in the image center' }, + { name => 'auto_center', type => 'boolean', + desc => 'Whether to automatically position the axis in the selection center' }, { name => 'axis', type => 'float', desc => 'coord. of flip axis' }, - { name => 'transform_direction', type => 'enum GimpTransformDirection', - desc => 'Direction of Transformation: { %%desc%% }' }, { name => 'clip_result', type => 'boolean', desc => 'Whether to clip results' } ); @@ -106,8 +104,8 @@ HELP 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); } } @@ -174,13 +172,10 @@ HELP /* 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); } @@ -262,12 +257,10 @@ HELP /* 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); @@ -294,10 +287,65 @@ HELP &pdb_misc; + @inargs = ( + &drawable_arg, + { name => 'rotate_type', type => 'enum GimpRotationType', + desc => 'Type of rotation: %%desc%%' }, + { name => 'auto_center', type => 'boolean', + desc => 'Whether to automatically rotate around the selection center' }, + { name => 'center_x', type => 'int32', + desc => 'The hor. coordinate of the center of rotation' }, + { name => 'center_y', type => 'int32', + desc => 'The vert. coordinate of the center of rotation' }, + { name => 'clip_result', type => 'boolean', + desc => 'Whether to clip results' } + ); + + @outargs = ( &drawable_out_arg('rotated') ); + + %invoke = ( + code => <<'CODE' +{ + 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); + } +} +CODE + ); +} + +sub drawable_transform_rotate_free { + $blurb = <<'BLURB'; +Rotate the specified drawable about given coordinates through the specified angle. +BLURB + + $help = <<'HELP'; +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. +HELP + + &pdb_misc; + @inargs = ( &drawable_arg, { name => 'angle', type => 'float', desc => 'The angle of rotation (radians)' }, + { name => 'auto_center', type => 'boolean', + desc => 'Whether to automatically rotate around the selection center' }, { name => 'center_x', type => 'int32', desc => 'The hor. coordinate of the center of rotation' }, { name => 'center_y', type => 'int32', @@ -320,8 +368,12 @@ HELP 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); @@ -406,11 +458,10 @@ HELP /* 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); @@ -473,8 +524,7 @@ HELP /* Shear the selection */ success = gimp_drawable_transform_affine (drawable, context, - &matrix, - transform_direction, + &matrix, transform_direction, interpolation, supersample, recursion_level, clip_result, progress); @@ -659,9 +709,9 @@ CODE @procs = qw(drawable_transform_flip drawable_transform_flip_free drawable_transform_perspective - drawable_transform_rotate drawable_transform_scale - drawable_transform_shear drawable_transform_2d - drawable_transform_matrix); + drawable_transform_rotate drawable_transform_rotate_free + drawable_transform_scale drawable_transform_shear + drawable_transform_2d drawable_transform_matrix); %exports = (app => [@procs], lib => [@procs]);