mirror of https://github.com/GNOME/gimp.git
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.
This commit is contained in:
parent
b6a756f284
commit
b8fadf3ad7
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -55,21 +55,36 @@ struct _GimpGuideClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_guide_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_guide_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpGuide * gimp_guide_new (GimpOrientationType orientation,
|
||||
guint32 guide_ID);
|
||||
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);
|
||||
guint32 gimp_guide_get_ID (GimpGuide *guide);
|
||||
|
||||
GimpOrientationType gimp_guide_get_orientation (GimpGuide *guide);
|
||||
void gimp_guide_set_orientation (GimpGuide *guide,
|
||||
GimpOrientationType orientation);
|
||||
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);
|
||||
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__ */
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
@ -76,31 +71,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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
@ -118,6 +134,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,
|
||||
|
@ -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))
|
||||
{
|
||||
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->active_style);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
else if (private->normal_style &&
|
||||
! 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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-grid.h"
|
||||
|
@ -629,11 +630,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue