diff --git a/app/display/Makefile.am b/app/display/Makefile.am index 5d45ccdf916acd1d6f594efbd0eb51343a21f887..acb2a8493bf99aee1fb35391dfe8c35a0a54344e 100644 --- a/app/display/Makefile.am +++ b/app/display/Makefile.am @@ -25,6 +25,8 @@ libappdisplay_a_sources = \ gimpcanvasboundary.h \ gimpcanvascorner.c \ gimpcanvascorner.h \ + gimpcanvasgrid.c \ + gimpcanvasgrid.h \ gimpcanvasgroup.c \ gimpcanvasgroup.h \ gimpcanvasguide.c \ diff --git a/app/display/gimpcanvasgrid.c b/app/display/gimpcanvasgrid.c new file mode 100644 index 0000000000000000000000000000000000000000..52248860d986e7e7a35b5a4b02ee8ca780bb3477 --- /dev/null +++ b/app/display/gimpcanvasgrid.c @@ -0,0 +1,399 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpcanvasgrid.c + * Copyright (C) 2010 Michael Natterer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" + +#include +#include + +#include "libgimpbase/gimpbase.h" +#include "libgimpmath/gimpmath.h" +#include "libgimpconfig/gimpconfig.h" + +#include "display-types.h" + +#include "core/gimpgrid.h" +#include "core/gimpimage.h" + +#include "gimpcanvasgrid.h" +#include "gimpdisplay.h" +#include "gimpdisplayshell.h" +#include "gimpdisplayshell-style.h" +#include "gimpdisplayshell-transform.h" + + +enum +{ + PROP_0, + PROP_GRID, + PROP_GRID_STYLE +}; + + +typedef struct _GimpCanvasGridPrivate GimpCanvasGridPrivate; + +struct _GimpCanvasGridPrivate +{ + GimpGrid *grid; + gboolean grid_style; +}; + +#define GET_PRIVATE(grid) \ + G_TYPE_INSTANCE_GET_PRIVATE (grid, \ + GIMP_TYPE_CANVAS_GRID, \ + GimpCanvasGridPrivate) + + +/* local function prototypes */ + +static void gimp_canvas_grid_finalize (GObject *object); +static void gimp_canvas_grid_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_canvas_grid_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +static void gimp_canvas_grid_draw (GimpCanvasItem *item, + GimpDisplayShell *shell, + cairo_t *cr); +static GdkRegion * gimp_canvas_grid_get_extents (GimpCanvasItem *item, + GimpDisplayShell *shell); +static void gimp_canvas_grid_stroke (GimpCanvasItem *item, + GimpDisplayShell *shell, + cairo_t *cr); + + +G_DEFINE_TYPE (GimpCanvasGrid, gimp_canvas_grid, GIMP_TYPE_CANVAS_ITEM) + +#define parent_class gimp_canvas_grid_parent_class + + +static void +gimp_canvas_grid_class_init (GimpCanvasGridClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass); + + object_class->finalize = gimp_canvas_grid_finalize; + object_class->set_property = gimp_canvas_grid_set_property; + object_class->get_property = gimp_canvas_grid_get_property; + + item_class->draw = gimp_canvas_grid_draw; + item_class->get_extents = gimp_canvas_grid_get_extents; + item_class->stroke = gimp_canvas_grid_stroke; + + g_object_class_install_property (object_class, PROP_GRID, + g_param_spec_object ("grid", NULL, NULL, + GIMP_TYPE_GRID, + GIMP_PARAM_READWRITE)); + + g_object_class_install_property (object_class, PROP_GRID_STYLE, + g_param_spec_boolean ("grid-style", + NULL, NULL, + FALSE, + GIMP_PARAM_READWRITE)); + + g_type_class_add_private (klass, sizeof (GimpCanvasGridPrivate)); +} + +static void +gimp_canvas_grid_init (GimpCanvasGrid *grid) +{ + GimpCanvasGridPrivate *private = GET_PRIVATE (grid); + + private->grid = g_object_new (GIMP_TYPE_GRID, NULL); +} + +static void +gimp_canvas_grid_finalize (GObject *object) +{ + GimpCanvasGridPrivate *private = GET_PRIVATE (object); + + if (private->grid) + { + g_object_unref (private->grid); + private->grid = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +gimp_canvas_grid_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpCanvasGridPrivate *private = GET_PRIVATE (object); + + switch (property_id) + { + case PROP_GRID: + { + GimpGrid *grid = g_value_get_object (value); + if (grid) + gimp_config_sync (G_OBJECT (grid), G_OBJECT (private->grid), 0); + } + break; + case PROP_GRID_STYLE: + private->grid_style = g_value_get_boolean (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_canvas_grid_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpCanvasGridPrivate *private = GET_PRIVATE (object); + + switch (property_id) + { + case PROP_GRID: + g_value_set_object (value, private->grid); + break; + case PROP_GRID_STYLE: + g_value_set_boolean (value, private->grid_style); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_canvas_grid_draw (GimpCanvasItem *item, + GimpDisplayShell *shell, + cairo_t *cr) +{ + GimpCanvasGridPrivate *private = GET_PRIVATE (item); + GimpImage *image = gimp_display_get_image (shell->display); + gdouble x, y; + gdouble dx1, dy1, dx2, dy2; + gint x0, x1, x2, x3; + gint y0, y1, y2, y3; + gint x_real, y_real; + gdouble x_offset, y_offset; + gint width, height; + +#define CROSSHAIR 2 + + g_return_if_fail (private->grid->xspacing > 0 && private->grid->yspacing > 0); + + cairo_clip_extents (cr, &dx1, &dy1, &dx2, &dy2); + + x1 = floor (dx1); + y1 = floor (dy1); + x2 = ceil (dx2); + y2 = ceil (dy2); + + width = gimp_image_get_width (image); + height = gimp_image_get_height (image); + + x_offset = private->grid->xoffset; + while (x_offset > 0) + x_offset -= private->grid->xspacing; + + y_offset = private->grid->yoffset; + while (y_offset > 0) + y_offset -= private->grid->yspacing; + + switch (private->grid->style) + { + case GIMP_GRID_DOTS: + for (x = x_offset; x <= width; x += private->grid->xspacing) + { + if (x < 0) + continue; + + gimp_display_shell_transform_xy (shell, x, 0, &x_real, &y_real); + + if (x_real < x1 || x_real >= x2) + continue; + + for (y = y_offset; y <= height; y += private->grid->yspacing) + { + if (y < 0) + continue; + + gimp_display_shell_transform_xy (shell, x, y, &x_real, &y_real); + + if (y_real >= y1 && y_real < y2) + { + cairo_move_to (cr, x_real, y_real + 0.5); + cairo_line_to (cr, x_real + 1, y_real + 0.5); + } + } + } + break; + + case GIMP_GRID_INTERSECTIONS: + for (x = x_offset; x <= width; x += private->grid->xspacing) + { + if (x < 0) + continue; + + gimp_display_shell_transform_xy (shell, x, 0, &x_real, &y_real); + + if (x_real + CROSSHAIR < x1 || x_real - CROSSHAIR >= x2) + continue; + + for (y = y_offset; y <= height; y += private->grid->yspacing) + { + if (y < 0) + continue; + + gimp_display_shell_transform_xy (shell, x, y, &x_real, &y_real); + + if (y_real + CROSSHAIR < y1 || y_real - CROSSHAIR >= y2) + continue; + + if (x_real >= x1 && x_real < x2) + { + cairo_move_to (cr, + x_real + 0.5, + CLAMP (y_real - CROSSHAIR, + y1, y2 - 1)); + cairo_line_to (cr, + x_real + 0.5, + CLAMP (y_real + CROSSHAIR, + y1, y2 - 1) + 1); + } + + if (y_real >= y1 && y_real < y2) + { + cairo_move_to (cr, + CLAMP (x_real - CROSSHAIR, + x1, x2 - 1), + y_real + 0.5); + cairo_line_to (cr, + CLAMP (x_real + CROSSHAIR, + x1, x2 - 1) + 1, + y_real + 0.5); + } + } + } + break; + + case GIMP_GRID_ON_OFF_DASH: + case GIMP_GRID_DOUBLE_DASH: + case GIMP_GRID_SOLID: + gimp_display_shell_transform_xy (shell, 0, 0, &x0, &y0); + gimp_display_shell_transform_xy (shell, width, height, &x3, &y3); + + for (x = x_offset; x < width; x += private->grid->xspacing) + { + if (x < 0) + continue; + + gimp_display_shell_transform_xy (shell, x, 0, &x_real, &y_real); + + if (x_real >= x1 && x_real < x2) + { + cairo_move_to (cr, x_real + 0.5, y0); + cairo_line_to (cr, x_real + 0.5, y3 + 1); + } + } + + for (y = y_offset; y < height; y += private->grid->yspacing) + { + if (y < 0) + continue; + + gimp_display_shell_transform_xy (shell, 0, y, &x_real, &y_real); + + if (y_real >= y1 && y_real < y2) + { + cairo_move_to (cr, x0, y_real + 0.5); + cairo_line_to (cr, x3 + 1, y_real + 0.5); + } + } + break; + } + + _gimp_canvas_item_stroke (item, cr); +} + +static GdkRegion * +gimp_canvas_grid_get_extents (GimpCanvasItem *item, + GimpDisplayShell *shell) +{ + GimpImage *image = gimp_display_get_image (shell->display); + GdkRectangle rectangle; + gdouble x1, y1; + gdouble x2, y2; + gint w, h; + + if (! image) + return NULL; + + w = gimp_image_get_width (image); + h = gimp_image_get_height (image); + + gimp_display_shell_transform_xy_f (shell, 0, 0, &x1, &y1); + gimp_display_shell_transform_xy_f (shell, w, h, &x2, &y2); + + rectangle.x = floor (x1); + rectangle.y = floor (y1); + rectangle.width = ceil (x2) - rectangle.x; + rectangle.height = ceil (y2) - rectangle.y; + + return gdk_region_rectangle (&rectangle); +} + +static void +gimp_canvas_grid_stroke (GimpCanvasItem *item, + GimpDisplayShell *shell, + cairo_t *cr) +{ + GimpCanvasGridPrivate *private = GET_PRIVATE (item); + + if (private->grid_style) + { + gimp_display_shell_set_grid_style (shell, cr, private->grid); + cairo_stroke (cr); + } + else + { + GIMP_CANVAS_ITEM_CLASS (parent_class)->stroke (item, shell, cr); + } +} + +GimpCanvasItem * +gimp_canvas_grid_new (GimpDisplayShell *shell, + GimpGrid *grid) +{ + g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL); + g_return_val_if_fail (grid == NULL || GIMP_IS_GRID (grid), NULL); + + return g_object_new (GIMP_TYPE_CANVAS_GRID, + "shell", shell, + "grid", grid, + NULL); +} diff --git a/app/display/gimpcanvasgrid.h b/app/display/gimpcanvasgrid.h new file mode 100644 index 0000000000000000000000000000000000000000..c9ac63b26ff606ab8fdc2704bb811fd99f1f5d2e --- /dev/null +++ b/app/display/gimpcanvasgrid.h @@ -0,0 +1,56 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * gimpcanvasgrid.h + * Copyright (C) 2010 Michael Natterer + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __GIMP_CANVAS_GRID_H__ +#define __GIMP_CANVAS_GRID_H__ + + +#include "gimpcanvasitem.h" + + +#define GIMP_TYPE_CANVAS_GRID (gimp_canvas_grid_get_type ()) +#define GIMP_CANVAS_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_GRID, GimpCanvasGrid)) +#define GIMP_CANVAS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_GRID, GimpCanvasGridClass)) +#define GIMP_IS_CANVAS_GRID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_GRID)) +#define GIMP_IS_CANVAS_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_GRID)) +#define GIMP_CANVAS_GRID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_GRID, GimpCanvasGridClass)) + + +typedef struct _GimpCanvasGrid GimpCanvasGrid; +typedef struct _GimpCanvasGridClass GimpCanvasGridClass; + +struct _GimpCanvasGrid +{ + GimpCanvasItem parent_instance; +}; + +struct _GimpCanvasGridClass +{ + GimpCanvasItemClass parent_class; +}; + + +GType gimp_canvas_grid_get_type (void) G_GNUC_CONST; + +GimpCanvasItem * gimp_canvas_grid_new (GimpDisplayShell *shell, + GimpGrid *grid); + + +#endif /* __GIMP_CANVAS_GRID_H__ */ diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c index 86a91ef15f4c5f78a0254ef533db695bc5756895..6d2698904bc84d8c27743cf86188b3c580b762de 100644 --- a/app/display/gimpdisplayshell-appearance.c +++ b/app/display/gimpdisplayshell-appearance.c @@ -30,9 +30,6 @@ #include "core/gimp.h" #include "core/gimpcontext.h" #include "core/gimpimage.h" -#include "core/gimpimage-grid.h" -#include "core/gimpimage-guides.h" -#include "core/gimpimage-sample-points.h" #include "widgets/gimpactiongroup.h" #include "widgets/gimprender.h" @@ -321,7 +318,6 @@ gimp_display_shell_set_show_grid (GimpDisplayShell *shell, gboolean show) { GimpDisplayOptions *options; - GimpImage *image; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); @@ -329,12 +325,7 @@ gimp_display_shell_set_show_grid (GimpDisplayShell *shell, g_object_set (options, "show-grid", show, NULL); - image = gimp_display_get_image (shell->display); - - if (image && gimp_image_get_grid (image)) - { - gimp_display_shell_expose_full (shell); - } + gimp_canvas_item_set_visible (shell->grid, show); appearance_set_action_active (shell, "view-show-grid", show); } diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index 95085027737787c67f031134f86ef55bdf36d0f1..f8ba60c8eb707c216fb153e64632a75755549201 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -2335,11 +2335,6 @@ gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell, gimp_display_shell_draw_vectors (shell, cr); cairo_restore (cr); - /* draw the grid */ - cairo_save (cr); - gimp_display_shell_draw_grid (shell, cr); - cairo_restore (cr); - /* draw canvas items */ cairo_save (cr); gimp_canvas_item_draw (shell->canvas_item, cr); diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 489586a6467d849e669caccae8f1933c604788d2..6cf4ca7b8a7b413b80b5b97f46a7fa02521043c8 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -31,9 +31,7 @@ #include "core/gimpcontext.h" #include "core/gimpdrawable.h" -#include "core/gimpgrid.h" #include "core/gimpimage.h" -#include "core/gimpimage-grid.h" #include "core/gimpprojection.h" #include "vectors/gimpstroke.h" @@ -123,181 +121,6 @@ gimp_display_shell_draw_get_scaled_image_size_for_scale (GimpDisplayShell *shell if (h) *h = PROJ_ROUND (level_height * (scale_y * (1 << level))); } -void -gimp_display_shell_draw_grid (GimpDisplayShell *shell, - cairo_t *cr) -{ - GimpImage *image; - - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - g_return_if_fail (cr != NULL); - - image = gimp_display_get_image (shell->display); - - if (image && gimp_display_shell_get_show_grid (shell)) - { - GimpGrid *grid; - gdouble x, y; - gdouble dx1, dy1, dx2, dy2; - gint x0, x1, x2, x3; - gint y0, y1, y2, y3; - gint x_real, y_real; - gdouble x_offset, y_offset; - gint width, height; - -#define CROSSHAIR 2 - - grid = gimp_image_get_grid (image); - if (! grid) - return; - - g_return_if_fail (grid->xspacing > 0 && grid->yspacing > 0); - - cairo_clip_extents (cr, &dx1, &dy1, &dx2, &dy2); - - x1 = floor (dx1); - y1 = floor (dy1); - x2 = ceil (dx2); - y2 = ceil (dy2); - - width = gimp_image_get_width (image); - height = gimp_image_get_height (image); - - x_offset = grid->xoffset; - while (x_offset > 0) - x_offset -= grid->xspacing; - - y_offset = grid->yoffset; - while (y_offset > 0) - y_offset -= grid->yspacing; - - gimp_display_shell_set_grid_style (shell, cr, grid); - - switch (grid->style) - { - case GIMP_GRID_DOTS: - for (x = x_offset; x <= width; x += grid->xspacing) - { - if (x < 0) - continue; - - gimp_display_shell_transform_xy (shell, - x, 0, &x_real, &y_real); - - if (x_real < x1 || x_real >= x2) - continue; - - for (y = y_offset; y <= height; y += grid->yspacing) - { - if (y < 0) - continue; - - gimp_display_shell_transform_xy (shell, - x, y, &x_real, &y_real); - - if (y_real >= y1 && y_real < y2) - { - cairo_move_to (cr, x_real, y_real + 0.5); - cairo_line_to (cr, x_real + 1, y_real + 0.5); - } - } - } - break; - - case GIMP_GRID_INTERSECTIONS: - for (x = x_offset; x <= width; x += grid->xspacing) - { - if (x < 0) - continue; - - gimp_display_shell_transform_xy (shell, - x, 0, &x_real, &y_real); - - if (x_real + CROSSHAIR < x1 || x_real - CROSSHAIR >= x2) - continue; - - for (y = y_offset; y <= height; y += grid->yspacing) - { - if (y < 0) - continue; - - gimp_display_shell_transform_xy (shell, - x, y, &x_real, &y_real); - - if (y_real + CROSSHAIR < y1 || y_real - CROSSHAIR >= y2) - continue; - - if (x_real >= x1 && x_real < x2) - { - cairo_move_to (cr, - x_real + 0.5, - CLAMP (y_real - CROSSHAIR, - y1, y2 - 1)); - cairo_line_to (cr, - x_real + 0.5, - CLAMP (y_real + CROSSHAIR, - y1, y2 - 1) + 1); - } - - if (y_real >= y1 && y_real < y2) - { - cairo_move_to (cr, - CLAMP (x_real - CROSSHAIR, - x1, x2 - 1), - y_real + 0.5); - cairo_line_to (cr, - CLAMP (x_real + CROSSHAIR, - x1, x2 - 1) + 1, - y_real + 0.5); - } - } - } - break; - - case GIMP_GRID_ON_OFF_DASH: - case GIMP_GRID_DOUBLE_DASH: - case GIMP_GRID_SOLID: - gimp_display_shell_transform_xy (shell, - 0, 0, &x0, &y0); - gimp_display_shell_transform_xy (shell, - width, height, &x3, &y3); - - for (x = x_offset; x < width; x += grid->xspacing) - { - if (x < 0) - continue; - - gimp_display_shell_transform_xy (shell, - x, 0, &x_real, &y_real); - - if (x_real >= x1 && x_real < x2) - { - cairo_move_to (cr, x_real + 0.5, y0); - cairo_line_to (cr, x_real + 0.5, y3 + 1); - } - } - - for (y = y_offset; y < height; y += grid->yspacing) - { - if (y < 0) - continue; - - gimp_display_shell_transform_xy (shell, - 0, y, &x_real, &y_real); - - if (y_real >= y1 && y_real < y2) - { - cairo_move_to (cr, x0, y_real + 0.5); - cairo_line_to (cr, x3 + 1, y_real + 0.5); - } - } - break; - } - - cairo_stroke (cr); - } -} - void gimp_display_shell_draw_pen (GimpDisplayShell *shell, cairo_t *cr, diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h index 09843f43cb83aa78919e952354ebbd390e15b5f1..8f6ef7f7f4ab70cd8958e3aa86b1c774d726bbf6 100644 --- a/app/display/gimpdisplayshell-draw.h +++ b/app/display/gimpdisplayshell-draw.h @@ -27,8 +27,7 @@ void gimp_display_shell_draw_get_scaled_image_size_for_scale gdouble scale, gint *w, gint *h); -void gimp_display_shell_draw_grid (GimpDisplayShell *shell, - cairo_t *cr); + void gimp_display_shell_draw_pen (GimpDisplayShell *shell, cairo_t *cr, const GimpVector2 *points, diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index 406e95b5114945cdfad6288233ba2ae5ad5c6ae4..0963e478db250766117d21bc31cc616bdf52ea11 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -176,9 +176,12 @@ gimp_display_shell_connect (GimpDisplayShell *shell) g_signal_connect (image, "undo-event", G_CALLBACK (gimp_display_shell_undo_event_handler), shell); + g_signal_connect (gimp_image_get_grid (image), "notify", G_CALLBACK (gimp_display_shell_grid_notify_handler), shell); + g_object_set (shell->grid, "grid", gimp_image_get_grid (image), NULL); + g_signal_connect (image, "name-changed", G_CALLBACK (gimp_display_shell_name_changed_handler), shell); @@ -457,10 +460,7 @@ gimp_display_shell_grid_notify_handler (GimpGrid *grid, GParamSpec *pspec, GimpDisplayShell *shell) { - gimp_display_shell_expose_full (shell); - - /* update item factory */ - gimp_display_flush (shell->display); + g_object_set (shell->grid, "grid", grid, NULL); } static void diff --git a/app/display/gimpdisplayshell-items.c b/app/display/gimpdisplayshell-items.c index adbc643bab04344f7aaacdcdcaf2dbe394223253..6b4f488a4c5b5f8979d7661536c9ffc5c783906e 100644 --- a/app/display/gimpdisplayshell-items.c +++ b/app/display/gimpdisplayshell-items.c @@ -24,6 +24,7 @@ #include "display-types.h" +#include "gimpcanvasgrid.h" #include "gimpcanvasproxygroup.h" #include "gimpdisplayshell.h" #include "gimpdisplayshell-expose.h" @@ -46,6 +47,11 @@ gimp_display_shell_items_init (GimpDisplayShell *shell) shell->canvas_item = gimp_canvas_group_new (shell); + 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); + g_object_unref (shell->grid); + shell->guides = gimp_canvas_proxy_group_new (shell); gimp_display_shell_add_item (shell, shell->guides); g_object_unref (shell->guides); @@ -73,6 +79,7 @@ gimp_display_shell_items_free (GimpDisplayShell *shell) g_object_unref (shell->canvas_item); shell->canvas_item = NULL; + shell->grid = NULL; shell->guides = NULL; shell->sample_points = NULL; } diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index e65ea5d879b0196c881486938db8de9951e12384..e72cb6a1eb695483b7618db29fb6e80233a54d06 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -136,6 +136,7 @@ struct _GimpDisplayShell cairo_pattern_t *checkerboard; /* checkerboard pattern */ GimpCanvasItem *canvas_item; /* items drawn on the canvas */ + GimpCanvasItem *grid; /* item proxy of the grid */ GimpCanvasItem *guides; /* item proxies of guides */ GimpCanvasItem *sample_points; /* item proxies of sample points */