Commit b6932690 authored by Michael Natterer's avatar Michael Natterer 😴

app: simplify creating of stroke and fill groups a lot

- add gimp_draw_tool_push_group()/pop_group() which manage a stack
  of groups; all items automatically get added to the stack's top group
- use push_group()/pop_group() all over the place, which saves a lot
  of code in most cases
- return GimpCanvasGroup not GimpCanvasItem pointers from
  gimp_draw_tool_add_stroke_group() and fill_group()

Unrelated:

- add GipmCanvasGroup parameter to gimp_rectangle_tool_draw()
- put rect select's round corners into the stroke group to
  avoid ugly overdrawing (the mis-alignment of arcs becomes
  very visible now however, will fix that soon)
parent 64d9d767
...@@ -85,6 +85,7 @@ static void gimp_crop_tool_cursor_update (GimpTool ...@@ -85,6 +85,7 @@ static void gimp_crop_tool_cursor_update (GimpTool
const GimpCoords *coords, const GimpCoords *coords,
GdkModifierType state, GdkModifierType state,
GimpDisplay *display); GimpDisplay *display);
static void gimp_crop_tool_draw (GimpDrawTool *draw_tool);
static gboolean gimp_crop_tool_execute (GimpRectangleTool *rectangle, static gboolean gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gint x, gint x,
gint y, gint y,
...@@ -154,7 +155,7 @@ gimp_crop_tool_class_init (GimpCropToolClass *klass) ...@@ -154,7 +155,7 @@ gimp_crop_tool_class_init (GimpCropToolClass *klass)
tool_class->oper_update = gimp_rectangle_tool_oper_update; tool_class->oper_update = gimp_rectangle_tool_oper_update;
tool_class->cursor_update = gimp_crop_tool_cursor_update; tool_class->cursor_update = gimp_crop_tool_cursor_update;
draw_tool_class->draw = gimp_rectangle_tool_draw; draw_tool_class->draw = gimp_crop_tool_draw;
} }
static void static void
...@@ -302,6 +303,12 @@ gimp_crop_tool_cursor_update (GimpTool *tool, ...@@ -302,6 +303,12 @@ gimp_crop_tool_cursor_update (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display); GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
} }
static void
gimp_crop_tool_draw (GimpDrawTool *draw_tool)
{
gimp_rectangle_tool_draw (draw_tool, NULL);
}
static gboolean static gboolean
gimp_crop_tool_execute (GimpRectangleTool *rectangle, gimp_crop_tool_execute (GimpRectangleTool *rectangle,
gint x, gint x,
......
...@@ -198,6 +198,17 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool) ...@@ -198,6 +198,17 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool)
GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool); GIMP_DRAW_TOOL_GET_CLASS (draw_tool)->draw (draw_tool);
if (draw_tool->group_stack)
{
g_warning ("%s: draw_tool->group_stack not empty after calling "
"GimpDrawTool::draw() of %s",
G_STRFUNC,
g_type_name (G_TYPE_FROM_INSTANCE (draw_tool)));
while (draw_tool->group_stack)
gimp_draw_tool_pop_group (draw_tool);
}
if (draw_tool->item) if (draw_tool->item)
{ {
gimp_display_shell_add_item (shell, draw_tool->item); gimp_display_shell_add_item (shell, draw_tool->item);
...@@ -343,13 +354,20 @@ void ...@@ -343,13 +354,20 @@ void
gimp_draw_tool_add_item (GimpDrawTool *draw_tool, gimp_draw_tool_add_item (GimpDrawTool *draw_tool,
GimpCanvasItem *item) GimpCanvasItem *item)
{ {
GimpCanvasGroup *group;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (GIMP_IS_CANVAS_ITEM (item)); g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
if (! draw_tool->item) if (! draw_tool->item)
draw_tool->item = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display)); draw_tool->item = gimp_canvas_group_new (gimp_display_get_shell (draw_tool->display));
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (draw_tool->item), item); group = GIMP_CANVAS_GROUP (draw_tool->item);
if (draw_tool->group_stack)
group = draw_tool->group_stack->data;
gimp_canvas_group_add_item (group, item);
} }
void void
...@@ -363,7 +381,7 @@ gimp_draw_tool_remove_item (GimpDrawTool *draw_tool, ...@@ -363,7 +381,7 @@ gimp_draw_tool_remove_item (GimpDrawTool *draw_tool,
gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (draw_tool->item), item); gimp_canvas_group_remove_item (GIMP_CANVAS_GROUP (draw_tool->item), item);
} }
GimpCanvasItem * GimpCanvasGroup *
gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool) gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool)
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
...@@ -376,10 +394,10 @@ gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool) ...@@ -376,10 +394,10 @@ gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool)
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item; return GIMP_CANVAS_GROUP (item);
} }
GimpCanvasItem * GimpCanvasGroup *
gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool) gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool)
{ {
GimpCanvasItem *item; GimpCanvasItem *item;
...@@ -392,7 +410,27 @@ gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool) ...@@ -392,7 +410,27 @@ gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool)
gimp_draw_tool_add_item (draw_tool, item); gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item); g_object_unref (item);
return item; return GIMP_CANVAS_GROUP (item);
}
void
gimp_draw_tool_push_group (GimpDrawTool *draw_tool,
GimpCanvasGroup *group)
{
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (GIMP_IS_CANVAS_GROUP (group));
draw_tool->group_stack = g_list_prepend (draw_tool->group_stack, group);
}
void
gimp_draw_tool_pop_group (GimpDrawTool *draw_tool)
{
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (draw_tool->group_stack != NULL);
draw_tool->group_stack = g_list_remove (draw_tool->group_stack,
draw_tool->group_stack->data);
} }
/** /**
......
...@@ -43,6 +43,7 @@ struct _GimpDrawTool ...@@ -43,6 +43,7 @@ struct _GimpDrawTool
gint paused_count; /* count to keep track of multiple pauses */ gint paused_count; /* count to keep track of multiple pauses */
GimpCanvasItem *item; GimpCanvasItem *item;
GList *group_stack;
}; };
struct _GimpDrawToolClass struct _GimpDrawToolClass
...@@ -84,8 +85,12 @@ void gimp_draw_tool_add_item (GimpDrawTool *draw_too ...@@ -84,8 +85,12 @@ void gimp_draw_tool_add_item (GimpDrawTool *draw_too
void gimp_draw_tool_remove_item (GimpDrawTool *draw_tool, void gimp_draw_tool_remove_item (GimpDrawTool *draw_tool,
GimpCanvasItem *item); GimpCanvasItem *item);
GimpCanvasItem * gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool); GimpCanvasGroup* gimp_draw_tool_add_stroke_group (GimpDrawTool *draw_tool);
GimpCanvasItem * gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool); GimpCanvasGroup* gimp_draw_tool_add_fill_group (GimpDrawTool *draw_tool);
void gimp_draw_tool_push_group (GimpDrawTool *draw_tool,
GimpCanvasGroup *group);
void gimp_draw_tool_pop_group (GimpDrawTool *draw_tool);
GimpCanvasItem * gimp_draw_tool_add_line (GimpDrawTool *draw_tool, GimpCanvasItem * gimp_draw_tool_add_line (GimpDrawTool *draw_tool,
gdouble x1, gdouble x1,
......
...@@ -1529,8 +1529,7 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool) ...@@ -1529,8 +1529,7 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool)
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (draw_tool); GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (draw_tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst); GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpTool *tool = GIMP_TOOL (draw_tool); GimpTool *tool = GIMP_TOOL (draw_tool);
GimpCanvasItem *stroke_group; GimpCanvasGroup *stroke_group;
GimpCanvasItem *item;
gboolean hovering_first_point = FALSE; gboolean hovering_first_point = FALSE;
gboolean handles_wants_to_show = FALSE; gboolean handles_wants_to_show = FALSE;
GimpCoords coords = { priv->last_coords.x, GimpCoords coords = { priv->last_coords.x,
...@@ -1547,15 +1546,11 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool) ...@@ -1547,15 +1546,11 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool)
stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
item = gimp_draw_tool_add_lines (draw_tool, gimp_draw_tool_push_group (draw_tool, stroke_group);
priv->points, priv->n_points, gimp_draw_tool_add_lines (draw_tool,
FALSE); priv->points, priv->n_points,
FALSE);
if (item) gimp_draw_tool_pop_group (draw_tool);
{
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
}
/* We always show the handle for the first point, even with button1 /* We always show the handle for the first point, even with button1
* down, since releasing the button on the first point will close * down, since releasing the button on the first point will close
...@@ -1616,14 +1611,13 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool) ...@@ -1616,14 +1611,13 @@ gimp_free_select_tool_draw (GimpDrawTool *draw_tool)
{ {
GimpVector2 last = priv->points[priv->n_points - 1]; GimpVector2 last = priv->points[priv->n_points - 1];
item = gimp_draw_tool_add_line (draw_tool, gimp_draw_tool_push_group (draw_tool, stroke_group);
last.x, gimp_draw_tool_add_line (draw_tool,
last.y, last.x,
priv->pending_point.x, last.y,
priv->pending_point.y); priv->pending_point.x,
priv->pending_point.y);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item); gimp_draw_tool_pop_group (draw_tool);
gimp_draw_tool_remove_item (draw_tool, item);
} }
} }
......
...@@ -655,8 +655,7 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) ...@@ -655,8 +655,7 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
{ {
GimpMeasureTool *measure = GIMP_MEASURE_TOOL (draw_tool); GimpMeasureTool *measure = GIMP_MEASURE_TOOL (draw_tool);
GimpTool *tool = GIMP_TOOL (draw_tool); GimpTool *tool = GIMP_TOOL (draw_tool);
GimpCanvasItem *stroke_group; GimpCanvasGroup *stroke_group;
GimpCanvasItem *item;
gint i; gint i;
gint draw_arc = 0; gint draw_arc = 0;
...@@ -687,14 +686,15 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) ...@@ -687,14 +686,15 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
if (i > 0) if (i > 0)
{ {
item = gimp_draw_tool_add_line (draw_tool, gimp_draw_tool_push_group (draw_tool, stroke_group);
measure->x[0],
measure->y[0],
measure->x[i],
measure->y[i]);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item); gimp_draw_tool_add_line (draw_tool,
gimp_draw_tool_remove_item (draw_tool, item); measure->x[0],
measure->y[0],
measure->x[i],
measure->y[i]);
gimp_draw_tool_pop_group (draw_tool);
/* only draw the arc if the lines are long enough */ /* only draw the arc if the lines are long enough */
if (gimp_draw_tool_calc_distance (draw_tool, tool->display, if (gimp_draw_tool_calc_distance (draw_tool, tool->display,
...@@ -721,6 +721,10 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) ...@@ -721,6 +721,10 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
if (angle2 != 0.0) if (angle2 != 0.0)
{ {
GimpCanvasItem *item;
gimp_draw_tool_push_group (draw_tool, stroke_group);
item = gimp_draw_tool_add_handle (draw_tool, item = gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_CIRCLE, GIMP_HANDLE_CIRCLE,
measure->x[0], measure->x[0],
...@@ -732,9 +736,6 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) ...@@ -732,9 +736,6 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
gimp_canvas_handle_set_angles (GIMP_CANVAS_HANDLE (item), gimp_canvas_handle_set_angles (GIMP_CANVAS_HANDLE (item),
angle1, angle2); angle1, angle2);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
if (measure->num_points == 2) if (measure->num_points == 2)
{ {
GimpDisplayShell *shell; GimpDisplayShell *shell;
...@@ -746,17 +747,16 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool) ...@@ -746,17 +747,16 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
target = FUNSCALEX (shell, (TARGET >> 1)); target = FUNSCALEX (shell, (TARGET >> 1));
arc_radius = FUNSCALEX (shell, ARC_RADIUS); arc_radius = FUNSCALEX (shell, ARC_RADIUS);
item = gimp_draw_tool_add_line (draw_tool, gimp_draw_tool_add_line (draw_tool,
measure->x[0], measure->x[0],
measure->y[0], measure->y[0],
(measure->x[1] >= measure->x[0] ? (measure->x[1] >= measure->x[0] ?
measure->x[0] + arc_radius + target : measure->x[0] + arc_radius + target :
measure->x[0] - arc_radius - target), measure->x[0] - arc_radius - target),
measure->y[0]); measure->y[0]);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
} }
gimp_draw_tool_pop_group (draw_tool);
} }
} }
} }
......
...@@ -747,35 +747,27 @@ gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool) ...@@ -747,35 +747,27 @@ gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool)
if (clone_tool->use_handles) if (clone_tool->use_handles)
{ {
GimpCanvasItem *stroke_group; GimpCanvasGroup *stroke_group;
GimpCanvasItem *item;
stroke_group = gimp_draw_tool_add_stroke_group (draw_tool); stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
/* draw the bounding box */ /* draw the bounding box */
item = gimp_draw_tool_add_line (draw_tool, gimp_draw_tool_push_group (draw_tool, stroke_group);
clone_tool->tx1, clone_tool->ty1,
clone_tool->tx2, clone_tool->ty2); gimp_draw_tool_add_line (draw_tool,
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item); clone_tool->tx1, clone_tool->ty1,
gimp_draw_tool_remove_item (draw_tool, item); clone_tool->tx2, clone_tool->ty2);
gimp_draw_tool_add_line (draw_tool,
item = gimp_draw_tool_add_line (draw_tool, clone_tool->tx2, clone_tool->ty2,
clone_tool->tx2, clone_tool->ty2, clone_tool->tx4, clone_tool->ty4);
clone_tool->tx4, clone_tool->ty4); gimp_draw_tool_add_line (draw_tool,
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item); clone_tool->tx3, clone_tool->ty3,
gimp_draw_tool_remove_item (draw_tool, item); clone_tool->tx4, clone_tool->ty4);
gimp_draw_tool_add_line (draw_tool,
item = gimp_draw_tool_add_line (draw_tool, clone_tool->tx3, clone_tool->ty3,
clone_tool->tx3, clone_tool->ty3, clone_tool->tx1, clone_tool->ty1);
clone_tool->tx4, clone_tool->ty4);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item); gimp_draw_tool_pop_group (draw_tool);
gimp_draw_tool_remove_item (draw_tool, item);
item = gimp_draw_tool_add_line (draw_tool,
clone_tool->tx3, clone_tool->ty3,
clone_tool->tx1, clone_tool->ty1);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
/* draw the tool handles */ /* draw the tool handles */
gimp_draw_tool_add_handle (draw_tool, gimp_draw_tool_add_handle (draw_tool,
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "widgets/gimpviewabledialog.h" #include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h" #include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasgroup.h"
#include "display/gimpdisplay.h" #include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-transform.h" #include "display/gimpdisplayshell-transform.h"
...@@ -288,15 +289,17 @@ gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool) ...@@ -288,15 +289,17 @@ gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool)
{ {
GimpRectangleSelectTool *rect_sel_tool; GimpRectangleSelectTool *rect_sel_tool;
GimpRectangleSelectToolPrivate *priv; GimpRectangleSelectToolPrivate *priv;
GimpCanvasGroup *stroke_group = NULL;
rect_sel_tool = GIMP_RECTANGLE_SELECT_TOOL (draw_tool); rect_sel_tool = GIMP_RECTANGLE_SELECT_TOOL (draw_tool);
priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool); priv = GIMP_RECTANGLE_SELECT_TOOL_GET_PRIVATE (rect_sel_tool);
if (priv->round_corners) if (priv->round_corners)
{ {
gint x1, y1, x2, y2; GimpCanvasItem *item;
gdouble radius; gint x1, y1, x2, y2;
gint square_size; gdouble radius;
gint square_size;
g_object_get (rect_sel_tool, g_object_get (rect_sel_tool,
"x1", &x1, "x1", &x1,
...@@ -310,28 +313,39 @@ gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool) ...@@ -310,28 +313,39 @@ gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool)
square_size = (int) (radius * 2); square_size = (int) (radius * 2);
gimp_draw_tool_add_arc (draw_tool, FALSE, stroke_group =
x1, y1, GIMP_CANVAS_GROUP (gimp_draw_tool_add_stroke_group (draw_tool));
square_size, square_size,
G_PI / 2.0, G_PI / 2.0); item = gimp_draw_tool_add_arc (draw_tool, FALSE,
x1, y1,
gimp_draw_tool_add_arc (draw_tool, FALSE, square_size, square_size,
x2 - square_size, y1, G_PI / 2.0, G_PI / 2.0);
square_size, square_size, gimp_canvas_group_add_item (stroke_group, item);
0.0, G_PI / 2.0); gimp_draw_tool_remove_item (draw_tool, item);
gimp_draw_tool_add_arc (draw_tool, FALSE, item = gimp_draw_tool_add_arc (draw_tool, FALSE,
x2 - square_size, y2 - square_size, x2 - square_size, y1,
square_size, square_size, square_size, square_size,
G_PI * 1.5, G_PI / 2.0); 0.0, G_PI / 2.0);
gimp_canvas_group_add_item (stroke_group, item);
gimp_draw_tool_add_arc (draw_tool, FALSE, gimp_draw_tool_remove_item (draw_tool, item);
x1, y2 - square_size,
square_size, square_size, item = gimp_draw_tool_add_arc (draw_tool, FALSE,
G_PI, G_PI / 2.0); x2 - square_size, y2 - square_size,
square_size, square_size,
G_PI * 1.5, G_PI / 2.0);
gimp_canvas_group_add_item (stroke_group, item);
gimp_draw_tool_remove_item (draw_tool, item);
item = gimp_draw_tool_add_arc (draw_tool, FALSE,
x1, y2 - square_size,
square_size, square_size,
G_PI, G_PI / 2.0);
gimp_canvas_group_add_item (stroke_group, item);
gimp_draw_tool_remove_item (draw_tool, item);
} }
gimp_rectangle_tool_draw (draw_tool); gimp_rectangle_tool_draw (draw_tool, stroke_group);
} }
static gboolean static gboolean
......
This diff is collapsed.
...@@ -120,7 +120,8 @@ void gimp_rectangle_tool_cursor_update (GimpTool *to ...@@ -120,7 +120,8 @@ void gimp_rectangle_tool_cursor_update (GimpTool *to
const GimpCoords *coords, const GimpCoords *coords,
GdkModifierType state, GdkModifierType state,
GimpDisplay *display); GimpDisplay *display);
void gimp_rectangle_tool_draw (GimpDrawTool *draw); void gimp_rectangle_tool_draw (GimpDrawTool *draw,
GimpCanvasGroup *stroke_group);
gboolean gimp_rectangle_tool_execute (GimpRectangleTool *rect_tool); gboolean gimp_rectangle_tool_execute (GimpRectangleTool *rect_tool);
void gimp_rectangle_tool_cancel (GimpRectangleTool *rect_tool); void gimp_rectangle_tool_cancel (GimpRectangleTool *rect_tool);
void gimp_rectangle_tool_set_constraint (GimpRectangleTool *rectangle, void gimp_rectangle_tool_set_constraint (GimpRectangleTool *rectangle,
......
...@@ -783,7 +783,7 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool) ...@@ -783,7 +783,7 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool)
"narrow-mode", TRUE, "narrow-mode", TRUE,
NULL); NULL);
gimp_rectangle_tool_draw (draw_tool); gimp_rectangle_tool_draw (draw_tool, NULL);
if (! text_tool->text || if (! text_tool->text ||
! text_tool->layer || ! text_tool->layer ||
...@@ -823,7 +823,7 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool) ...@@ -823,7 +823,7 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool)
{ {
GimpTextTool *text_tool = GIMP_TEXT_TOOL (draw_tool); GimpTextTool *text_tool = GIMP_TEXT_TOOL (draw_tool);
GtkTextBuffer *buffer = GTK_TEXT_BUFFER (text_tool->buffer); GtkTextBuffer *buffer = GTK_TEXT_BUFFER (text_tool->buffer);
GimpCanvasItem *fill_group; GimpCanvasGroup *fill_group;
PangoLayout *layout; PangoLayout *layout;
gint offset_x; gint offset_x;
gint offset_y; gint offset_y;
...@@ -850,6 +850,8 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool) ...@@ -850,6 +850,8 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool)
iter = pango_layout_get_iter (layout); iter = pango_layout_get_iter (layout);
gimp_draw_tool_push_group (draw_tool, fill_group);
do do
{ {
if (! pango_layout_iter_get_run (iter)) if (! pango_layout_iter_get_run (iter))
...@@ -859,9 +861,8 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool) ...@@ -859,9 +861,8 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool)
if (i >= min && i < max) if (i >= min && i < max)
{ {
GimpCanvasItem *item; PangoRectangle rect;
PangoRectangle rect; gint ytop, ybottom;
gint ytop, ybottom;
pango_layout_iter_get_char_extents (iter, &rect); pango_layout_iter_get_char_extents (iter, &rect);
pango_layout_iter_get_line_yrange (iter, &ytop, &ybottom); pango_layout_iter_get_line_yrange (iter, &ytop, &ybottom);
...@@ -876,16 +877,15 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool) ...@@ -876,16 +877,15 @@ gimp_text_tool_draw_selection (GimpDrawTool *draw_tool)
rect.x += offset_x; rect.x += offset_x;
rect.y += offset_y; rect.y += offset_y;
item = gimp_draw_tool_add_rectangle (draw_tool, TRUE, gimp_draw_tool_add_rectangle (draw_tool, TRUE,
rect.x, rect.y, rect.x, rect.y,
rect.width, rect.height); rect.width, rect.height);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (fill_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
} }
} }
while (pango_layout_iter_next_char (iter)); while (pango_layout_iter_next_char (iter));
gimp_draw_tool_pop_group (draw_tool);
pango_layout_iter_free (iter); pango_layout_iter_free (iter);
} }
......
...@@ -781,14 +781,16 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool) ...@@ -781,14 +781,16 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
GimpTool *tool = GIMP_TOOL (draw_tool); GimpTool *tool = GIMP_TOOL (draw_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool); GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool);
GimpImage *image = gimp_display_get_image (tool->display); GimpImage *image = gimp_display_get_image (tool->display);