Commit 3415d22e authored by Michael Natterer's avatar Michael Natterer 😴

app: some cleanup in the new symmetry code, mostly harmless

parent 9e5329df
......@@ -62,7 +62,7 @@ const GimpStringActionEntry dialogs_dockable_actions[] =
GIMP_HELP_DEVICE_STATUS_DIALOG },
{ "dialogs-symmetry", GIMP_STOCK_SYMMETRY,
NC_("dialogs-action", "_Symmetry painting"), NULL,
NC_("dialogs-action", "_Symmetry Painting"), NULL,
NC_("dialogs-action", "Open the symmetry dialog"),
"gimp-symmetry-editor",
GIMP_HELP_SYMMETRY_DIALOG },
......
......@@ -369,14 +369,14 @@ libappcore_a_sources = \
gimpstrokeoptions.h \
gimpsubprogress.c \
gimpsubprogress.h \
gimpsymmetry.c \
gimpsymmetry.h \
gimpsymmetry-mandala.c \
gimpsymmetry-mandala.h \
gimpsymmetry-mirror.c \
gimpsymmetry-mirror.h \
gimpsymmetry-tiling.c \
gimpsymmetry-tiling.h \
gimpsymmetry.c \
gimpsymmetry.h \
gimpsymmetry-mandala.c \
gimpsymmetry-mandala.h \
gimpsymmetry-mirror.c \
gimpsymmetry-mirror.h \
gimpsymmetry-tiling.c \
gimpsymmetry-tiling.h \
gimptag.c \
gimptag.h \
gimptagcache.c \
......
......@@ -182,6 +182,7 @@ typedef struct _GimpMirror GimpMirror;
typedef struct _GimpTiling GimpTiling;
typedef struct _GimpMandala GimpMandala;
/* misc objects */
typedef struct _GimpBuffer GimpBuffer;
......
......@@ -652,19 +652,19 @@ gimp_brush_transform_mask (GimpBrush *brush,
if (op)
{
GeglNode *graph, *source, *target;
GeglBuffer *buffer = gimp_temp_buf_create_buffer ((GimpTempBuf *) mask);
graph = gegl_node_new ();
source = gegl_node_new_child (graph,
"operation", "gegl:buffer-source",
"buffer", buffer,
NULL);
GeglNode *graph, *source, *target;
GeglBuffer *buffer = gimp_temp_buf_create_buffer ((GimpTempBuf *) mask);
graph = gegl_node_new ();
source = gegl_node_new_child (graph,
"operation", "gegl:buffer-source",
"buffer", buffer,
NULL);
gegl_node_add_child (graph, op);
target = gegl_node_new_child (graph,
"operation", "gegl:write-buffer",
"buffer", buffer,
NULL);
target = gegl_node_new_child (graph,
"operation", "gegl:write-buffer",
"buffer", buffer,
NULL);
gegl_node_link_many (source, op, target, NULL);
gegl_node_process (target);
......@@ -672,6 +672,7 @@ gimp_brush_transform_mask (GimpBrush *brush,
g_object_unref (graph);
g_object_unref (buffer);
}
gimp_brush_cache_add (brush->priv->mask_cache,
(gpointer) mask,
op, width, height,
......@@ -725,19 +726,19 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
if (op)
{
GeglNode *graph, *source, *target;
GeglBuffer *buffer = gimp_temp_buf_create_buffer ((GimpTempBuf *) pixmap);
graph = gegl_node_new ();
source = gegl_node_new_child (graph,
"operation", "gegl:buffer-source",
"buffer", buffer,
NULL);
GeglNode *graph, *source, *target;
GeglBuffer *buffer = gimp_temp_buf_create_buffer ((GimpTempBuf *) pixmap);
graph = gegl_node_new ();
source = gegl_node_new_child (graph,
"operation", "gegl:buffer-source",
"buffer", buffer,
NULL);
gegl_node_add_child (graph, op);
target = gegl_node_new_child (graph,
"operation", "gegl:write-buffer",
"buffer", buffer,
NULL);
target = gegl_node_new_child (graph,
"operation", "gegl:write-buffer",
"buffer", buffer,
NULL);
gegl_node_link_many (source, op, target, NULL);
gegl_node_process (target);
......@@ -745,6 +746,7 @@ gimp_brush_transform_pixmap (GimpBrush *brush,
g_object_unref (graph);
g_object_unref (buffer);
}
gimp_brush_cache_add (brush->priv->pixmap_cache,
(gpointer) pixmap,
op, width, height,
......
......@@ -29,29 +29,33 @@
#include "gimp-log.h"
#include "gimp-intl.h"
#define MAX_CACHED_DATA 20
enum
{
PROP_0,
PROP_DATA_DESTROY
};
typedef struct _GimpBrushCacheUnit GimpBrushCacheUnit;
struct _GimpBrushCacheUnit
{
gpointer data;
gint width;
gint height;
gdouble scale;
gdouble aspect_ratio;
gdouble angle;
gdouble hardness;
GeglNode *op;
gpointer data;
gint width;
gint height;
gdouble scale;
gdouble aspect_ratio;
gdouble angle;
gdouble hardness;
GeglNode *op;
};
static void gimp_brush_cache_constructed (GObject *object);
static void gimp_brush_cache_finalize (GObject *object);
static void gimp_brush_cache_set_property (GObject *object,
......@@ -106,19 +110,7 @@ gimp_brush_cache_finalize (GObject *object)
{
GimpBrushCache *cache = GIMP_BRUSH_CACHE (object);
if (cache->cached_units)
{
GList *iter;
for (iter = cache->cached_units; iter; iter = g_list_next (iter))
{
GimpBrushCacheUnit *unit = iter->data;
cache->data_destroy (unit->data);
}
g_list_free_full (cache->cached_units, g_free);
cache->cached_units = NULL;
}
gimp_brush_cache_clear (cache);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -200,6 +192,7 @@ gimp_brush_cache_clear (GimpBrushCache *cache)
cache->data_destroy (unit->data);
}
g_list_free_full (cache->cached_units, g_free);
cache->cached_units = NULL;
}
......@@ -241,6 +234,7 @@ gimp_brush_cache_get (GimpBrushCache *cache,
if (cache->cached_units)
cache->cached_units->prev = iter;
cache->cached_units = iter;
return (gconstpointer) unit->data;
}
}
......@@ -262,7 +256,7 @@ gimp_brush_cache_add (GimpBrushCache *cache,
gdouble angle,
gdouble hardness)
{
GList *iter;
GList *iter;
GimpBrushCacheUnit *unit;
g_return_if_fail (GIMP_IS_BRUSH_CACHE (cache));
......@@ -271,6 +265,7 @@ gimp_brush_cache_add (GimpBrushCache *cache,
for (iter = cache->cached_units; iter; iter = g_list_next (iter))
{
unit = iter->data;
if (data == unit->data)
return;
}
......@@ -284,16 +279,16 @@ gimp_brush_cache_add (GimpBrushCache *cache,
cache->cached_units = g_list_delete_link (cache->cached_units, iter);
}
unit = g_new (GimpBrushCacheUnit, 1);
unit = g_new0 (GimpBrushCacheUnit, 1);
unit->data = data;
unit->width = width;
unit->height = height;
unit->scale = scale;
unit->aspect_ratio = aspect_ratio;
unit->angle = angle;
unit->hardness = hardness;
unit->op = op;
unit->data = data;
unit->width = width;
unit->height = height;
unit->scale = scale;
unit->aspect_ratio = aspect_ratio;
unit->angle = angle;
unit->hardness = hardness;
unit->op = op;
cache->cached_units = g_list_prepend (cache->cached_units, unit);
}
......@@ -34,6 +34,7 @@
#include "gimpguide.h"
#include "gimpmarshal.h"
enum
{
REMOVED,
......
......@@ -87,4 +87,5 @@ void gimp_guide_get_active_style (GimpGuide *guide,
gdouble gimp_guide_get_line_width (GimpGuide *guide);
gboolean gimp_guide_is_custom (GimpGuide *guide);
#endif /* __GIMP_GUIDE_H__ */
......@@ -33,6 +33,7 @@
#include "gimpsymmetry-mirror.h"
#include "gimpsymmetry-tiling.h"
/**
* gimp_image_symmetry_list:
*
......@@ -46,6 +47,7 @@ gimp_image_symmetry_list (void)
list = g_list_prepend (list, GINT_TO_POINTER (GIMP_TYPE_MIRROR));
list = g_list_prepend (list, GINT_TO_POINTER (GIMP_TYPE_TILING));
list = g_list_prepend (list, GINT_TO_POINTER (GIMP_TYPE_MANDALA));
return list;
}
......@@ -66,15 +68,13 @@ gimp_image_symmetry_new (GimpImage *image,
GType type)
{
GimpSymmetry *sym = NULL;
g_return_val_if_fail (g_type_is_a (type, GIMP_TYPE_SYMMETRY), NULL);
if (type != G_TYPE_NONE)
{
sym = g_object_new (type,
"image", image,
NULL);
sym->type = type;
}
sym = g_object_new (type,
"image", image,
NULL);
sym->type = type;
return sym;
}
......@@ -123,6 +123,7 @@ gimp_image_symmetry_remove (GimpImage *image,
if (private->selected_symmetry == sym)
gimp_image_symmetry_select (image, G_TYPE_NONE);
private->symmetries = g_list_remove (private->symmetries,
sym);
g_object_unref (sym);
......
......@@ -21,6 +21,7 @@
#ifndef __GIMP_IMAGE_SYMMETRY_H__
#define __GIMP_IMAGE_SYMMETRY_H__
GList * gimp_image_symmetry_list (void);
GimpSymmetry * gimp_image_symmetry_new (GimpImage *image,
......@@ -35,4 +36,5 @@ gboolean gimp_image_symmetry_select (GimpImage *image,
GType type);
GimpSymmetry * gimp_image_symmetry_selected (GimpImage *image);
#endif /* __GIMP_IMAGE_SYMMETRY_H__ */
......@@ -633,6 +633,7 @@ gimp_image_class_init (GimpImageClass *klass)
GIMP_TYPE_SYMMETRY,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (GimpImagePrivate));
}
......@@ -883,7 +884,6 @@ gimp_image_set_property (GObject *object,
NULL);
private->selected_symmetry = NULL;
for (iter = private->symmetries; iter; iter = g_list_next (iter))
{
GimpSymmetry *sym = iter->data;
......@@ -893,12 +893,12 @@ gimp_image_set_property (GObject *object,
if (private->selected_symmetry == NULL)
{
GimpSymmetry *sym;
GimpSymmetry *sym = gimp_image_symmetry_new (image, type);
sym = gimp_image_symmetry_new (image, type);
gimp_image_symmetry_add (image, sym);
private->selected_symmetry = sym;
}
g_object_set (private->selected_symmetry,
"active", TRUE,
NULL);
......
......@@ -43,16 +43,17 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_CENTER_X,
PROP_CENTER_Y,
PROP_SIZE,
PROP_DISABLE_TRANSFORMATION,
};
/* Local function prototypes */
static void gimp_mandala_constructed (GObject *object);
......@@ -94,10 +95,12 @@ static void
gint previous_height,
GimpSymmetry *sym);
G_DEFINE_TYPE (GimpMandala, gimp_mandala, GIMP_TYPE_SYMMETRY)
#define parent_class gimp_mandala_parent_class
static void
gimp_mandala_class_init (GimpMandalaClass *klass)
{
......@@ -164,9 +167,7 @@ gimp_mandala_constructed (GObject *object)
static void
gimp_mandala_finalize (GObject *object)
{
GimpMandala *mandala;
mandala = GIMP_MANDALA (object);
GimpMandala *mandala = GIMP_MANDALA (object);
if (mandala->horizontal_guide)
g_object_unref (mandala->horizontal_guide);
......@@ -283,17 +284,14 @@ gimp_mandala_add_guide (GimpMandala *mandala,
static GimpRGB normal_bg = { 0.0, 1.0, 1.0, 1.0 };
static GimpRGB active_fg = { 0.0, 1.0, 1.0, 1.0 };
static GimpRGB active_bg = { 1.0, 0.0, 0.0, 1.0 };
GimpSymmetry *sym;
GimpSymmetry *sym = GIMP_SYMMETRY (mandala);
GimpImage *image;
Gimp *gimp;
GimpGuide *guide;
gint position;
g_return_if_fail (GIMP_IS_MANDALA (mandala));
sym = GIMP_SYMMETRY (mandala);
image = sym->image;
gimp = GIMP (image->gimp);
gimp = image->gimp;
guide = gimp_guide_custom_new (orientation,
gimp->next_guide_ID++,
......@@ -319,14 +317,13 @@ gimp_mandala_add_guide (GimpMandala *mandala,
mandala->center_x = (gdouble) gimp_image_get_width (image) / 2.0;
position = (gint) mandala->center_x;
}
g_signal_connect (G_OBJECT (guide), "removed",
g_signal_connect (guide, "removed",
G_CALLBACK (gimp_mandala_guide_removed_cb),
mandala);
gimp_image_add_guide (image, guide,
(gint) position);
gimp_image_add_guide (image, guide, position);
g_signal_connect (G_OBJECT (guide), "notify::position",
g_signal_connect (guide, "notify::position",
G_CALLBACK (gimp_mandala_guide_position_cb),
mandala);
}
......@@ -335,23 +332,21 @@ static void
gimp_mandala_remove_guide (GimpMandala *mandala,
GimpOrientationType orientation)
{
GimpSymmetry *sym;
GimpSymmetry *sym = GIMP_SYMMETRY (mandala);
GimpImage *image;
GimpGuide *guide;
g_return_if_fail (GIMP_IS_MANDALA (mandala));
sym = GIMP_SYMMETRY (mandala);
image = sym->image;
guide = (orientation == GIMP_ORIENTATION_HORIZONTAL) ?
mandala->horizontal_guide : mandala->vertical_guide;
g_signal_handlers_disconnect_by_func (G_OBJECT (guide),
g_signal_handlers_disconnect_by_func (guide,
gimp_mandala_guide_removed_cb,
mandala);
g_signal_handlers_disconnect_by_func (G_OBJECT (guide),
g_signal_handlers_disconnect_by_func (guide,
gimp_mandala_guide_position_cb,
mandala);
gimp_image_remove_guide (image, guide, FALSE);
g_object_unref (guide);
......@@ -365,9 +360,7 @@ static void
gimp_mandala_guide_removed_cb (GObject *object,
GimpMandala *mandala)
{
GimpSymmetry *sym;
sym = GIMP_SYMMETRY (mandala);
GimpSymmetry *sym = GIMP_SYMMETRY (mandala);
g_signal_handlers_disconnect_by_func (object,
gimp_mandala_guide_removed_cb,
......@@ -375,6 +368,7 @@ gimp_mandala_guide_removed_cb (GObject *object,
g_signal_handlers_disconnect_by_func (object,
gimp_mandala_guide_position_cb,
mandala);
if (GIMP_GUIDE (object) == mandala->horizontal_guide)
{
g_object_unref (mandala->horizontal_guide);
......@@ -401,9 +395,7 @@ gimp_mandala_guide_position_cb (GObject *object,
GParamSpec *pspec,
GimpMandala *mandala)
{
GimpGuide *guide;
guide = GIMP_GUIDE (object);
GimpGuide *guide = GIMP_GUIDE (object);
if (guide == mandala->horizontal_guide)
{
......@@ -420,14 +412,11 @@ gimp_mandala_update_strokes (GimpSymmetry *sym,
GimpDrawable *drawable,
GimpCoords *origin)
{
GimpMandala *mandala = GIMP_MANDALA (sym);
GimpMandala *mandala = GIMP_MANDALA (sym);
GimpCoords *coords;
GimpMatrix3 matrix;
gint i;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_SYMMETRY (sym));
g_list_free_full (sym->strokes, g_free);
sym->strokes = NULL;
......@@ -456,6 +445,7 @@ gimp_mandala_update_strokes (GimpSymmetry *sym,
coords->y = new_y;
sym->strokes = g_list_prepend (sym->strokes, coords);
}
sym->strokes = g_list_reverse (sym->strokes);
g_signal_emit_by_name (sym, "strokes-updated", sym->image);
......@@ -467,13 +457,10 @@ gimp_mandala_get_operation (GimpSymmetry *sym,
gint paint_width,
gint paint_height)
{
GimpMandala *mandala = GIMP_MANDALA (sym);
GeglNode *op = NULL;
GimpMandala *mandala = GIMP_MANDALA (sym);
GeglNode *op = NULL;
gint i;
g_return_val_if_fail (GIMP_IS_MANDALA (sym), NULL);
g_return_val_if_fail (stroke < mandala->size, NULL);
if (! mandala->disable_transformation &&
stroke != 0 &&
paint_width != 0 &&
......@@ -484,6 +471,7 @@ gimp_mandala_get_operation (GimpSymmetry *sym,
mandala->cached_paint_height != paint_height)
{
GList *iter;
if (mandala->ops)
{
for (iter = mandala->ops; iter; iter = g_list_next (iter))
......@@ -496,6 +484,7 @@ gimp_mandala_get_operation (GimpSymmetry *sym,
}
mandala->ops = g_list_prepend (mandala->ops, NULL);
for (i = 1; i < mandala->size; i++)
{
op = gegl_node_new_child (NULL,
......@@ -509,9 +498,11 @@ gimp_mandala_get_operation (GimpSymmetry *sym,
NULL);
mandala->ops = g_list_prepend (mandala->ops, op);
}
mandala->ops = g_list_reverse (mandala->ops);
mandala->cached_size = mandala->size;
mandala->cached_paint_width = paint_width;
mandala->cached_size = mandala->size;
mandala->cached_paint_width = paint_width;
mandala->cached_paint_height = paint_height;
}
......@@ -523,7 +514,7 @@ gimp_mandala_get_operation (GimpSymmetry *sym,
static GParamSpec **
gimp_mandala_get_settings (GimpSymmetry *sym,
gint *n_settings)
gint *n_settings)
{
GParamSpec **pspecs;
......
......@@ -32,6 +32,7 @@
#define GIMP_IS_MANDALA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_MANDALA))
#define GIMP_MANDALA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_MANDALA, GimpMandalaClass))
typedef struct _GimpMandalaClass GimpMandalaClass;
struct _GimpMandala
......@@ -57,6 +58,8 @@ struct _GimpMandalaClass
GimpSymmetryClass parent_class;
};
GType gimp_mandala_get_type (void) G_GNUC_CONST;
GType gimp_mandala_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_MANDALA_H__ */
......@@ -42,10 +42,10 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_HORIZONTAL_SYMMETRY,
PROP_VERTICAL_SYMMETRY,
PROP_POINT_SYMMETRY,
......@@ -54,6 +54,7 @@ enum
PROP_VERTICAL_POSITION
};
/* Local function prototypes */
static void gimp_mirror_finalize (GObject *object);
......@@ -96,10 +97,12 @@ static void gimp_mirror_set_vertical_symmetry (GimpMirror *mirr
static void gimp_mirror_set_point_symmetry (GimpMirror *mirror,
gboolean active);
G_DEFINE_TYPE (GimpMirror, gimp_mirror, GIMP_TYPE_SYMMETRY)
#define parent_class gimp_mirror_parent_class
static void
gimp_mirror_class_init (GimpMirrorClass *klass)
{
......@@ -266,8 +269,8 @@ gimp_mirror_update_strokes (GimpSymmetry *sym,
GimpDrawable *drawable,
GimpCoords *origin)
{
GList *strokes = NULL;
GimpMirror *mirror = GIMP_MIRROR (sym);
GList *strokes = NULL;
GimpCoords *coords;
g_list_free_full (sym->strokes, g_free);
......@@ -280,12 +283,14 @@ gimp_mirror_update_strokes (GimpSymmetry *sym,
coords->y = 2.0 * mirror->horizontal_position - origin->y;
strokes = g_list_prepend (strokes, coords);
}
if (mirror->vertical_mirror)
{
coords = g_memdup (origin, sizeof (GimpCoords));
coords->x = 2.0 * mirror->vertical_position - origin->x;
strokes = g_list_prepend (strokes, coords);
}
if (mirror->point_symmetry)
{
coords = g_memdup (origin, sizeof (GimpCoords));
......@@ -293,6 +298,7 @@ gimp_mirror_update_strokes (GimpSymmetry *sym,
coords->y = 2.0 * mirror->horizontal_position - origin->y;
strokes = g_list_prepend (strokes, coords);
}
sym->strokes = g_list_reverse (strokes);
g_signal_emit_by_name (sym, "strokes-updated", sym->image);
......@@ -314,13 +320,10 @@ static void gimp_mirror_prepare_operations (GimpMirror *mirror,
mirror->horizontal_op = gegl_node_new_child (NULL,
"operation", "gegl:reflect",
"origin-x", 0.0,
"origin-y",
(gdouble) paint_height / 2.0,
"x",
1.0,
"y",
0.0,
"origin-x", 0.0,
"origin-y", paint_height / 2.0,
"x", 1.0,
"y", 0.0,
NULL);
if (mirror->vertical_op)
......@@ -328,13 +331,10 @@ static void gimp_mirror_prepare_operations (GimpMirror *mirror,
mirror->vertical_op = gegl_node_new_child (NULL,
"operation", "gegl:reflect",
"origin-x",
(gdouble) paint_width / 2.0,
"origin-y", 0.0,
"x",
0.0,
"y",
1.0,
"origin-x", paint_width / 2.0,
"origin-y", 0.0,
"x", 0.0,
"y", 1.0,
NULL);
if (mirror->central_op)
......@@ -342,12 +342,9 @@ static void gimp_mirror_prepare_operations (GimpMirror *mirror,
mirror->central_op = gegl_node_new_child (NULL,
"operation", "gegl:rotate",
"origin-x",
(gdouble) paint_width / 2.0,
"origin-y",
(gdouble) paint_height / 2.0,
"degrees",
180.0,
"origin-x", paint_width / 2.0,
"origin-y", paint_height / 2.0,
"degrees", 180.0,
NULL);
}
......@@ -357,7 +354,7 @@ gimp_mirror_get_operation (GimpSymmetry *sym,
gint paint_width,
gint paint_height)
{
GimpMirror *mirror = GIMP_MIRROR (sym);
GimpMirror *mirror = GIMP_MIRROR (sym);
GeglNode *op;
g_return_val_if_fail (stroke >= 0 &&
......@@ -384,11 +381,7 @@ gimp_mirror_get_operation (GimpSymmetry *sym,
static void
gimp_mirror_reset (GimpMirror *mirror)
{
GimpSymmetry *sym;
g_return_if_fail (GIMP_IS_MIRROR (mirror));
sym = GIMP_SYMMETRY (mirror);
GimpSymmetry *sym = GIMP_SYMMETRY (mirror);
if (sym->origin)
{
......@@ -405,17 +398,14 @@ gimp_mirror_add_guide (GimpMirror *mirror,
static GimpRGB normal_bg = { 0.0, 1.0, 0.0, 1.0 };
static GimpRGB active_fg = { 0.0, 1.0, 0.0, 1.0 };
static GimpRGB active_bg = { 1.0, 0.0, 0.0, 1.0 };
GimpSymmetry *sym;
GimpSymmetry *sym = GIMP_SYMMETRY (mirror);
GimpImage *image;
Gimp *gimp;
GimpGuide *guide;
gint position;
g_return_if_fail (GIMP_IS_MIRROR (mirror));
sym = GIMP_SYMMETRY (mirror);
image = sym->image;
gimp = GIMP (image->gimp);
gimp = image->gimp;
guide = gimp_guide_custom_new (orientation,
gimp->next_guide_ID++,
......@@ -429,8 +419,8 @@ gimp_mirror_add_guide (GimpMirror *mirror,
/* Mirror guide position at first activation is at canvas middle. */
if (mirror->horizontal_position < 1.0)
mirror->horizontal_position = (gdouble) gimp_image_get_height (image) / 2.0;
position = (gint) mirror->horizontal_position;
mirror->horizontal_position = gimp_image_get_height (image) / 2.0;
position = mirror->horizontal_position;
}
else
{
......@@ -438,17 +428,17 @@ gimp_mirror_add_guide (GimpMirror *mirror,
/* Mirror guide position at first activation is at canvas middle. */
if (mirror->vertical_position < 1.0)
mirror->vertical_position = (gdouble) gimp_image_get_width (image) / 2.0;