mirror of https://github.com/GNOME/gimp.git
app: don't let the vectors tool draw the active vectors
Let the display shell deal with drawing the vectors. The vectors tool only draws the handles on the active vectors object.
This commit is contained in:
parent
4c57e3f19e
commit
5ab83e72ac
|
@ -584,10 +584,40 @@ gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_draw_one_vectors (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
GimpVectors *vectors,
|
||||
gdouble width)
|
||||
gimp_display_shell_draw_active_vectors (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
GimpVectors *vectors,
|
||||
gdouble width)
|
||||
{
|
||||
GimpStroke *stroke = NULL;
|
||||
|
||||
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
|
||||
{
|
||||
GimpBezierDesc *desc = gimp_vectors_make_bezier (vectors);
|
||||
|
||||
if (desc)
|
||||
{
|
||||
cairo_append_path (cr, (cairo_path_t *) desc);
|
||||
|
||||
cairo_set_line_width (cr, 1.6 * width);
|
||||
cairo_set_source_rgb (cr, 0.0, 0.7, 1.0);
|
||||
cairo_stroke_preserve (cr);
|
||||
|
||||
cairo_set_line_width (cr, width);
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
g_free (desc->data);
|
||||
g_free (desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_draw_inactive_vectors (GimpDisplayShell *shell,
|
||||
cairo_t *cr,
|
||||
GimpVectors *vectors,
|
||||
gdouble width)
|
||||
{
|
||||
GimpStroke *stroke = NULL;
|
||||
|
||||
|
@ -612,6 +642,7 @@ gimp_display_shell_draw_one_vectors (GimpDisplayShell *shell,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
|
||||
cairo_t *cr)
|
||||
|
@ -625,6 +656,7 @@ gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
|
|||
if (image && TRUE /* gimp_display_shell_get_show_vectors (shell) */)
|
||||
{
|
||||
GList *all_vectors = gimp_image_get_vectors_list (image);
|
||||
GimpVectors *active = gimp_image_get_active_vectors (image);
|
||||
const GList *list;
|
||||
gdouble xscale;
|
||||
gdouble yscale;
|
||||
|
@ -646,8 +678,18 @@ gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
|
|||
{
|
||||
GimpVectors *vectors = list->data;
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_display_shell_draw_one_vectors (shell, cr, vectors, width);
|
||||
if (vectors != active &&
|
||||
gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
{
|
||||
gimp_display_shell_draw_inactive_vectors (shell, cr,
|
||||
vectors, width);
|
||||
}
|
||||
}
|
||||
|
||||
/* the active vector is always rendered on top */
|
||||
if (active)
|
||||
{
|
||||
gimp_display_shell_draw_active_vectors (shell, cr, active, width);
|
||||
}
|
||||
|
||||
g_list_free (all_vectors);
|
||||
|
|
|
@ -104,6 +104,9 @@ static void gimp_display_shell_exported_handler (GimpImage *i
|
|||
const gchar *uri,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
static void gimp_display_shell_active_vectors_handler (GimpImage *image,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
static void gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_vectors_thaw_handler (GimpVectors *vectors,
|
||||
|
@ -202,6 +205,10 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
|||
G_CALLBACK (gimp_display_shell_exported_handler),
|
||||
shell);
|
||||
|
||||
g_signal_connect (image, "active-vectors-changed",
|
||||
G_CALLBACK (gimp_display_shell_active_vectors_handler),
|
||||
shell);
|
||||
|
||||
shell->vectors_freeze_handler =
|
||||
gimp_tree_handler_connect (vectors, "freeze",
|
||||
G_CALLBACK (gimp_display_shell_vectors_freeze_handler),
|
||||
|
@ -345,6 +352,10 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
|||
gimp_tree_handler_disconnect (shell->vectors_freeze_handler);
|
||||
shell->vectors_freeze_handler = NULL;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_active_vectors_handler,
|
||||
shell);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_exported_handler,
|
||||
shell);
|
||||
|
@ -603,6 +614,13 @@ gimp_display_shell_exported_handler (GimpImage *image,
|
|||
g_free (filename);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_active_vectors_handler (GimpImage *image,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_expose_full (shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
|
|
|
@ -78,8 +78,6 @@ void gimp_draw_tool_resume (GimpDrawTool *draw_tool)
|
|||
|
||||
gboolean gimp_draw_tool_is_drawn (GimpDrawTool *draw_tool);
|
||||
|
||||
void gimp_draw_tool_set_vectors (GimpDrawTool *draw_tool,
|
||||
GList *vectors);
|
||||
void gimp_draw_tool_set_transform (GimpDrawTool *draw_tool,
|
||||
GimpMatrix3 *transform);
|
||||
|
||||
|
|
|
@ -118,8 +118,6 @@ static void gimp_vector_tool_vectors_changed (GimpImage *image,
|
|||
GimpVectorTool *vector_tool);
|
||||
static void gimp_vector_tool_vectors_removed (GimpVectors *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,
|
||||
|
@ -1399,18 +1397,15 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
|
|||
static void
|
||||
gimp_vector_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (draw_tool);
|
||||
GimpAnchor *cur_anchor = NULL;
|
||||
GimpStroke *cur_stroke = NULL;
|
||||
GimpVectors *vectors;
|
||||
GArray *coords;
|
||||
gboolean closed;
|
||||
GList *draw_anchors;
|
||||
GList *list;
|
||||
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (draw_tool);
|
||||
GimpVectors *vectors = vector_tool->vectors;
|
||||
GimpAnchor *cur_anchor = NULL;
|
||||
GimpStroke *cur_stroke = NULL;
|
||||
GArray *coords;
|
||||
GList *draw_anchors;
|
||||
GList *list;
|
||||
|
||||
vectors = vector_tool->vectors;
|
||||
|
||||
if (!vectors)
|
||||
if (! vectors)
|
||||
return;
|
||||
|
||||
while ((cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke)))
|
||||
|
@ -1483,23 +1478,6 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
|
|||
g_array_free (coords, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* the stroke itself */
|
||||
if (! gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
{
|
||||
coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
|
||||
|
||||
if (coords)
|
||||
{
|
||||
if (coords->len)
|
||||
gimp_draw_tool_draw_strokes (draw_tool,
|
||||
&g_array_index (coords,
|
||||
GimpCoords, 0),
|
||||
coords->len, FALSE, FALSE);
|
||||
|
||||
g_array_free (coords, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1518,37 +1496,6 @@ gimp_vector_tool_vectors_removed (GimpVectors *vectors,
|
|||
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 *stroke = NULL;
|
||||
|
||||
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
|
||||
{
|
||||
GArray *coords;
|
||||
gboolean closed;
|
||||
|
||||
coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
|
||||
|
||||
if (coords)
|
||||
{
|
||||
if (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)
|
||||
|
@ -1610,9 +1557,6 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
|
|||
g_signal_handlers_disconnect_by_func (vector_tool->vectors,
|
||||
gimp_vector_tool_vectors_removed,
|
||||
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);
|
||||
|
@ -1665,9 +1609,6 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
|
|||
g_signal_connect_object (vectors, "removed",
|
||||
G_CALLBACK (gimp_vector_tool_vectors_removed),
|
||||
vector_tool, 0);
|
||||
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, 0);
|
||||
|
|
Loading…
Reference in New Issue