[gimp/symmetry: 1/5] app: add a "custom" guide concept.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/symmetry: 1/5] app: add a "custom" guide concept.
- Date: Thu, 17 Dec 2015 19:54:55 +0000 (UTC)
commit be6623886eba98a9f107ff77cf791d7213c12df5
Author: Jehan <jehan girinstud io>
Date: Tue Dec 15 02:54:04 2015 +0100
app: add a "custom" guide concept.
With gimp_guide_custom_new(), you can create a custom guide with a different
style on canvas (other pattern/color/width). A custom guide won't be saved
and could be used, for instance, for specific GEGL op guiding.
app/core/gimpguide.c | 181 ++++++++++++++++++++++++++++++-
app/core/gimpguide.h | 47 ++++++---
app/display/gimpcanvas-style.c | 30 -----
app/display/gimpcanvas-style.h | 3 -
app/display/gimpcanvasguide.c | 97 +++++++++++++----
app/display/gimpcanvasguide.h | 4 +-
app/display/gimpdisplayshell-handlers.c | 20 +++-
app/tools/gimpdrawtool.c | 13 ++-
app/tools/gimpdrawtool.h | 4 +-
app/tools/gimpmovetool.c | 27 ++++-
app/xcf/xcf-save.c | 10 ++
tools/pdbgen/pdb/image_guides.pdb | 3 +-
12 files changed, 354 insertions(+), 85 deletions(-)
---
diff --git a/app/core/gimpguide.c b/app/core/gimpguide.c
index eaa8b74..aca4da8 100644
--- a/app/core/gimpguide.c
+++ b/app/core/gimpguide.c
@@ -20,9 +20,13 @@
#include "config.h"
+#include <cairo.h>
+#include <gegl.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>
#include "libgimpbase/gimpbase.h"
+#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
@@ -41,7 +45,12 @@ enum
PROP_0,
PROP_ID,
PROP_ORIENTATION,
- PROP_POSITION
+ PROP_POSITION,
+ PROP_NORMAL_FOREGROUND,
+ PROP_NORMAL_BACKGROUND,
+ PROP_ACTIVE_FOREGROUND,
+ PROP_ACTIVE_BACKGROUND,
+ PROP_LINE_WIDTH
};
@@ -50,6 +59,13 @@ struct _GimpGuidePrivate
guint32 guide_ID;
GimpOrientationType orientation;
gint position;
+
+ GimpRGB normal_foreground;
+ GimpRGB normal_background;
+ GimpRGB active_foreground;
+ GimpRGB active_background;
+ gdouble line_width;
+ gboolean custom;
};
@@ -106,6 +122,33 @@ gimp_guide_class_init (GimpGuideClass *klass)
GIMP_GUIDE_POSITION_UNDEFINED,
0);
+ g_object_class_install_property (object_class, PROP_NORMAL_FOREGROUND,
+ g_param_spec_boxed ("normal-foreground", NULL, NULL,
+ GIMP_TYPE_RGB,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_NORMAL_BACKGROUND,
+ g_param_spec_boxed ("normal-background", NULL, NULL,
+ GIMP_TYPE_RGB,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_ACTIVE_FOREGROUND,
+ g_param_spec_boxed ("active-foreground", NULL, NULL,
+ GIMP_TYPE_RGB,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_ACTIVE_BACKGROUND,
+ g_param_spec_boxed ("active-background", NULL, NULL,
+ GIMP_TYPE_RGB,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_LINE_WIDTH,
+ g_param_spec_double ("line-width", NULL, NULL,
+ 0, GIMP_MAX_IMAGE_SIZE,
+ 1.0,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_type_class_add_private (klass, sizeof (GimpGuidePrivate));
}
@@ -135,6 +178,21 @@ gimp_guide_get_property (GObject *object,
case PROP_POSITION:
g_value_set_int (value, guide->priv->position);
break;
+ case PROP_NORMAL_FOREGROUND:
+ g_value_set_boxed (value, &guide->priv->normal_foreground);
+ break;
+ case PROP_NORMAL_BACKGROUND:
+ g_value_set_boxed (value, &guide->priv->normal_background);
+ break;
+ case PROP_ACTIVE_FOREGROUND:
+ g_value_set_boxed (value, &guide->priv->active_foreground);
+ break;
+ case PROP_ACTIVE_BACKGROUND:
+ g_value_set_boxed (value, &guide->priv->active_background);
+ break;
+ case PROP_LINE_WIDTH:
+ g_value_set_double (value, guide->priv->line_width);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -160,6 +218,39 @@ gimp_guide_set_property (GObject *object,
case PROP_POSITION:
guide->priv->position = g_value_get_int (value);
break;
+ case PROP_NORMAL_FOREGROUND:
+ {
+ GimpRGB *color = g_value_get_boxed (value);
+
+ guide->priv->normal_foreground = *color;
+ }
+ break;
+ case PROP_NORMAL_BACKGROUND:
+ {
+ GimpRGB *color = g_value_get_boxed (value);
+
+ guide->priv->normal_background = *color;
+ }
+ break;
+ case PROP_ACTIVE_FOREGROUND:
+ {
+ GimpRGB *color = g_value_get_boxed (value);
+
+ guide->priv->active_foreground = *color;
+ }
+ break;
+ case PROP_ACTIVE_BACKGROUND:
+ {
+ GimpRGB *color = g_value_get_boxed (value);
+
+ guide->priv->active_background = *color;
+ }
+ break;
+ case PROP_LINE_WIDTH:
+ guide->priv->line_width = g_value_get_double (value);
+ if (guide->priv->line_width != 1.0)
+ guide->priv->custom = TRUE;
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -170,12 +261,66 @@ GimpGuide *
gimp_guide_new (GimpOrientationType orientation,
guint32 guide_ID)
{
+ const GimpRGB normal_fg = { 0.0, 0.0, 0.0, 1.0 };
+ const GimpRGB normal_bg = { 0.0, 0.5, 1.0, 1.0 };
+ const GimpRGB active_fg = { 0.0, 0.0, 0.0, 1.0 };
+ const GimpRGB active_bg = { 1.0, 0.0, 0.0, 1.0 };
+
return g_object_new (GIMP_TYPE_GUIDE,
- "id", guide_ID,
- "orientation", orientation,
+ "id", guide_ID,
+ "orientation", orientation,
+ "normal-foreground", &normal_fg,
+ "normal-background", &normal_bg,
+ "active-foreground", &active_fg,
+ "active-background", &active_bg,
+ "line-width", 1.0,
NULL);
}
+/**
+ * gimp_guide_custom_new:
+ * @orientation: the #GimpOrientationType
+ * @guide_ID: the unique guide ID
+ * @normal_foreground: foreground color for normal state
+ * @normal_background: background color for normal state
+ * @active_foreground: foreground color for active state
+ * @active_background: background color for active state
+ * @line_width: the width of the guide line
+ *
+ * This function returns a new guide and will flag it as "custom".
+ * Custom guides are used for purpose "other" than the basic guides
+ * a user can create oneself, for instance as symmetry guides, to
+ * drive GEGL ops, etc.
+ * They are not saved in the XCF file. If an op, a symmetry or a plugin
+ * wishes to save its state, it has to do it internally.
+ *
+ * Returns: the custom #GimpGuide.
+ **/
+GimpGuide *
+gimp_guide_custom_new (GimpOrientationType orientation,
+ guint32 guide_ID,
+ GimpRGB *normal_foreground,
+ GimpRGB *normal_background,
+ GimpRGB *active_foreground,
+ GimpRGB *active_background,
+ gdouble line_width)
+{
+ GimpGuide *guide;
+
+ guide = g_object_new (GIMP_TYPE_GUIDE,
+ "id", guide_ID,
+ "orientation", orientation,
+ "normal-foreground", normal_foreground,
+ "normal-background", normal_background,
+ "active-foreground", active_foreground,
+ "active-background", active_background,
+ "line-width", line_width,
+ NULL);
+ guide->priv->custom = TRUE;
+
+ return guide;
+}
+
guint32
gimp_guide_get_ID (GimpGuide *guide)
{
@@ -229,3 +374,33 @@ gimp_guide_removed (GimpGuide *guide)
g_signal_emit (guide, gimp_guide_signals[REMOVED], 0);
}
+
+void
+gimp_guide_get_normal_style (GimpGuide *guide,
+ GimpRGB *foreground,
+ GimpRGB *background)
+{
+ *foreground = guide->priv->normal_foreground;
+ *background = guide->priv->normal_background;
+}
+
+void
+gimp_guide_get_active_style (GimpGuide *guide,
+ GimpRGB *foreground,
+ GimpRGB *background)
+{
+ *foreground = guide->priv->active_foreground;
+ *background = guide->priv->active_background;
+}
+
+gdouble
+gimp_guide_get_line_width (GimpGuide *guide)
+{
+ return guide->priv->line_width;
+}
+
+gboolean
+gimp_guide_is_custom (GimpGuide *guide)
+{
+ return guide->priv->custom;
+}
diff --git a/app/core/gimpguide.h b/app/core/gimpguide.h
index 20cc34e..ade9f57 100644
--- a/app/core/gimpguide.h
+++ b/app/core/gimpguide.h
@@ -55,21 +55,36 @@ struct _GimpGuideClass
};
-GType gimp_guide_get_type (void) G_GNUC_CONST;
-
-GimpGuide * gimp_guide_new (GimpOrientationType orientation,
- guint32 guide_ID);
-
-guint32 gimp_guide_get_ID (GimpGuide *guide);
-
-GimpOrientationType gimp_guide_get_orientation (GimpGuide *guide);
-void gimp_guide_set_orientation (GimpGuide *guide,
- GimpOrientationType orientation);
-
-gint gimp_guide_get_position (GimpGuide *guide);
-void gimp_guide_set_position (GimpGuide *guide,
- gint position);
-void gimp_guide_removed (GimpGuide *guide);
-
+GType gimp_guide_get_type (void) G_GNUC_CONST;
+
+GimpGuide * gimp_guide_new (GimpOrientationType orientation,
+ guint32 guide_ID);
+GimpGuide * gimp_guide_custom_new (GimpOrientationType orientation,
+ guint32 guide_ID,
+ GimpRGB *normal_foreground,
+ GimpRGB *normal_background,
+ GimpRGB *active_foreground,
+ GimpRGB *active_background,
+ gdouble line_width);
+
+guint32 gimp_guide_get_ID (GimpGuide *guide);
+
+GimpOrientationType gimp_guide_get_orientation (GimpGuide *guide);
+void gimp_guide_set_orientation (GimpGuide *guide,
+ GimpOrientationType orientation);
+
+gint gimp_guide_get_position (GimpGuide *guide);
+void gimp_guide_set_position (GimpGuide *guide,
+ gint position);
+void gimp_guide_removed (GimpGuide *guide);
+
+void gimp_guide_get_normal_style (GimpGuide *guide,
+ GimpRGB *foreground,
+ GimpRGB *background);
+void gimp_guide_get_active_style (GimpGuide *guide,
+ GimpRGB *foreground,
+ GimpRGB *background);
+gdouble gimp_guide_get_line_width (GimpGuide *guide);
+gboolean gimp_guide_is_custom (GimpGuide *guide);
#endif /* __GIMP_GUIDE_H__ */
diff --git a/app/display/gimpcanvas-style.c b/app/display/gimpcanvas-style.c
index 81b840b..39ade03 100644
--- a/app/display/gimpcanvas-style.c
+++ b/app/display/gimpcanvas-style.c
@@ -35,11 +35,6 @@
#include "gimpcanvas-style.h"
-static const GimpRGB guide_normal_fg = { 0.0, 0.0, 0.0, 1.0 };
-static const GimpRGB guide_normal_bg = { 0.0, 0.5, 1.0, 1.0 };
-static const GimpRGB guide_active_fg = { 0.0, 0.0, 0.0, 1.0 };
-static const GimpRGB guide_active_bg = { 1.0, 0.0, 0.0, 1.0 };
-
static const GimpRGB sample_point_normal = { 0.0, 0.5, 1.0, 1.0 };
static const GimpRGB sample_point_active = { 1.0, 0.0, 0.0, 1.0 };
@@ -77,31 +72,6 @@ static const GimpRGB tool_fg_highlight = { 1.0, 0.8, 0.2, 0.8 };
/* public functions */
void
-gimp_canvas_set_guide_style (GtkWidget *canvas,
- cairo_t *cr,
- gboolean active)
-{
- cairo_pattern_t *pattern;
-
- g_return_if_fail (GTK_IS_WIDGET (canvas));
- g_return_if_fail (cr != NULL);
-
- cairo_set_line_width (cr, 1.0);
-
- if (active)
- pattern = gimp_cairo_stipple_pattern_create (&guide_active_fg,
- &guide_active_bg,
- 0);
- else
- pattern = gimp_cairo_stipple_pattern_create (&guide_normal_fg,
- &guide_normal_bg,
- 0);
-
- cairo_set_source (cr, pattern);
- cairo_pattern_destroy (pattern);
-}
-
-void
gimp_canvas_set_sample_point_style (GtkWidget *canvas,
cairo_t *cr,
gboolean active)
diff --git a/app/display/gimpcanvas-style.h b/app/display/gimpcanvas-style.h
index 9715a76..726afa6 100644
--- a/app/display/gimpcanvas-style.h
+++ b/app/display/gimpcanvas-style.h
@@ -22,9 +22,6 @@
#define __GIMP_CANVAS_STYLE_H__
-void gimp_canvas_set_guide_style (GtkWidget *canvas,
- cairo_t *cr,
- gboolean active);
void gimp_canvas_set_sample_point_style (GtkWidget *canvas,
cairo_t *cr,
gboolean active);
diff --git a/app/display/gimpcanvasguide.c b/app/display/gimpcanvasguide.c
index b0788ce..4d4e65f 100644
--- a/app/display/gimpcanvasguide.c
+++ b/app/display/gimpcanvasguide.c
@@ -38,7 +38,9 @@ enum
PROP_0,
PROP_ORIENTATION,
PROP_POSITION,
- PROP_GUIDE_STYLE
+ PROP_NORMAL_STYLE,
+ PROP_ACTIVE_STYLE,
+ PROP_LINE_WIDTH
};
@@ -46,9 +48,12 @@ typedef struct _GimpCanvasGuidePrivate GimpCanvasGuidePrivate;
struct _GimpCanvasGuidePrivate
{
- GimpOrientationType orientation;
- gint position;
- gboolean guide_style;
+ GimpOrientationType orientation;
+ gint position;
+
+ cairo_pattern_t *active_style;
+ cairo_pattern_t *normal_style;
+ gdouble line_width;
};
#define GET_PRIVATE(guide) \
@@ -59,6 +64,7 @@ struct _GimpCanvasGuidePrivate
/* local function prototypes */
+static void gimp_canvas_guide_finalize (GObject *object);
static void gimp_canvas_guide_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -85,6 +91,7 @@ gimp_canvas_guide_class_init (GimpCanvasGuideClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
+ object_class->finalize = gimp_canvas_guide_finalize;
object_class->set_property = gimp_canvas_guide_set_property;
object_class->get_property = gimp_canvas_guide_get_property;
@@ -104,11 +111,20 @@ gimp_canvas_guide_class_init (GimpCanvasGuideClass *klass)
GIMP_MAX_IMAGE_SIZE, 0,
GIMP_PARAM_READWRITE));
- g_object_class_install_property (object_class, PROP_GUIDE_STYLE,
- g_param_spec_boolean ("guide-style",
- NULL, NULL,
- FALSE,
- GIMP_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_NORMAL_STYLE,
+ g_param_spec_pointer ("normal-style", NULL, NULL,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_ACTIVE_STYLE,
+ g_param_spec_pointer ("active-style", NULL, NULL,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_LINE_WIDTH,
+ g_param_spec_double ("line-width", NULL, NULL,
+ 0, GIMP_MAX_IMAGE_SIZE,
+ 1.0,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
g_type_class_add_private (klass, sizeof (GimpCanvasGuidePrivate));
}
@@ -119,6 +135,17 @@ gimp_canvas_guide_init (GimpCanvasGuide *guide)
}
static void
+gimp_canvas_guide_finalize (GObject *object)
+{
+ GimpCanvasGuidePrivate *private = GET_PRIVATE (object);
+
+ cairo_pattern_destroy (private->normal_style);
+ cairo_pattern_destroy (private->active_style);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
gimp_canvas_guide_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -134,8 +161,18 @@ gimp_canvas_guide_set_property (GObject *object,
case PROP_POSITION:
private->position = g_value_get_int (value);
break;
- case PROP_GUIDE_STYLE:
- private->guide_style = g_value_get_boolean (value);
+ case PROP_NORMAL_STYLE:
+ if (private->normal_style)
+ cairo_pattern_destroy (private->normal_style);
+ private->normal_style = g_value_get_pointer (value);
+ break;
+ case PROP_ACTIVE_STYLE:
+ if (private->active_style)
+ cairo_pattern_destroy (private->active_style);
+ private->active_style = g_value_get_pointer (value);
+ break;
+ case PROP_LINE_WIDTH:
+ private->line_width = g_value_get_double (value);
break;
default:
@@ -160,8 +197,14 @@ gimp_canvas_guide_get_property (GObject *object,
case PROP_POSITION:
g_value_set_int (value, private->position);
break;
- case PROP_GUIDE_STYLE:
- g_value_set_boolean (value, private->guide_style);
+ case PROP_NORMAL_STYLE:
+ g_value_set_pointer (value, private->normal_style);
+ break;
+ case PROP_ACTIVE_STYLE:
+ g_value_set_pointer (value, private->active_style);
+ break;
+ case PROP_LINE_WIDTH:
+ g_value_set_double (value, private->line_width);
break;
default:
@@ -247,10 +290,18 @@ gimp_canvas_guide_stroke (GimpCanvasItem *item,
{
GimpCanvasGuidePrivate *private = GET_PRIVATE (item);
- if (private->guide_style)
+ if (private->active_style &&
+ gimp_canvas_item_get_highlight (item))
+ {
+ cairo_set_line_width (cr, private->line_width);
+ cairo_set_source (cr, private->active_style);
+ cairo_stroke (cr);
+ }
+ else if (private->normal_style &&
+ ! gimp_canvas_item_get_highlight (item))
{
- gimp_canvas_set_guide_style (gimp_canvas_item_get_canvas (item), cr,
- gimp_canvas_item_get_highlight (item));
+ cairo_set_line_width (cr, private->line_width);
+ cairo_set_source (cr, private->normal_style);
cairo_stroke (cr);
}
else
@@ -263,15 +314,19 @@ GimpCanvasItem *
gimp_canvas_guide_new (GimpDisplayShell *shell,
GimpOrientationType orientation,
gint position,
- gboolean guide_style)
+ cairo_pattern_t *normal_style,
+ cairo_pattern_t *active_style,
+ gdouble line_width)
{
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
return g_object_new (GIMP_TYPE_CANVAS_GUIDE,
- "shell", shell,
- "orientation", orientation,
- "position", position,
- "guide-style", guide_style,
+ "shell", shell,
+ "orientation", orientation,
+ "position", position,
+ "normal-style", normal_style,
+ "active-style", active_style,
+ "line-width", line_width,
NULL);
}
diff --git a/app/display/gimpcanvasguide.h b/app/display/gimpcanvasguide.h
index 29d6295..380238b 100644
--- a/app/display/gimpcanvasguide.h
+++ b/app/display/gimpcanvasguide.h
@@ -52,7 +52,9 @@ GType gimp_canvas_guide_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_guide_new (GimpDisplayShell *shell,
GimpOrientationType orientation,
gint position,
- gboolean guide_style);
+ cairo_pattern_t *normal_style,
+ cairo_pattern_t *active_style,
+ gdouble line_width);
void gimp_canvas_guide_set (GimpCanvasItem *guide,
GimpOrientationType orientation,
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 37c218e..c412cbf 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -31,6 +31,7 @@
#include "config/gimpdisplayoptions.h"
#include "core/gimp.h"
+#include "core/gimp-cairo.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-grid.h"
@@ -622,11 +623,26 @@ gimp_display_shell_guide_add_handler (GimpImage *image,
{
GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->guides);
GimpCanvasItem *item;
-
+ cairo_pattern_t *normal_style;
+ cairo_pattern_t *active_style;
+ GimpRGB normal_foreground;
+ GimpRGB normal_background;
+ GimpRGB active_foreground;
+ GimpRGB active_background;
+
+ gimp_guide_get_normal_style (guide, &normal_foreground, &normal_background);
+ gimp_guide_get_active_style (guide, &active_foreground, &active_background);
+ normal_style = gimp_cairo_stipple_pattern_create (&normal_foreground,
+ &normal_background,
+ 0);
+ active_style = gimp_cairo_stipple_pattern_create (&active_foreground,
+ &active_background,
+ 0);
item = gimp_canvas_guide_new (shell,
gimp_guide_get_orientation (guide),
gimp_guide_get_position (guide),
- TRUE);
+ normal_style, active_style,
+ gimp_guide_get_line_width (guide));
gimp_canvas_proxy_group_add_item (group, guide, item);
g_object_unref (item);
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 1f707f0..85f6fd3 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -583,14 +583,17 @@ GimpCanvasItem *
gimp_draw_tool_add_guide (GimpDrawTool *draw_tool,
GimpOrientationType orientation,
gint position,
- gboolean guide_style)
+ cairo_pattern_t *normal_style,
+ cairo_pattern_t *active_style,
+ gdouble line_width)
{
GimpCanvasItem *item;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
item = gimp_canvas_guide_new (gimp_display_get_shell (draw_tool->display),
- orientation, position, guide_style);
+ orientation, position,
+ normal_style, active_style, line_width);
gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item);
@@ -617,9 +620,11 @@ gimp_draw_tool_add_crosshair (GimpDrawTool *draw_tool,
gimp_draw_tool_push_group (draw_tool, group);
gimp_draw_tool_add_guide (draw_tool,
- GIMP_ORIENTATION_VERTICAL, position_x, FALSE);
+ GIMP_ORIENTATION_VERTICAL, position_x,
+ NULL, NULL, 1.0);
gimp_draw_tool_add_guide (draw_tool,
- GIMP_ORIENTATION_HORIZONTAL, position_y, FALSE);
+ GIMP_ORIENTATION_HORIZONTAL, position_y,
+ NULL, NULL, 1.0);
gimp_draw_tool_pop_group (draw_tool);
return GIMP_CANVAS_ITEM (group);
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index 6f358c4..2ae34b2 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -115,7 +115,9 @@ GimpCanvasItem * gimp_draw_tool_add_line (GimpDrawTool *draw_too
GimpCanvasItem * gimp_draw_tool_add_guide (GimpDrawTool *draw_tool,
GimpOrientationType orientation,
gint position,
- gboolean guide_style);
+ cairo_pattern_t *normal_style,
+ cairo_pattern_t *active_style,
+ gdouble line_width);
GimpCanvasItem * gimp_draw_tool_add_crosshair (GimpDrawTool *draw_tool,
gint position_x,
gint position_y);
diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c
index 6e89f6c..6f9a2e6 100644
--- a/app/tools/gimpmovetool.c
+++ b/app/tools/gimpmovetool.c
@@ -31,6 +31,7 @@
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
+#include "core/gimp-cairo.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
@@ -834,12 +835,32 @@ gimp_move_tool_draw (GimpDrawTool *draw_tool)
if (move->guide)
{
- GimpCanvasItem *item;
+ GimpCanvasItem *item;
+ cairo_pattern_t *normal_style;
+ cairo_pattern_t *active_style;
+ GimpRGB normal_foreground;
+ GimpRGB normal_background;
+ GimpRGB active_foreground;
+ GimpRGB active_background;
+
+ gimp_guide_get_normal_style (move->guide,
+ &normal_foreground,
+ &normal_background);
+ gimp_guide_get_active_style (move->guide,
+ &active_foreground,
+ &active_background);
+ normal_style = gimp_cairo_stipple_pattern_create (&normal_foreground,
+ &normal_background,
+ 0);
+ active_style = gimp_cairo_stipple_pattern_create (&active_foreground,
+ &active_background,
+ 0);
item = gimp_draw_tool_add_guide (draw_tool,
gimp_guide_get_orientation (move->guide),
gimp_guide_get_position (move->guide),
- TRUE);
+ normal_style, active_style,
+ gimp_guide_get_line_width (move->guide));
gimp_canvas_item_set_highlight (item, TRUE);
}
@@ -849,7 +870,7 @@ gimp_move_tool_draw (GimpDrawTool *draw_tool)
gimp_draw_tool_add_guide (draw_tool,
move->guide_orientation,
move->guide_position,
- FALSE);
+ NULL, NULL, 1.0);
}
}
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index 5ada022..7bf2179 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -890,12 +890,19 @@ xcf_save_prop (XcfInfo *info,
case PROP_GUIDES:
{
+ GList *iter;
GList *guides;
gint n_guides;
guides = va_arg (args, GList *);
n_guides = g_list_length (guides);
+ for (iter = guides; iter; iter = g_list_next (iter))
+ {
+ /* Do not save custom guides. */
+ if (gimp_guide_is_custom (GIMP_GUIDE (iter->data)))
+ n_guides--;
+ }
size = n_guides * (4 + 1);
xcf_write_prop_type_check_error (info, prop_type);
@@ -907,6 +914,9 @@ xcf_save_prop (XcfInfo *info,
gint32 position = gimp_guide_get_position (guide);
gint8 orientation;
+ if (gimp_guide_is_custom (guide))
+ continue;
+
switch (gimp_guide_get_orientation (guide))
{
case GIMP_ORIENTATION_HORIZONTAL:
diff --git a/tools/pdbgen/pdb/image_guides.pdb b/tools/pdbgen/pdb/image_guides.pdb
index dcfd9ca..88e0c49 100644
--- a/tools/pdbgen/pdb/image_guides.pdb
+++ b/tools/pdbgen/pdb/image_guides.pdb
@@ -246,7 +246,8 @@ CODE
}
- headers = qw("core/gimpguide.h"
+ headers = qw("cairo.h"
+ "core/gimpguide.h"
"core/gimpimage-guides.h"
"core/gimpimage-undo-push.h"
"gimppdb-utils.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]