From 7e90a3e4e5e9b565b2e5f375de3a2fd9dcdb0bee Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 30 Jun 2015 15:55:05 +0200 Subject: [PATCH] app: use gimp_item_bounds() instead of gimp_vectors_bounds() --- app/core/gimpimage-arrange.c | 30 ++++++----------- app/tools/gimpaligntool.c | 23 +++---------- app/tools/gimpeditselectiontool.c | 56 ++++++++++++------------------- 3 files changed, 37 insertions(+), 72 deletions(-) diff --git a/app/core/gimpimage-arrange.c b/app/core/gimpimage-arrange.c index 668b65c237..b113a45efd 100644 --- a/app/core/gimpimage-arrange.c +++ b/app/core/gimpimage-arrange.c @@ -24,8 +24,6 @@ #include "core-types.h" -#include "vectors/gimpvectors.h" - #include "gimpimage.h" #include "gimpimage-arrange.h" #include "gimpimage-guides.h" @@ -37,6 +35,7 @@ #include "gimp-intl.h" + static GList * sort_by_offset (GList *list); static void compute_offsets (GList *list, GimpAlignmentType alignment); @@ -322,26 +321,17 @@ compute_offset (GObject *object, else if (GIMP_IS_ITEM (object)) { GimpItem *item = GIMP_ITEM (object); + gint off_x, off_y; - if (GIMP_IS_VECTORS (object)) - { - gdouble x1_f, y1_f, x2_f, y2_f; + gimp_item_bounds (item, + &object_offset_x, + &object_offset_y, + &object_width, + &object_height); - gimp_vectors_bounds (GIMP_VECTORS (item), - &x1_f, &y1_f, - &x2_f, &y2_f); - - object_offset_x = ROUND (x1_f); - object_offset_y = ROUND (y1_f); - object_height = ROUND (y2_f - y1_f); - object_width = ROUND (x2_f - x1_f); - } - else - { - gimp_item_get_offset (item, &object_offset_x, &object_offset_y); - object_width = gimp_item_get_width (item); - object_height = gimp_item_get_height (item); - } + gimp_item_get_offset (item, &off_x, &off_y); + object_offset_x += off_x; + object_offset_y += off_y; } else if (GIMP_IS_GUIDE (object)) { diff --git a/app/tools/gimpaligntool.c b/app/tools/gimpaligntool.c index 6a0f63e331..aca03c4f52 100644 --- a/app/tools/gimpaligntool.c +++ b/app/tools/gimpaligntool.c @@ -622,26 +622,13 @@ gimp_align_tool_draw (GimpDrawTool *draw_tool) if (GIMP_IS_ITEM (list->data)) { GimpItem *item = list->data; + gint off_x, off_y; - if (GIMP_IS_VECTORS (item)) - { - gdouble x1_f, y1_f, x2_f, y2_f; + gimp_item_bounds (item, &x, &y, &w, &h); - gimp_vectors_bounds (GIMP_VECTORS (item), - &x1_f, &y1_f, - &x2_f, &y2_f); - x = ROUND (x1_f); - y = ROUND (y1_f); - w = ROUND (x2_f - x1_f); - h = ROUND (y2_f - y1_f); - } - else - { - gimp_item_get_offset (item, &x, &y); - - w = gimp_item_get_width (item); - h = gimp_item_get_height (item); - } + gimp_item_get_offset (item, &off_x, &off_y); + x += off_x; + y += off_y; gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE, x, y, diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index f43957821e..d83bc8df0a 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -24,6 +24,7 @@ #include #include +#include "libgimpbase/gimpbase.h" #include "libgimpmath/gimpmath.h" #include "libgimpwidgets/gimpwidgets.h" @@ -43,8 +44,6 @@ #include "core/gimpselection.h" #include "core/gimpundostack.h" -#include "vectors/gimpvectors.h" - #include "widgets/gimpwidgets-utils.h" #include "display/gimpdisplay.h" @@ -364,10 +363,9 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool, case GIMP_TRANSLATE_MODE_VECTORS: { - gdouble xd1, yd1, xd2, yd2; - - gimp_vectors_bounds (GIMP_VECTORS (active_item), - &xd1, &yd1, &xd2, &yd2); + gimp_item_bounds (active_item, &x1, &y1, &x2, &y2); + x2 += x1; + y2 += y1; if (gimp_item_get_linked (active_item)) { @@ -384,22 +382,19 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool, for (list = linked; list; list = g_list_next (list)) { GimpItem *item = list->data; - gdouble x3, y3; - gdouble x4, y4; + gint x3, y3; + gint x4, y4; - gimp_vectors_bounds (GIMP_VECTORS (item), &x3, &y3, &x4, &y4); + gimp_item_bounds (item, &x3, &y3, &x4, &y4); + x4 += x3; + y4 += y3; - xd1 = MIN (xd1, x3); - yd1 = MIN (yd1, y3); - xd2 = MAX (xd2, x4); - yd2 = MAX (yd2, y4); + x1 = MIN (x1, x3); + y1 = MIN (y1, y3); + x2 = MAX (x2, x4); + y2 = MAX (y2, y4); } } - - x1 = ROUND (floor (xd1)); - y1 = ROUND (floor (yd1)); - x2 = ROUND (ceil (xd2)); - y2 = ROUND (ceil (yd2)); } break; } @@ -840,9 +835,9 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool) case GIMP_TRANSLATE_MODE_VECTORS: { - gdouble x1, y1, x2, y2; + gint x, y, w, h; - gimp_vectors_bounds (GIMP_VECTORS (active_item), &x1, &y1, &x2, &y2); + gimp_item_bounds (active_item, &x, &y, &w, &h); if (gimp_item_get_linked (active_item)) { @@ -859,28 +854,21 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool) for (list = linked; list; list = g_list_next (list)) { GimpItem *item = list->data; - gdouble x3, y3; - gdouble x4, y4; + gint x2, y2; + gint w2, h2; - gimp_vectors_bounds (GIMP_VECTORS (item), &x3, &y3, &x4, &y4); + gimp_item_bounds (item, &x2, &y2, &w2, &h2); - x1 = MIN (x1, x3); - y1 = MIN (y1, y3); - x2 = MAX (x2, x4); - y2 = MAX (y2, y4); + gimp_rectangle_union (x, y, w, h, + x2, y2, w2, h2, + &x, &y, &w, &h); } g_list_free (linked); } - x1 = floor (x1); - y1 = floor (y1); - x2 = ceil (x2); - y2 = ceil (y2); - gimp_draw_tool_add_rectangle (draw_tool, FALSE, - x1, y1, - x2 - x1, y2 - y1); + x, y, w, h); } break;