Commit 55f01bf6 authored by Michael Natterer's avatar Michael Natterer 😴

app: remove gimp_display_shell_draw_vectors()

which is the last bit of non-item drawing of stuff that is not
somehow the image itself... wheee!

This involves reverting commit
6bce0641 and adding back all the
vectors handlers that were in gimpdisplayshell-callbacks.c before.
Change the callbacks to manage proxy items for all the image's
vectors.
parent db72c72c
......@@ -78,10 +78,6 @@ struct _GimpImagePrivate
GQuark channel_name_changed_handler;
GQuark channel_color_changed_handler;
GimpTreeHandler *vectors_freeze_handler;
GimpTreeHandler *vectors_thaw_handler;
GimpTreeHandler *vectors_visible_handler;
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
......
......@@ -63,7 +63,6 @@
#include "gimpsamplepoint.h"
#include "gimpselection.h"
#include "gimptemplate.h"
#include "gimptreehandler.h"
#include "gimpundostack.h"
#include "file/file-utils.h"
......@@ -100,7 +99,6 @@ enum
DIRTY,
SAVED,
EXPORTED,
UPDATE_VECTORS,
GUIDE_ADDED,
GUIDE_REMOVED,
GUIDE_MOVED,
......@@ -193,18 +191,6 @@ static void gimp_image_channel_name_changed (GimpChannel *channel,
GimpImage *image);
static void gimp_image_channel_color_changed (GimpChannel *channel,
GimpImage *image);
static void gimp_image_vectors_freeze (GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_thaw (GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_visible (GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_add (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image);
static void gimp_image_vectors_remove (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image);
static void gimp_image_active_layer_notify (GimpItemTree *tree,
const GParamSpec *pspec,
GimpImage *image);
......@@ -424,16 +410,6 @@ gimp_image_class_init (GimpImageClass *klass)
G_TYPE_NONE, 1,
G_TYPE_STRING);
gimp_image_signals[UPDATE_VECTORS] =
g_signal_new ("update-vectors",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpImageClass, update_vectors),
NULL, NULL,
gimp_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
GIMP_TYPE_VECTORS);
gimp_image_signals[GUIDE_ADDED] =
g_signal_new ("guide-added",
G_TYPE_FROM_CLASS (klass),
......@@ -573,7 +549,6 @@ gimp_image_class_init (GimpImageClass *klass)
klass->dirty = NULL;
klass->saved = NULL;
klass->exported = NULL;
klass->update_vectors = NULL;
klass->guide_added = NULL;
klass->guide_removed = NULL;
klass->guide_moved = NULL;
......@@ -727,26 +702,6 @@ gimp_image_init (GimpImage *image)
G_CALLBACK (gimp_image_channel_remove),
image);
private->vectors_freeze_handler =
gimp_tree_handler_connect (private->vectors->container, "freeze",
G_CALLBACK (gimp_image_vectors_freeze),
image);
private->vectors_thaw_handler =
gimp_tree_handler_connect (private->vectors->container, "thaw",
G_CALLBACK (gimp_image_vectors_thaw),
image);
private->vectors_visible_handler =
gimp_tree_handler_connect (private->vectors->container, "visibility-changed",
G_CALLBACK (gimp_image_vectors_visible),
image);
g_signal_connect (private->vectors->container, "add",
G_CALLBACK (gimp_image_vectors_add),
image);
g_signal_connect (private->vectors->container, "remove",
G_CALLBACK (gimp_image_vectors_remove),
image);
private->floating_sel = NULL;
private->selection_mask = NULL;
......@@ -948,22 +903,6 @@ gimp_image_dispose (GObject *object)
gimp_image_channel_remove,
image);
gimp_tree_handler_disconnect (private->vectors_freeze_handler);
private->vectors_freeze_handler = NULL;
gimp_tree_handler_disconnect (private->vectors_thaw_handler);
private->vectors_thaw_handler = NULL;
gimp_tree_handler_disconnect (private->vectors_visible_handler);
private->vectors_visible_handler = NULL;
g_signal_handlers_disconnect_by_func (private->vectors->container,
gimp_image_vectors_add,
image);
g_signal_handlers_disconnect_by_func (private->vectors->container,
gimp_image_vectors_remove,
image);
gimp_container_foreach (private->layers->container,
(GFunc) gimp_item_removed, NULL);
gimp_container_foreach (private->channels->container,
......@@ -1464,47 +1403,6 @@ gimp_image_channel_color_changed (GimpChannel *channel,
}
}
static void
gimp_image_vectors_freeze (GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_thaw (GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_visible (GimpVectors *vectors,
GimpImage *image)
{
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_add (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_vectors_remove (GimpContainer *container,
GimpVectors *vectors,
GimpImage *image)
{
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
gimp_image_update_vectors (image, vectors);
}
static void
gimp_image_active_layer_notify (GimpItemTree *tree,
const GParamSpec *pspec,
......@@ -2113,17 +2011,6 @@ gimp_image_invalidate (GimpImage *image,
GIMP_IMAGE_GET_PRIVATE (image)->flush_accum.preview_invalidated = TRUE;
}
void
gimp_image_update_vectors (GimpImage *image,
GimpVectors *vectors)
{
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (GIMP_IS_VECTORS (vectors));
g_signal_emit (image, gimp_image_signals[UPDATE_VECTORS], 0,
vectors);
}
void
gimp_image_guide_added (GimpImage *image,
GimpGuide *guide)
......
......@@ -131,8 +131,6 @@ struct _GimpImageClass
void (* exported) (GimpImage *image,
const gchar *uri);
void (* update_vectors) (GimpImage *image,
GimpVectors *vectors);
void (* guide_added) (GimpImage *image,
GimpGuide *guide);
void (* guide_removed) (GimpImage *image,
......@@ -253,9 +251,6 @@ void gimp_image_invalidate (GimpImage *image,
gint y,
gint width,
gint height);
void gimp_image_update_vectors (GimpImage *image,
GimpVectors *vectors);
void gimp_image_guide_added (GimpImage *image,
GimpGuide *guide);
void gimp_image_guide_removed (GimpImage *image,
......
......@@ -2330,11 +2330,6 @@ gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
gimp_display_shell_preview_transform (shell, cr);
cairo_restore (cr);
/* draw the vectors */
cairo_save (cr);
gimp_display_shell_draw_vectors (shell, cr);
cairo_restore (cr);
/* draw canvas items */
cairo_save (cr);
gimp_canvas_item_draw (shell->canvas_item, cr);
......
......@@ -33,9 +33,6 @@
#include "core/gimpimage.h"
#include "core/gimpprojection.h"
#include "vectors/gimpstroke.h"
#include "vectors/gimpvectors.h"
#include "widgets/gimpcairo.h"
#include "gimpcanvas.h"
......@@ -149,52 +146,6 @@ gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
cairo_mask (cr, mask);
}
void
gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
cairo_t *cr)
{
GimpImage *image;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
image = gimp_display_get_image (shell->display);
if (image && TRUE /* gimp_display_shell_get_show_vectors (shell) */)
{
GList *all_vectors = gimp_image_get_vectors_list (image);
const GList *list;
GimpCanvasItem *path;
path = gimp_canvas_path_new (shell, NULL, FALSE, TRUE);
if (! all_vectors)
return;
for (list = all_vectors; list; list = list->next)
{
GimpVectors *vectors = list->data;
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
{
const GimpBezierDesc *desc;
gboolean active;
desc = gimp_vectors_get_bezier (vectors);
active = (vectors == gimp_image_get_active_vectors (image));
g_object_set (path, "path", desc, NULL);
gimp_canvas_item_set_highlight (path, active);
gimp_canvas_item_draw (path, cr);
}
}
g_object_unref (path);
g_list_free (all_vectors);
}
}
void
gimp_display_shell_draw_image (GimpDisplayShell *shell,
cairo_t *cr,
......
......@@ -37,9 +37,6 @@ void gimp_display_shell_draw_selection_in (GimpDisplayShell *shell,
cairo_pattern_t *mask,
gint index);
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell,
cairo_t *cr);
void gimp_display_shell_draw_image (GimpDisplayShell *shell,
cairo_t *cr,
gint x,
......
......@@ -30,7 +30,6 @@
#include "config/gimpdisplayoptions.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-grid.h"
......@@ -38,15 +37,19 @@
#include "core/gimpimage-quick-mask.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpitem.h"
#include "core/gimpitemstack.h"
#include "core/gimpsamplepoint.h"
#include "core/gimptreehandler.h"
#include "vectors/gimpvectors.h"
#include "file/file-utils.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcanvasguide.h"
#include "gimpcanvaslayerboundary.h"
#include "gimpcanvaspath.h"
#include "gimpcanvasproxygroup.h"
#include "gimpcanvassamplepoint.h"
#include "gimpdisplay.h"
......@@ -112,9 +115,6 @@ static void gimp_display_shell_sample_point_remove_handler(GimpImage *i
static void gimp_display_shell_sample_point_move_handler (GimpImage *image,
GimpSamplePoint *sample_point,
GimpDisplayShell *shell);
static void gimp_display_shell_update_vectors_handler (GimpImage *image,
GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_invalidate_preview_handler (GimpImage *image,
GimpDisplayShell *shell);
static void gimp_display_shell_profile_changed_handler (GimpColorManaged *image,
......@@ -129,6 +129,19 @@ static void gimp_display_shell_exported_handler (GimpImage *i
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,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_visible_handler (GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_add_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_vectors_remove_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell);
static void gimp_display_shell_check_notify_handler (GObject *config,
GParamSpec *param_spec,
GimpDisplayShell *shell);
......@@ -158,12 +171,14 @@ void
gimp_display_shell_connect (GimpDisplayShell *shell)
{
GimpImage *image;
GimpContainer *vectors;
GList *list;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
image = gimp_display_get_image (shell->display);
vectors = gimp_image_get_vectors (image);
g_return_if_fail (GIMP_IS_IMAGE (image));
......@@ -230,9 +245,6 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
gimp_display_shell_sample_point_add_handler (image, list->data, shell);
}
g_signal_connect (image, "update-vectors",
G_CALLBACK (gimp_display_shell_update_vectors_handler),
shell);
g_signal_connect (image, "invalidate-preview",
G_CALLBACK (gimp_display_shell_invalidate_preview_handler),
shell);
......@@ -250,6 +262,32 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
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),
shell);
shell->vectors_thaw_handler =
gimp_tree_handler_connect (vectors, "thaw",
G_CALLBACK (gimp_display_shell_vectors_thaw_handler),
shell);
shell->vectors_visible_handler =
gimp_tree_handler_connect (vectors, "visibility-changed",
G_CALLBACK (gimp_display_shell_vectors_visible_handler),
shell);
g_signal_connect (vectors, "add",
G_CALLBACK (gimp_display_shell_vectors_add_handler),
shell);
g_signal_connect (vectors, "remove",
G_CALLBACK (gimp_display_shell_vectors_remove_handler),
shell);
for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (vectors));
list;
list = g_list_next (list))
{
gimp_display_shell_vectors_add_handler (vectors, list->data, shell);
}
g_signal_connect (shell->display->config,
"notify::transparency-size",
G_CALLBACK (gimp_display_shell_check_notify_handler),
......@@ -322,6 +360,7 @@ void
gimp_display_shell_disconnect (GimpDisplayShell *shell)
{
GimpImage *image;
GimpContainer *vectors;
GList *list;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
......@@ -331,6 +370,8 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
g_return_if_fail (GIMP_IS_IMAGE (image));
vectors = gimp_image_get_vectors (image);
gimp_display_shell_icon_update_stop (shell);
gimp_canvas_layer_boundary_set_layer (GIMP_CANVAS_LAYER_BOUNDARY (shell->layer_boundary),
......@@ -361,10 +402,34 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
gimp_display_shell_check_notify_handler,
shell);
g_signal_handlers_disconnect_by_func (vectors,
gimp_display_shell_vectors_remove_handler,
shell);
g_signal_handlers_disconnect_by_func (vectors,
gimp_display_shell_vectors_add_handler,
shell);
gimp_tree_handler_disconnect (shell->vectors_visible_handler);
shell->vectors_visible_handler = NULL;
gimp_tree_handler_disconnect (shell->vectors_thaw_handler);
shell->vectors_thaw_handler = NULL;
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);
for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (vectors));
list;
list = g_list_next (list))
{
gimp_canvas_proxy_group_remove_item (GIMP_CANVAS_PROXY_GROUP (shell->vectors),
list->data);
}
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_exported_handler,
shell);
......@@ -412,9 +477,6 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
list->data);
}
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_update_vectors_handler,
shell);
g_signal_handlers_disconnect_by_func (image,
gimp_display_shell_quick_mask_changed_handler,
shell);
......@@ -662,14 +724,6 @@ gimp_display_shell_sample_point_move_handler (GimpImage *image,
gimp_canvas_item_end_change (item);
}
static void
gimp_display_shell_update_vectors_handler (GimpImage *image,
GimpVectors *vectors,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_vectors (shell, vectors);
}
static void
gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
gint previous_origin_x,
......@@ -769,7 +823,86 @@ static void
gimp_display_shell_active_vectors_handler (GimpImage *image,
GimpDisplayShell *shell)
{
gimp_display_shell_expose_full (shell);
GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
GimpVectors *active = gimp_image_get_active_vectors (image);
GList *list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
GimpVectors *vectors = list->data;
GimpCanvasItem *item;
item = gimp_canvas_proxy_group_get_item (group, vectors);
gimp_canvas_item_set_highlight (item, vectors == active);
}
}
static void
gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
GimpDisplayShell *shell)
{
/* do nothing */
}
static void
gimp_display_shell_vectors_thaw_handler (GimpVectors *vectors,
GimpDisplayShell *shell)
{
GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
GimpCanvasItem *item;
item = gimp_canvas_proxy_group_get_item (group, vectors);
gimp_canvas_item_begin_change (item);
g_object_set (item,
"path", gimp_vectors_get_bezier (vectors),
NULL);
gimp_canvas_item_end_change (item);
}
static void
gimp_display_shell_vectors_visible_handler (GimpVectors *vectors,
GimpDisplayShell *shell)
{
GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
GimpCanvasItem *item;
item = gimp_canvas_proxy_group_get_item (group, vectors);
gimp_canvas_item_set_visible (item,
gimp_item_get_visible (GIMP_ITEM (vectors)));
}
static void
gimp_display_shell_vectors_add_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell)
{
GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
GimpCanvasItem *item;
item = gimp_canvas_path_new (shell,
gimp_vectors_get_bezier (vectors),
FALSE,
TRUE);
gimp_canvas_item_set_visible (item,
gimp_item_get_visible (GIMP_ITEM (vectors)));
gimp_canvas_proxy_group_add_item (group, vectors, item);
g_object_unref (item);
}
static void
gimp_display_shell_vectors_remove_handler (GimpContainer *container,
GimpVectors *vectors,
GimpDisplayShell *shell)
{
GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
gimp_canvas_proxy_group_remove_item (group, vectors);
}
static void
......
......@@ -49,6 +49,10 @@ gimp_display_shell_items_init (GimpDisplayShell *shell)
shell->canvas_item = gimp_canvas_group_new (shell);
shell->vectors = gimp_canvas_proxy_group_new (shell);
gimp_display_shell_add_item (shell, shell->vectors);
g_object_unref (shell->vectors);
shell->grid = gimp_canvas_grid_new (shell, NULL);
g_object_set (shell->grid, "grid-style", TRUE, NULL);
gimp_display_shell_add_item (shell, shell->grid);
......
......@@ -136,6 +136,7 @@ struct _GimpDisplayShell
cairo_pattern_t *checkerboard; /* checkerboard pattern */
GimpCanvasItem *canvas_item; /* items drawn on the canvas */
GimpCanvasItem *vectors; /* item proxy of vectors */
GimpCanvasItem *grid; /* item proxy of the grid */
GimpCanvasItem *guides; /* item proxies of guides */
GimpCanvasItem *sample_points; /* item proxies of sample points */
......@@ -172,6 +173,10 @@ struct _GimpDisplayShell
gint paused_count;
GimpTreeHandler *vectors_freeze_handler;
GimpTreeHandler *vectors_thaw_handler;
GimpTreeHandler *vectors_visible_handler;
gboolean zoom_on_resize;
gboolean show_transform_preview;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment