mirror of https://github.com/GNOME/gimp.git
app: use gimp_item_bounds() instead of gimp_vectors_bounds()
This commit is contained in:
parent
4edf70f4f1
commit
7e90a3e4e5
|
@ -24,8 +24,6 @@
|
||||||
|
|
||||||
#include "core-types.h"
|
#include "core-types.h"
|
||||||
|
|
||||||
#include "vectors/gimpvectors.h"
|
|
||||||
|
|
||||||
#include "gimpimage.h"
|
#include "gimpimage.h"
|
||||||
#include "gimpimage-arrange.h"
|
#include "gimpimage-arrange.h"
|
||||||
#include "gimpimage-guides.h"
|
#include "gimpimage-guides.h"
|
||||||
|
@ -37,6 +35,7 @@
|
||||||
|
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
static GList * sort_by_offset (GList *list);
|
static GList * sort_by_offset (GList *list);
|
||||||
static void compute_offsets (GList *list,
|
static void compute_offsets (GList *list,
|
||||||
GimpAlignmentType alignment);
|
GimpAlignmentType alignment);
|
||||||
|
@ -322,26 +321,17 @@ compute_offset (GObject *object,
|
||||||
else if (GIMP_IS_ITEM (object))
|
else if (GIMP_IS_ITEM (object))
|
||||||
{
|
{
|
||||||
GimpItem *item = GIMP_ITEM (object);
|
GimpItem *item = GIMP_ITEM (object);
|
||||||
|
gint off_x, off_y;
|
||||||
|
|
||||||
if (GIMP_IS_VECTORS (object))
|
gimp_item_bounds (item,
|
||||||
{
|
&object_offset_x,
|
||||||
gdouble x1_f, y1_f, x2_f, y2_f;
|
&object_offset_y,
|
||||||
|
&object_width,
|
||||||
|
&object_height);
|
||||||
|
|
||||||
gimp_vectors_bounds (GIMP_VECTORS (item),
|
gimp_item_get_offset (item, &off_x, &off_y);
|
||||||
&x1_f, &y1_f,
|
object_offset_x += off_x;
|
||||||
&x2_f, &y2_f);
|
object_offset_y += off_y;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (GIMP_IS_GUIDE (object))
|
else if (GIMP_IS_GUIDE (object))
|
||||||
{
|
{
|
||||||
|
|
|
@ -622,26 +622,13 @@ gimp_align_tool_draw (GimpDrawTool *draw_tool)
|
||||||
if (GIMP_IS_ITEM (list->data))
|
if (GIMP_IS_ITEM (list->data))
|
||||||
{
|
{
|
||||||
GimpItem *item = list->data;
|
GimpItem *item = list->data;
|
||||||
|
gint off_x, off_y;
|
||||||
|
|
||||||
if (GIMP_IS_VECTORS (item))
|
gimp_item_bounds (item, &x, &y, &w, &h);
|
||||||
{
|
|
||||||
gdouble x1_f, y1_f, x2_f, y2_f;
|
|
||||||
|
|
||||||
gimp_vectors_bounds (GIMP_VECTORS (item),
|
gimp_item_get_offset (item, &off_x, &off_y);
|
||||||
&x1_f, &y1_f,
|
x += off_x;
|
||||||
&x2_f, &y2_f);
|
y += off_y;
|
||||||
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_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
|
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
|
||||||
x, y,
|
x, y,
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
|
||||||
|
#include "libgimpbase/gimpbase.h"
|
||||||
#include "libgimpmath/gimpmath.h"
|
#include "libgimpmath/gimpmath.h"
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
|
@ -43,8 +44,6 @@
|
||||||
#include "core/gimpselection.h"
|
#include "core/gimpselection.h"
|
||||||
#include "core/gimpundostack.h"
|
#include "core/gimpundostack.h"
|
||||||
|
|
||||||
#include "vectors/gimpvectors.h"
|
|
||||||
|
|
||||||
#include "widgets/gimpwidgets-utils.h"
|
#include "widgets/gimpwidgets-utils.h"
|
||||||
|
|
||||||
#include "display/gimpdisplay.h"
|
#include "display/gimpdisplay.h"
|
||||||
|
@ -364,10 +363,9 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool,
|
||||||
|
|
||||||
case GIMP_TRANSLATE_MODE_VECTORS:
|
case GIMP_TRANSLATE_MODE_VECTORS:
|
||||||
{
|
{
|
||||||
gdouble xd1, yd1, xd2, yd2;
|
gimp_item_bounds (active_item, &x1, &y1, &x2, &y2);
|
||||||
|
x2 += x1;
|
||||||
gimp_vectors_bounds (GIMP_VECTORS (active_item),
|
y2 += y1;
|
||||||
&xd1, &yd1, &xd2, &yd2);
|
|
||||||
|
|
||||||
if (gimp_item_get_linked (active_item))
|
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))
|
for (list = linked; list; list = g_list_next (list))
|
||||||
{
|
{
|
||||||
GimpItem *item = list->data;
|
GimpItem *item = list->data;
|
||||||
gdouble x3, y3;
|
gint x3, y3;
|
||||||
gdouble x4, y4;
|
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);
|
x1 = MIN (x1, x3);
|
||||||
yd1 = MIN (yd1, y3);
|
y1 = MIN (y1, y3);
|
||||||
xd2 = MAX (xd2, x4);
|
x2 = MAX (x2, x4);
|
||||||
yd2 = MAX (yd2, y4);
|
y2 = MAX (y2, y4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = ROUND (floor (xd1));
|
|
||||||
y1 = ROUND (floor (yd1));
|
|
||||||
x2 = ROUND (ceil (xd2));
|
|
||||||
y2 = ROUND (ceil (yd2));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -840,9 +835,9 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
|
||||||
|
|
||||||
case GIMP_TRANSLATE_MODE_VECTORS:
|
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))
|
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))
|
for (list = linked; list; list = g_list_next (list))
|
||||||
{
|
{
|
||||||
GimpItem *item = list->data;
|
GimpItem *item = list->data;
|
||||||
gdouble x3, y3;
|
gint x2, y2;
|
||||||
gdouble x4, y4;
|
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);
|
gimp_rectangle_union (x, y, w, h,
|
||||||
y1 = MIN (y1, y3);
|
x2, y2, w2, h2,
|
||||||
x2 = MAX (x2, x4);
|
&x, &y, &w, &h);
|
||||||
y2 = MAX (y2, y4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free (linked);
|
g_list_free (linked);
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = floor (x1);
|
|
||||||
y1 = floor (y1);
|
|
||||||
x2 = ceil (x2);
|
|
||||||
y2 = ceil (y2);
|
|
||||||
|
|
||||||
gimp_draw_tool_add_rectangle (draw_tool, FALSE,
|
gimp_draw_tool_add_rectangle (draw_tool, FALSE,
|
||||||
x1, y1,
|
x, y, w, h);
|
||||||
x2 - x1, y2 - y1);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue