mirror of https://github.com/GNOME/gimp.git
app, pdb, plug-ins: get rid of (plug-in-rotate).
It can be reimplemented with (gimp-image-rotate) and (gimp-item-transform-rotate-simple), with even more capabilities for the latter. The item rotate procedure is a bit more tricky though, since it takes into account the selection. It means that either you want to just remove the selection before (that's what I did here, because this script was already losing the selection anyway), or you want to store the selection (with (gimp-channel-copy)), then reapply it (very likely with (gimp-channel-combine-masks)) at the end, after also rotating it appropriately the same way as the image if needed.
This commit is contained in:
parent
c26b2cd08f
commit
1fbd2acc84
|
@ -30,7 +30,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 721 procedures registered total */
|
||||
/* 720 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -564,56 +564,6 @@ plug_in_displace_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
plug_in_rotate_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpImage *image;
|
||||
GimpDrawable *drawable;
|
||||
gint angle;
|
||||
gboolean everything;
|
||||
|
||||
image = g_value_get_object (gimp_value_array_index (args, 1));
|
||||
drawable = g_value_get_object (gimp_value_array_index (args, 2));
|
||||
angle = g_value_get_int (gimp_value_array_index (args, 3));
|
||||
everything = g_value_get_boolean (gimp_value_array_index (args, 4));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GimpRotationType rotate_type = angle - 1;
|
||||
|
||||
if (everything)
|
||||
{
|
||||
gimp_image_rotate (image, context, rotate_type, progress);
|
||||
}
|
||||
else if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
||||
GIMP_PDB_ITEM_CONTENT, error))
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (drawable);
|
||||
gint off_x, off_y;
|
||||
gdouble center_x, center_y;
|
||||
|
||||
gimp_item_get_offset (item, &off_x, &off_y);
|
||||
|
||||
center_x = ((gdouble) off_x + (gdouble) gimp_item_get_width (item) / 2.0);
|
||||
center_y = ((gdouble) off_y + (gdouble) gimp_item_get_height (item) / 2.0);
|
||||
|
||||
gimp_item_rotate (item, context, rotate_type, center_x, center_y,
|
||||
GIMP_IS_CHANNEL (drawable));
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
void
|
||||
register_plug_in_compat_procs (GimpPDB *pdb)
|
||||
{
|
||||
|
@ -870,52 +820,4 @@ register_plug_in_compat_procs (GimpPDB *pdb)
|
|||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-plug-in-rotate
|
||||
*/
|
||||
procedure = gimp_procedure_new (plug_in_rotate_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"plug-in-rotate");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Rotates a layer or the whole image by 90, 180 or 270 degrees",
|
||||
"This plug-in does rotate the active layer or the whole image clockwise by multiples of 90 degrees. When the whole image is chosen, the image is resized if necessary.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Sven Neumann <sven@gimp.org>",
|
||||
"Sven Neumann",
|
||||
"2014");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_enum ("run-mode",
|
||||
"run mode",
|
||||
"The run mode",
|
||||
GIMP_TYPE_RUN_MODE,
|
||||
GIMP_RUN_INTERACTIVE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_image ("image",
|
||||
"image",
|
||||
"Input image (unused)",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_drawable ("drawable",
|
||||
"drawable",
|
||||
"Input drawable",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_int ("angle",
|
||||
"angle",
|
||||
"Angle { 90 (1), 180 (2), 270 (3) } degrees",
|
||||
1, 3, 1,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_boolean ("everything",
|
||||
"everything",
|
||||
"Rotate the whole image",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
|
|
@ -281,62 +281,6 @@ CODE
|
|||
|
||||
# We simplify the GEGL signature, reducing tile width and height to just size
|
||||
|
||||
sub plug_in_rotate {
|
||||
$blurb = 'Rotates a layer or the whole image by 90, 180 or 270 degrees';
|
||||
|
||||
$help = <<'HELP';
|
||||
This plug-in does rotate the active layer or the whole image clockwise
|
||||
by multiples of 90 degrees. When the whole image is chosen, the image
|
||||
is resized if necessary.
|
||||
HELP
|
||||
|
||||
&neo_pdb_misc;
|
||||
$date = '2014';
|
||||
|
||||
@inargs = (
|
||||
{ name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
|
||||
desc => 'The run mode' },
|
||||
{ name => 'image', type => 'image',
|
||||
desc => 'Input image (unused)' },
|
||||
{ name => 'drawable', type => 'drawable',
|
||||
desc => 'Input drawable' },
|
||||
{ name => 'angle', type => '1 <= int32 <= 3',
|
||||
desc => 'Angle { 90 (1), 180 (2), 270 (3) } degrees' },
|
||||
{ name => 'everything', type => 'boolean',
|
||||
desc => 'Rotate the whole image' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GimpRotationType rotate_type = angle - 1;
|
||||
|
||||
if (everything)
|
||||
{
|
||||
gimp_image_rotate (image, context, rotate_type, progress);
|
||||
}
|
||||
else if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
|
||||
GIMP_PDB_ITEM_CONTENT, error))
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (drawable);
|
||||
gint off_x, off_y;
|
||||
gdouble center_x, center_y;
|
||||
|
||||
gimp_item_get_offset (item, &off_x, &off_y);
|
||||
|
||||
center_x = ((gdouble) off_x + (gdouble) gimp_item_get_width (item) / 2.0);
|
||||
center_y = ((gdouble) off_y + (gdouble) gimp_item_get_height (item) / 2.0);
|
||||
|
||||
gimp_item_rotate (item, context, rotate_type, center_x, center_y,
|
||||
GIMP_IS_CHANNEL (drawable));
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
$extra{app}->{code} = <<'CODE';
|
||||
static GeglNode *
|
||||
wrap_in_graph (GeglNode *node)
|
||||
|
@ -636,8 +580,7 @@ CODE
|
|||
@procs = qw(plug_in_autocrop
|
||||
plug_in_autocrop_layer
|
||||
plug_in_bump_map
|
||||
plug_in_displace
|
||||
plug_in_rotate);
|
||||
plug_in_displace);
|
||||
|
||||
%exports = (app => [@procs], lib => []);
|
||||
|
||||
|
|
|
@ -121,7 +121,10 @@
|
|||
(/ (- width crop-width) 2)
|
||||
(/ (- height crop-height) 2))
|
||||
(if (< ratio 1)
|
||||
(plug-in-rotate RUN-NONINTERACTIVE image pic-layer 1 FALSE)
|
||||
(begin
|
||||
(gimp-selection-none image)
|
||||
(gimp-item-transform-rotate-simple pic-layer ROTATE-DEGREES90 TRUE 0 0)
|
||||
)
|
||||
)
|
||||
|
||||
; add the background layer
|
||||
|
@ -230,7 +233,7 @@
|
|||
|
||||
; eventually rotate the whole thing back
|
||||
(if (< ratio 1)
|
||||
(plug-in-rotate RUN-NONINTERACTIVE image pic-layer 3 TRUE)
|
||||
(gimp-image-rotate image ROTATE-DEGREES270)
|
||||
)
|
||||
|
||||
; clean up after the script
|
||||
|
|
Loading…
Reference in New Issue