[gimp] app: change gimp_pickable_auto_shrink()'s parameters
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: change gimp_pickable_auto_shrink()'s parameters
- Date: Sun, 25 Sep 2016 20:41:17 +0000 (UTC)
commit ea98f9967ef680f181fe78a593c0c7a3e9b7ac5d
Author: Michael Natterer <mitch gimp org>
Date: Sun Sep 25 22:40:28 2016 +0200
app: change gimp_pickable_auto_shrink()'s parameters
from x1, y1, x2, y2 to x, y, width, height.
app/actions/image-commands.c | 7 ++--
app/actions/layers-commands.c | 17 ++++++----
app/core/gimppickable-auto-shrink.c | 54 ++++++++++++++++++-----------------
app/core/gimppickable-auto-shrink.h | 16 +++++-----
app/pdb/plug-in-compat-cmds.c | 33 +++++++++------------
app/tools/gimprectangletool.c | 26 ++++++++--------
tools/pdbgen/pdb/plug_in_compat.pdb | 33 +++++++++------------
7 files changed, 91 insertions(+), 95 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 06fbb28..762a291 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -724,7 +724,8 @@ image_crop_to_content_cmd_callback (GtkAction *action,
{
GimpImage *image;
GtkWidget *widget;
- gint x1, y1, x2, y2;
+ gint x, y;
+ gint width, height;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
@@ -732,11 +733,11 @@ image_crop_to_content_cmd_callback (GtkAction *action,
0, 0,
gimp_image_get_width (image),
gimp_image_get_height (image),
- &x1, &y1, &x2, &y2))
+ &x, &y, &width, &height))
{
case GIMP_AUTO_SHRINK_SHRINK:
gimp_image_crop (image, action_data_get_context (data),
- x1, y1, x2 - x1, y2 - y1, TRUE);
+ x, y, width, height, TRUE);
gimp_image_flush (image);
break;
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index b146bdf..998b95e 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -743,7 +743,8 @@ layers_crop_to_selection_cmd_callback (GtkAction *action,
{
gimp_message_literal (image->gimp,
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
- _("Cannot crop because the current selection is empty."));
+ _("Cannot crop because the current selection "
+ "is empty."));
return;
}
@@ -768,7 +769,8 @@ layers_crop_to_content_cmd_callback (GtkAction *action,
GimpImage *image;
GimpLayer *layer;
GtkWidget *widget;
- gint x1, y1, x2, y2;
+ gint x, y;
+ gint width, height;
return_if_no_layer (image, layer, data);
return_if_no_widget (widget, data);
@@ -776,14 +778,14 @@ layers_crop_to_content_cmd_callback (GtkAction *action,
0, 0,
gimp_item_get_width (GIMP_ITEM (layer)),
gimp_item_get_height (GIMP_ITEM (layer)),
- &x1, &y1, &x2, &y2))
+ &x, &y, &width, &height))
{
case GIMP_AUTO_SHRINK_SHRINK:
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
_("Crop Layer to Content"));
gimp_item_resize (GIMP_ITEM (layer), action_data_get_context (data),
- x2 - x1, y2 - y1, -x1, -y1);
+ width, height, -x, -y);
gimp_image_undo_group_end (image);
gimp_image_flush (image);
@@ -792,13 +794,15 @@ layers_crop_to_content_cmd_callback (GtkAction *action,
case GIMP_AUTO_SHRINK_EMPTY:
gimp_message_literal (image->gimp,
G_OBJECT (widget), GIMP_MESSAGE_INFO,
- _("Cannot crop because the active layer has no content."));
+ _("Cannot crop because the active layer "
+ "has no content."));
break;
case GIMP_AUTO_SHRINK_UNSHRINKABLE:
gimp_message_literal (image->gimp,
G_OBJECT (widget), GIMP_MESSAGE_INFO,
- _("Cannot crop because the active layer is already cropped to its content."));
+ _("Cannot crop because the active layer "
+ "is already cropped to its content."));
break;
}
}
@@ -1319,7 +1323,6 @@ layers_resize_callback (GtkWidget *dialog,
gimp_item_resize (item, context,
width, height, offset_x, offset_y);
-
gimp_image_flush (gimp_item_get_image (item));
}
else
diff --git a/app/core/gimppickable-auto-shrink.c b/app/core/gimppickable-auto-shrink.c
index fb7e416..89171bb 100644
--- a/app/core/gimppickable-auto-shrink.c
+++ b/app/core/gimppickable-auto-shrink.c
@@ -60,14 +60,14 @@ static gboolean gimp_pickable_colors_alpha (guchar *col1,
GimpAutoShrink
gimp_pickable_auto_shrink (GimpPickable *pickable,
- gint start_x1,
- gint start_y1,
- gint start_x2,
- gint start_y2,
- gint *shrunk_x1,
- gint *shrunk_y1,
- gint *shrunk_x2,
- gint *shrunk_y2)
+ gint start_x,
+ gint start_y,
+ gint start_width,
+ gint start_height,
+ gint *shrunk_x,
+ gint *shrunk_y,
+ gint *shrunk_width,
+ gint *shrunk_height)
{
GeglBuffer *buffer;
GeglRectangle rect;
@@ -81,10 +81,10 @@ gimp_pickable_auto_shrink (GimpPickable *pickable,
GimpAutoShrink retval = GIMP_AUTO_SHRINK_UNSHRINKABLE;
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE);
- g_return_val_if_fail (shrunk_x1 != NULL, FALSE);
- g_return_val_if_fail (shrunk_y1 != NULL, FALSE);
- g_return_val_if_fail (shrunk_x2 != NULL, FALSE);
- g_return_val_if_fail (shrunk_y2 != NULL, FALSE);
+ g_return_val_if_fail (shrunk_x != NULL, FALSE);
+ g_return_val_if_fail (shrunk_y != NULL, FALSE);
+ g_return_val_if_fail (shrunk_width != NULL, FALSE);
+ g_return_val_if_fail (shrunk_height != NULL, FALSE);
gimp_set_busy (gimp_pickable_get_image (pickable)->gimp);
@@ -98,16 +98,16 @@ gimp_pickable_auto_shrink (GimpPickable *pickable,
buffer = gimp_pickable_get_buffer (pickable);
- x1 = MAX (start_x1, 0);
- y1 = MAX (start_y1, 0);
- x2 = MIN (start_x2, gegl_buffer_get_width (buffer));
- y2 = MIN (start_y2, gegl_buffer_get_height (buffer));
+ x1 = MAX (start_x, 0);
+ y1 = MAX (start_y, 0);
+ x2 = MIN (start_x + start_width, gegl_buffer_get_width (buffer));
+ y2 = MIN (start_y + start_height, gegl_buffer_get_height (buffer));
/* By default, return the start values */
- *shrunk_x1 = x1;
- *shrunk_y1 = y1;
- *shrunk_x2 = x2;
- *shrunk_y2 = y2;
+ *shrunk_x = x1;
+ *shrunk_y = y1;
+ *shrunk_width = x2 - x1;
+ *shrunk_height = y2 - y1;
format = babl_format ("R'G'B'A u8");
@@ -210,13 +210,15 @@ gimp_pickable_auto_shrink (GimpPickable *pickable,
}
x2 = x + 1;
- if (x1 != start_x1 || y1 != start_y1 ||
- x2 != start_x2 || y2 != start_y2)
+ if (x1 != start_x ||
+ y1 != start_y ||
+ x2 - x1 != start_width ||
+ y2 - y1 != start_height)
{
- *shrunk_x1 = x1;
- *shrunk_y1 = y1;
- *shrunk_x2 = x2;
- *shrunk_y2 = y2;
+ *shrunk_x = x1;
+ *shrunk_y = y1;
+ *shrunk_width = x2 - x1;
+ *shrunk_height = y2 - y1;
retval = GIMP_AUTO_SHRINK_SHRINK;
}
diff --git a/app/core/gimppickable-auto-shrink.h b/app/core/gimppickable-auto-shrink.h
index f94f62c..bcc662f 100644
--- a/app/core/gimppickable-auto-shrink.h
+++ b/app/core/gimppickable-auto-shrink.h
@@ -28,14 +28,14 @@ typedef enum
GimpAutoShrink gimp_pickable_auto_shrink (GimpPickable *pickable,
- gint x1,
- gint y1,
- gint x2,
- gint y2,
- gint *shrunk_x1,
- gint *shrunk_y1,
- gint *shrunk_x2,
- gint *shrunk_y2);
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gint *shrunk_x,
+ gint *shrunk_y,
+ gint *shrunk_width,
+ gint *shrunk_height);
#endif /* __GIMP_PICKABLE_AUTO_SHRINK_H__ */
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index d0b8545..243299a 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -581,42 +581,37 @@ plug_in_autocrop_invoker (GimpProcedure *procedure,
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error))
{
- gint x1, y1, x2, y2;
+ gint x, y, width, height;
gint off_x, off_y;
gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable),
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
- &x1, &y1, &x2, &y2);
+ &x, &y, &width, &height);
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
-
- x1 += off_x; x2 += off_x;
- y1 += off_y; y2 += off_y;
+ x += off_x;
+ y += off_y;
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
_("Autocrop image"));
- if (x1 < 0 || y1 < 0 ||
- x2 > gimp_image_get_width (image) ||
- y2 > gimp_image_get_height (image))
+ if (x < 0 ||
+ y < 0 ||
+ x + width > gimp_image_get_width (image) ||
+ y + height > gimp_image_get_height (image))
{
/*
* partially outside the image area, we need to
* resize the image to be able to crop properly.
*/
- gimp_image_resize (image, context,
- x2 - x1, y2 - y1, -x1, -y1, NULL);
-
- x2 -= x1;
- y2 -= y1;
+ gimp_image_resize (image, context, width, height, -x, -y, NULL);
- x1 = y1 = 0;
+ x = y = 0;
}
- gimp_image_crop (image, context,
- x1, y1, x2 - x1, y2 - y1, TRUE);
+ gimp_image_crop (image, context, x, y, width, height, TRUE);
gimp_image_undo_group_end (image);
}
@@ -649,7 +644,7 @@ plug_in_autocrop_layer_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error))
{
GimpLayer *layer = gimp_image_get_active_layer (image);
- gint x1, y1, x2, y2;
+ gint x, y, width, height;
if (layer)
{
@@ -657,14 +652,14 @@ plug_in_autocrop_layer_invoker (GimpProcedure *procedure,
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
- &x1, &y1, &x2, &y2))
+ &x, &y, &width, &height))
{
case GIMP_AUTO_SHRINK_SHRINK:
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
_("Autocrop layer"));
gimp_item_resize (GIMP_ITEM (layer), context,
- x2 - x1, y2 - y1, -x1, -y1);
+ width, height, -x, -y);
gimp_image_undo_group_end (image);
break;
diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c
index 79ec0ba..c46e9c5 100644
--- a/app/tools/gimprectangletool.c
+++ b/app/tools/gimprectangletool.c
@@ -2500,10 +2500,10 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool)
gint offset_y = 0;
gint x1, y1;
gint x2, y2;
- gint shrunk_x1;
- gint shrunk_y1;
- gint shrunk_x2;
- gint shrunk_y2;
+ gint shrunk_x;
+ gint shrunk_y;
+ gint shrunk_width;
+ gint shrunk_height;
gboolean shrink_merged;
if (! display)
@@ -2540,11 +2540,11 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool)
}
switch (gimp_pickable_auto_shrink (pickable,
- x1, y1, x2, y2,
- &shrunk_x1,
- &shrunk_y1,
- &shrunk_x2,
- &shrunk_y2))
+ x1, y1, x2 - x1, y2 - y1,
+ &shrunk_x,
+ &shrunk_y,
+ &shrunk_width,
+ &shrunk_height))
{
case GIMP_AUTO_SHRINK_SHRINK:
{
@@ -2553,10 +2553,10 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool)
gimp_draw_tool_pause (GIMP_DRAW_TOOL (rect_tool));
private->function = GIMP_RECTANGLE_TOOL_AUTO_SHRINK;
- private->x1 = offset_x + shrunk_x1;
- private->y1 = offset_y + shrunk_y1;
- private->x2 = offset_x + shrunk_x2;
- private->y2 = offset_y + shrunk_y2;
+ private->x1 = offset_x + shrunk_x;
+ private->y1 = offset_y + shrunk_y;
+ private->x2 = offset_x + shrunk_x + shrunk_width;
+ private->y2 = offset_y + shrunk_y + shrunk_height;
gimp_rectangle_tool_update_int_rect (rect_tool);
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 9c0c3bf..0af91c2 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -274,42 +274,37 @@ HELP
if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error))
{
- gint x1, y1, x2, y2;
+ gint x, y, width, height;
gint off_x, off_y;
gimp_pickable_auto_shrink (GIMP_PICKABLE (drawable),
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
- &x1, &y1, &x2, &y2);
+ &x, &y, &width, &height);
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
-
- x1 += off_x; x2 += off_x;
- y1 += off_y; y2 += off_y;
+ x += off_x;
+ y += off_y;
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
_("Autocrop image"));
- if (x1 < 0 || y1 < 0 ||
- x2 > gimp_image_get_width (image) ||
- y2 > gimp_image_get_height (image))
+ if (x < 0 ||
+ y < 0 ||
+ x + width > gimp_image_get_width (image) ||
+ y + height > gimp_image_get_height (image))
{
/*
* partially outside the image area, we need to
* resize the image to be able to crop properly.
*/
- gimp_image_resize (image, context,
- x2 - x1, y2 - y1, -x1, -y1, NULL);
-
- x2 -= x1;
- y2 -= y1;
+ gimp_image_resize (image, context, width, height, -x, -y, NULL);
- x1 = y1 = 0;
+ x = y = 0;
}
- gimp_image_crop (image, context,
- x1, y1, x2 - x1, y2 - y1, TRUE);
+ gimp_image_crop (image, context, x, y, width, height, TRUE);
gimp_image_undo_group_end (image);
}
@@ -347,7 +342,7 @@ HELP
GIMP_PDB_ITEM_CONTENT, error))
{
GimpLayer *layer = gimp_image_get_active_layer (image);
- gint x1, y1, x2, y2;
+ gint x, y, width, height;
if (layer)
{
@@ -355,14 +350,14 @@ HELP
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)),
- &x1, &y1, &x2, &y2))
+ &x, &y, &width, &height))
{
case GIMP_AUTO_SHRINK_SHRINK:
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
_("Autocrop layer"));
gimp_item_resize (GIMP_ITEM (layer), context,
- x2 - x1, y2 - y1, -x1, -y1);
+ width, height, -x, -y);
gimp_image_undo_group_end (image);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]