removed all calls to gimp_tool_control_set_preserve() so the tool doesn't

2003-09-12  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpvectortool.c: removed all calls to
	gimp_tool_control_set_preserve() so the tool doesn't get
	confused by the image being dirtied.

	Made it aware of visible vectors:

	(gimp_vector_tool_draw): don't draw the stroke itself if the
	current vectors is visible.

	(gimp_vector_tool_vectors_visible): new callback which just draws
	the stroke itself when the vectors changes visibility.

	(gimp_vector_tool_set_vectors): connect the new callback.
This commit is contained in:
Michael Natterer 2003-09-12 00:00:23 +00:00 committed by Michael Natterer
parent 2b6eadfe41
commit 3f437bb73b
2 changed files with 69 additions and 15 deletions

View file

@ -1,3 +1,19 @@
2003-09-12 Michael Natterer <mitch@gimp.org>
* app/tools/gimpvectortool.c: removed all calls to
gimp_tool_control_set_preserve() so the tool doesn't get
confused by the image being dirtied.
Made it aware of visible vectors:
(gimp_vector_tool_draw): don't draw the stroke itself if the
current vectors is visible.
(gimp_vector_tool_vectors_visible): new callback which just draws
the stroke itself when the vectors changes visibility.
(gimp_vector_tool_set_vectors): connect the new callback.
2003-09-12 Michael Natterer <mitch@gimp.org>
Added support for permanently showing the visible vectors, not
@ -15,12 +31,12 @@
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c: call the new
freeze()/thaw() functions instead of calling the tool_manager
directly. Removes the tools/ sependency from the scale and scroll
directly. Removes the tools/ dependency from the scale and scroll
files. Also draw the vectors once when the canvas is realized so
XOR drawing is in the correct state.
* app/display/gimpdisplayshell-handlers.c: connect to
image->vectors' "add" and "remove" signal and to the "freeze",
image->vectors' "add" and "remove" signals and to the "freeze",
"thaw" and "visibility_changed" signals of all vectors in
image->vectors and update vectors drawing accordingly.

View file

@ -116,6 +116,8 @@ static void gimp_vector_tool_draw (GimpDrawTool *draw_tool);
static void gimp_vector_tool_clear_vectors (GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_visible (GimpVectors *vectors,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_freeze (GimpVectors *vectors,
GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors,
@ -295,12 +297,10 @@ gimp_vector_tool_button_press (GimpTool *tool,
gimp_draw_tool_stop (draw_tool);
}
gimp_tool_control_set_preserve (tool->control, TRUE);
if (vector_tool->vectors)
gimp_image_undo_push_vectors_mod (GIMP_ITEM (vector_tool->vectors)->gimage,
"Vectors operation",
vector_tool->vectors);
gimp_tool_control_set_preserve (tool->control, FALSE);
gimp_tool_control_activate (tool->control);
tool->gdisp = gdisp;
@ -311,13 +311,9 @@ gimp_vector_tool_button_press (GimpTool *tool,
{
vectors = gimp_vectors_new (gdisp->gimage, _("Unnamed"));
gimp_tool_control_set_preserve (tool->control, TRUE);
gimp_image_add_vectors (gdisp->gimage, vectors, -1);
gimp_image_flush (gdisp->gimage);
gimp_tool_control_set_preserve (tool->control, FALSE);
gimp_vector_tool_set_vectors (vector_tool, vectors);
vector_tool->function = VECTORS_CREATE_STROKE;
@ -1193,15 +1189,19 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
}
/* the stroke itself */
coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
if (coords && coords->len)
if (! gimp_item_get_visible (GIMP_ITEM (vectors)))
{
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords, GimpCoords, 0),
coords->len, FALSE, FALSE);
coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
g_array_free (coords, TRUE);
if (coords && coords->len)
{
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, 0),
coords->len, FALSE, FALSE);
g_array_free (coords, TRUE);
}
}
}
}
@ -1214,6 +1214,37 @@ gimp_vector_tool_clear_vectors (GimpVectorTool *vector_tool)
gimp_vector_tool_set_vectors (vector_tool, NULL);
}
static void
gimp_vector_tool_vectors_visible (GimpVectors *vectors,
GimpVectorTool *vector_tool)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (vector_tool);
if (gimp_draw_tool_is_active (draw_tool) &&
draw_tool->paused_count == 0)
{
GimpStroke *cur_stroke = NULL;
while ((cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke)))
{
GArray *coords;
gboolean closed;
coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
if (coords && coords->len)
{
gimp_draw_tool_draw_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, 0),
coords->len, FALSE, FALSE);
g_array_free (coords, TRUE);
}
}
}
}
static void
gimp_vector_tool_vectors_freeze (GimpVectors *vectors,
GimpVectorTool *vector_tool)
@ -1324,6 +1355,9 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
gimp_vector_tool_clear_vectors,
vector_tool);
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
gimp_vector_tool_vectors_visible,
vector_tool);
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
gimp_vector_tool_vectors_freeze,
vector_tool);
@ -1356,6 +1390,10 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
G_CALLBACK (gimp_vector_tool_clear_vectors),
vector_tool,
G_CONNECT_SWAPPED);
g_signal_connect_object (vectors, "visibility_changed",
G_CALLBACK (gimp_vector_tool_vectors_visible),
vector_tool,
0);
g_signal_connect_object (vectors, "freeze",
G_CALLBACK (gimp_vector_tool_vectors_freeze),
vector_tool,