mirror of https://github.com/GNOME/gimp.git
app/core/Makefile.am app/core/core-types.h app/core/gimpguideundo.[ch] new
2007-01-30 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/core-types.h * app/core/gimpguideundo.[ch] * app/core/gimpsamplepointundo.[ch]: new classes implementing guide and sample point undos. * app/core/gimpimage-undo-push.c: use them and remove all guide and sample point code. svn path=/trunk/; revision=21815
This commit is contained in:
parent
a3197b0c7c
commit
f0d1d8643d
17
ChangeLog
17
ChangeLog
|
@ -1,8 +1,19 @@
|
|||
2007-01-30 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/core-types.h
|
||||
* app/core/gimpguideundo.[ch]
|
||||
* app/core/gimpsamplepointundo.[ch]: new classes implementing
|
||||
guide and sample point undos.
|
||||
|
||||
* app/core/gimpimage-undo-push.c: use them and remove all guide
|
||||
and sample point code.
|
||||
|
||||
2007-01-30 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/gimpsamplepoint.[ch]: new files implementing new(),
|
||||
ref() and unref() and the new GIMP_TYPE_SAMPLE_TYPE boxed type.
|
||||
ref() and unref() and the new GIMP_TYPE_SAMPLE_POINT boxed type.
|
||||
|
||||
* app/core/gimpimage-sample-points.[ch]: removed ref() and unref()
|
||||
functions here.
|
||||
|
@ -29,8 +40,8 @@
|
|||
* app/core/core-enums.[ch]
|
||||
* app/core/gimpimage-undo-push.[ch]: drop the "image" from
|
||||
GIMP_UNDO_IMAGE_GUIDE, GIMP_UNDO_IMAGE_SAMPLE_POINT,
|
||||
gimp_imge_undo_push_image_guide() and
|
||||
gimp_imge_undo_push_image_sample_point()
|
||||
gimp_image_undo_push_image_guide() and
|
||||
gimp_image_undo_push_image_sample_point()
|
||||
|
||||
* app/core/gimpimage-undo.c
|
||||
* app/core/gimpimage-guides.c
|
||||
|
|
|
@ -134,10 +134,12 @@ libappcore_a_sources = \
|
|||
gimpgradient-load.h \
|
||||
gimpgradient-save.c \
|
||||
gimpgradient-save.h \
|
||||
gimpgrid.c \
|
||||
gimpgrid.h \
|
||||
gimpguide.c \
|
||||
gimpguide.h \
|
||||
gimpgrid.c \
|
||||
gimpgrid.h \
|
||||
gimpguide.c \
|
||||
gimpguide.h \
|
||||
gimpguideundo.c \
|
||||
gimpguideundo.h \
|
||||
gimpimage.c \
|
||||
gimpimage.h \
|
||||
gimpimage-arrange.c \
|
||||
|
@ -253,6 +255,8 @@ libappcore_a_sources = \
|
|||
gimpprojection-construct.h \
|
||||
gimpsamplepoint.c \
|
||||
gimpsamplepoint.h \
|
||||
gimpsamplepointundo.c \
|
||||
gimpsamplepointundo.h \
|
||||
gimpscanconvert.c \
|
||||
gimpscanconvert.h \
|
||||
gimpselection.c \
|
||||
|
|
|
@ -117,6 +117,8 @@ typedef struct _GimpChannelUndo GimpChannelUndo;
|
|||
typedef struct _GimpChannelPropUndo GimpChannelPropUndo;
|
||||
typedef struct _GimpDrawableUndo GimpDrawableUndo;
|
||||
typedef struct _GimpLayerPropUndo GimpLayerPropUndo;
|
||||
typedef struct _GimpGuideUndo GimpGuideUndo;
|
||||
typedef struct _GimpSamplePointUndo GimpSamplePointUndo;
|
||||
typedef struct _GimpUndoStack GimpUndoStack;
|
||||
typedef struct _GimpUndoAccumulator GimpUndoAccumulator;
|
||||
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpguide.h"
|
||||
#include "gimpguideundo.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GUIDE
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_guide_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_guide_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_guide_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_guide_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_guide_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpGuideUndo, gimp_guide_undo, GIMP_TYPE_UNDO)
|
||||
|
||||
#define parent_class gimp_guide_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_guide_undo_class_init (GimpGuideUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_guide_undo_constructor;
|
||||
object_class->set_property = gimp_guide_undo_set_property;
|
||||
object_class->get_property = gimp_guide_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_guide_undo_pop;
|
||||
undo_class->free = gimp_guide_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_GUIDE,
|
||||
g_param_spec_object ("guide", NULL, NULL,
|
||||
GIMP_TYPE_GUIDE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_guide_undo_init (GimpGuideUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_guide_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpGuideUndo *guide_undo;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
guide_undo = GIMP_GUIDE_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_GUIDE (guide_undo->guide));
|
||||
|
||||
guide_undo->orientation = gimp_guide_get_orientation (guide_undo->guide);
|
||||
guide_undo->position = gimp_guide_get_position (guide_undo->guide);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_guide_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpGuideUndo *guide_undo = GIMP_GUIDE_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GUIDE:
|
||||
guide_undo->guide = (GimpGuide *) g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_guide_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpGuideUndo *guide_undo = GIMP_GUIDE_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GUIDE:
|
||||
g_value_set_object (value, guide_undo->guide);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_guide_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpGuideUndo *guide_undo = GIMP_GUIDE_UNDO (undo);
|
||||
GimpOrientationType orientation;
|
||||
gint position;
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
orientation = gimp_guide_get_orientation (guide_undo->guide);
|
||||
position = gimp_guide_get_position (guide_undo->guide);
|
||||
|
||||
/* add and move guides manually (nor using the gimp_image_guide
|
||||
* API), because we might be in the middle of an image resizing
|
||||
* undo group and the guide's position might be temporarily out of
|
||||
* image.
|
||||
*/
|
||||
|
||||
if (position == -1)
|
||||
{
|
||||
undo->image->guides = g_list_prepend (undo->image->guides,
|
||||
guide_undo->guide);
|
||||
gimp_guide_set_position (guide_undo->guide, guide_undo->position);
|
||||
g_object_ref (guide_undo->guide);
|
||||
gimp_image_update_guide (undo->image, guide_undo->guide);
|
||||
}
|
||||
else if (guide_undo->position == -1)
|
||||
{
|
||||
gimp_image_remove_guide (undo->image, guide_undo->guide, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_update_guide (undo->image, guide_undo->guide);
|
||||
gimp_guide_set_position (guide_undo->guide, guide_undo->position);
|
||||
gimp_image_update_guide (undo->image, guide_undo->guide);
|
||||
}
|
||||
|
||||
gimp_guide_set_orientation (guide_undo->guide, guide_undo->orientation);
|
||||
|
||||
guide_undo->position = position;
|
||||
guide_undo->orientation = orientation;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_guide_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpGuideUndo *guide_undo = GIMP_GUIDE_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
|
||||
if (guide_undo->guide)
|
||||
{
|
||||
g_object_unref (guide_undo->guide);
|
||||
guide_undo->guide = NULL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_GUIDE_UNDO_H__
|
||||
#define __GIMP_GUIDE_UNDO_H__
|
||||
|
||||
|
||||
#include "gimpundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_GUIDE_UNDO (gimp_guide_undo_get_type ())
|
||||
#define GIMP_GUIDE_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_GUIDE_UNDO, GimpGuideUndo))
|
||||
#define GIMP_GUIDE_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_GUIDE_UNDO, GimpGuideUndoClass))
|
||||
#define GIMP_IS_GUIDE_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_GUIDE_UNDO))
|
||||
#define GIMP_IS_GUIDE_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_GUIDE_UNDO))
|
||||
#define GIMP_GUIDE_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_GUIDE_UNDO, GimpGuideUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpGuideUndoClass GimpGuideUndoClass;
|
||||
|
||||
struct _GimpGuideUndo
|
||||
{
|
||||
GimpUndo parent_instance;
|
||||
|
||||
GimpGuide *guide;
|
||||
GimpOrientationType orientation;
|
||||
gint position;
|
||||
};
|
||||
|
||||
struct _GimpGuideUndoClass
|
||||
{
|
||||
GimpUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_guide_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_GUIDE_UNDO_H__ */
|
|
@ -34,9 +34,8 @@
|
|||
#include "gimpdrawableundo.h"
|
||||
#include "gimpgrid.h"
|
||||
#include "gimpguide.h"
|
||||
#include "gimpguideundo.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpimageundo.h"
|
||||
|
@ -48,6 +47,7 @@
|
|||
#include "gimplist.h"
|
||||
#include "gimpparasitelist.h"
|
||||
#include "gimpsamplepoint.h"
|
||||
#include "gimpsamplepointundo.h"
|
||||
#include "gimpselection.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
|
@ -58,9 +58,9 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/*****************/
|
||||
/* Image Undos */
|
||||
/*****************/
|
||||
/**************************/
|
||||
/* Image Property Undos */
|
||||
/**************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_image_type (GimpImage *image,
|
||||
|
@ -136,217 +136,42 @@ gimp_image_undo_push_image_colormap (GimpImage *image,
|
|||
}
|
||||
|
||||
|
||||
/****************/
|
||||
/* Guide Undo */
|
||||
/****************/
|
||||
|
||||
typedef struct _GuideUndo GuideUndo;
|
||||
|
||||
struct _GuideUndo
|
||||
{
|
||||
GimpGuide *guide;
|
||||
GimpOrientationType orientation;
|
||||
gint position;
|
||||
};
|
||||
|
||||
static gboolean undo_pop_guide (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_guide (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
/********************************/
|
||||
/* Guide & Sample Point Undos */
|
||||
/********************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_guide (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
GimpGuide *guide)
|
||||
{
|
||||
GimpUndo *new;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_GUIDE (guide), NULL);
|
||||
|
||||
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
|
||||
sizeof (GuideUndo),
|
||||
sizeof (GuideUndo),
|
||||
GIMP_UNDO_GUIDE, undo_desc,
|
||||
GIMP_DIRTY_IMAGE_META,
|
||||
undo_pop_guide,
|
||||
undo_free_guide,
|
||||
NULL)))
|
||||
{
|
||||
GuideUndo *gu = new->data;
|
||||
|
||||
gu->guide = g_object_ref (guide);
|
||||
gu->orientation = gimp_guide_get_orientation (guide);
|
||||
gu->position = gimp_guide_get_position (guide);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return gimp_image_undo_push (image, GIMP_TYPE_GUIDE_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_GUIDE, undo_desc,
|
||||
GIMP_DIRTY_IMAGE_META,
|
||||
NULL, NULL,
|
||||
"guide", guide,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_guide (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GuideUndo *gu = undo->data;
|
||||
GimpOrientationType old_orientation;
|
||||
gint old_position;
|
||||
|
||||
old_orientation = gimp_guide_get_orientation (gu->guide);
|
||||
old_position = gimp_guide_get_position (gu->guide);
|
||||
|
||||
/* add and move guides manually (nor using the gimp_image_guide
|
||||
* API), because we might be in the middle of an image resizing
|
||||
* undo group and the guide's position might be temporarily out of
|
||||
* image.
|
||||
*/
|
||||
|
||||
if (old_position == -1)
|
||||
{
|
||||
undo->image->guides = g_list_prepend (undo->image->guides, gu->guide);
|
||||
gimp_guide_set_position (gu->guide, gu->position);
|
||||
g_object_ref (gu->guide);
|
||||
gimp_image_update_guide (undo->image, gu->guide);
|
||||
}
|
||||
else if (gu->position == -1)
|
||||
{
|
||||
gimp_image_remove_guide (undo->image, gu->guide, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_update_guide (undo->image, gu->guide);
|
||||
gimp_guide_set_position (gu->guide, gu->position);
|
||||
gimp_image_update_guide (undo->image, gu->guide);
|
||||
}
|
||||
|
||||
gimp_guide_set_orientation (gu->guide, gu->orientation);
|
||||
|
||||
gu->position = old_position;
|
||||
gu->orientation = old_orientation;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_guide (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GuideUndo *gu = undo->data;
|
||||
|
||||
g_object_unref (gu->guide);
|
||||
g_free (gu);
|
||||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/* Sampe Point Undo */
|
||||
/**********************/
|
||||
|
||||
typedef struct _SamplePointUndo SamplePointUndo;
|
||||
|
||||
struct _SamplePointUndo
|
||||
{
|
||||
GimpSamplePoint *sample_point;
|
||||
gint x;
|
||||
gint y;
|
||||
};
|
||||
|
||||
static gboolean undo_pop_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_sample_point (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
GimpSamplePoint *sample_point)
|
||||
{
|
||||
GimpUndo *new;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (sample_point != NULL, NULL);
|
||||
|
||||
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
|
||||
sizeof (SamplePointUndo),
|
||||
sizeof (SamplePointUndo),
|
||||
GIMP_UNDO_SAMPLE_POINT, undo_desc,
|
||||
GIMP_DIRTY_IMAGE_META,
|
||||
undo_pop_sample_point,
|
||||
undo_free_sample_point,
|
||||
NULL)))
|
||||
{
|
||||
SamplePointUndo *spu = new->data;
|
||||
|
||||
spu->sample_point = gimp_sample_point_ref (sample_point);
|
||||
spu->x = sample_point->x;
|
||||
spu->y = sample_point->y;
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
SamplePointUndo *spu = undo->data;
|
||||
gint old_x;
|
||||
gint old_y;
|
||||
|
||||
old_x = spu->sample_point->x;
|
||||
old_y = spu->sample_point->y;
|
||||
|
||||
/* add and move sample points manually (nor using the
|
||||
* gimp_image_sample_point API), because we might be in the middle
|
||||
* of an image resizing undo group and the sample point's position
|
||||
* might be temporarily out of image.
|
||||
*/
|
||||
|
||||
if (spu->sample_point->x == -1)
|
||||
{
|
||||
undo->image->sample_points = g_list_append (undo->image->sample_points,
|
||||
spu->sample_point);
|
||||
|
||||
spu->sample_point->x = spu->x;
|
||||
spu->sample_point->y = spu->y;
|
||||
gimp_sample_point_ref (spu->sample_point);
|
||||
|
||||
gimp_image_sample_point_added (undo->image, spu->sample_point);
|
||||
gimp_image_update_sample_point (undo->image, spu->sample_point);
|
||||
}
|
||||
else if (spu->x == -1)
|
||||
{
|
||||
gimp_image_remove_sample_point (undo->image, spu->sample_point, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_update_sample_point (undo->image, spu->sample_point);
|
||||
spu->sample_point->x = spu->x;
|
||||
spu->sample_point->y = spu->y;
|
||||
gimp_image_update_sample_point (undo->image, spu->sample_point);
|
||||
}
|
||||
|
||||
spu->x = old_x;
|
||||
spu->y = old_y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
SamplePointUndo *gu = undo->data;
|
||||
|
||||
gimp_sample_point_unref (gu->sample_point);
|
||||
g_free (gu);
|
||||
return gimp_image_undo_push (image, GIMP_TYPE_SAMPLE_POINT_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_SAMPLE_POINT, undo_desc,
|
||||
GIMP_DIRTY_IMAGE_META,
|
||||
NULL, NULL,
|
||||
"sample-point", sample_point,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -526,9 +351,9 @@ gimp_image_undo_push_mask (GimpImage *image,
|
|||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/* Item Rename Undo */
|
||||
/**********************/
|
||||
/*************************/
|
||||
/* Item Property Undos */
|
||||
/*************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_item_rename (GimpImage *image,
|
||||
|
@ -548,11 +373,6 @@ gimp_image_undo_push_item_rename (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/****************************/
|
||||
/* Item displacement Undo */
|
||||
/****************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_item_displace (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
@ -573,11 +393,6 @@ gimp_image_undo_push_item_displace (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Item Visibility Undo */
|
||||
/******************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_item_visibility (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
@ -596,11 +411,6 @@ gimp_image_undo_push_item_visibility (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/* Item linked Undo */
|
||||
/**********************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_item_linked (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
@ -816,9 +626,9 @@ undo_free_layer (GimpUndo *undo,
|
|||
}
|
||||
|
||||
|
||||
/***************************/
|
||||
/* Layer re-position Undo */
|
||||
/***************************/
|
||||
/**************************/
|
||||
/* Layer Property Undos */
|
||||
/**************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_layer_reposition (GimpImage *image,
|
||||
|
@ -838,11 +648,6 @@ gimp_image_undo_push_layer_reposition (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/*********************/
|
||||
/* Layer Mode Undo */
|
||||
/*********************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_layer_mode (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
@ -861,11 +666,6 @@ gimp_image_undo_push_layer_mode (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/************************/
|
||||
/* Layer Opacity Undo */
|
||||
/************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_layer_opacity (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
@ -884,11 +684,6 @@ gimp_image_undo_push_layer_opacity (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/***************************/
|
||||
/* Layer Lock Alpha Undo */
|
||||
/***************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_layer_lock_alpha (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
@ -1419,9 +1214,9 @@ undo_free_channel (GimpUndo *undo,
|
|||
}
|
||||
|
||||
|
||||
/******************************/
|
||||
/* Channel re-position Undo */
|
||||
/******************************/
|
||||
/****************************/
|
||||
/* Channel Property Undos */
|
||||
/****************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_channel_reposition (GimpImage *image,
|
||||
|
@ -1441,11 +1236,6 @@ gimp_image_undo_push_channel_reposition (GimpImage *image,
|
|||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/************************/
|
||||
/* Channel color Undo */
|
||||
/************************/
|
||||
|
||||
GimpUndo *
|
||||
gimp_image_undo_push_channel_color (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
|
|
|
@ -0,0 +1,214 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpsamplepoint.h"
|
||||
#include "gimpsamplepointundo.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SAMPLE_POINT
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_sample_point_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_sample_point_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_sample_point_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_sample_point_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_sample_point_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpSamplePointUndo, gimp_sample_point_undo, GIMP_TYPE_UNDO)
|
||||
|
||||
#define parent_class gimp_sample_point_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_sample_point_undo_class_init (GimpSamplePointUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_sample_point_undo_constructor;
|
||||
object_class->set_property = gimp_sample_point_undo_set_property;
|
||||
object_class->get_property = gimp_sample_point_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_sample_point_undo_pop;
|
||||
undo_class->free = gimp_sample_point_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_SAMPLE_POINT,
|
||||
g_param_spec_boxed ("sample-point", NULL, NULL,
|
||||
GIMP_TYPE_SAMPLE_POINT,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_sample_point_undo_init (GimpSamplePointUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_sample_point_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpSamplePointUndo *sample_point_undo;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
sample_point_undo = GIMP_SAMPLE_POINT_UNDO (object);
|
||||
|
||||
g_assert (sample_point_undo->sample_point != NULL);
|
||||
|
||||
sample_point_undo->x = sample_point_undo->sample_point->x;
|
||||
sample_point_undo->y = sample_point_undo->sample_point->y;
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_sample_point_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpSamplePointUndo *sample_point_undo = GIMP_SAMPLE_POINT_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_SAMPLE_POINT:
|
||||
sample_point_undo->sample_point = g_value_dup_boxed (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_sample_point_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpSamplePointUndo *sample_point_undo = GIMP_SAMPLE_POINT_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_SAMPLE_POINT:
|
||||
g_value_set_boxed (value, sample_point_undo->sample_point);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_sample_point_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpSamplePointUndo *sample_point_undo = GIMP_SAMPLE_POINT_UNDO (undo);
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
x = sample_point_undo->sample_point->x;
|
||||
y = sample_point_undo->sample_point->y;
|
||||
|
||||
/* add and move sample points manually (nor using the
|
||||
* gimp_image_sample_point API), because we might be in the middle
|
||||
* of an image resizing undo group and the sample point's position
|
||||
* might be temporarily out of image.
|
||||
*/
|
||||
|
||||
if (x == -1)
|
||||
{
|
||||
undo->image->sample_points =
|
||||
g_list_append (undo->image->sample_points,
|
||||
sample_point_undo->sample_point);
|
||||
|
||||
sample_point_undo->sample_point->x = sample_point_undo->x;
|
||||
sample_point_undo->sample_point->y = sample_point_undo->y;
|
||||
gimp_sample_point_ref (sample_point_undo->sample_point);
|
||||
|
||||
gimp_image_sample_point_added (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
gimp_image_update_sample_point (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
}
|
||||
else if (sample_point_undo->x == -1)
|
||||
{
|
||||
gimp_image_remove_sample_point (undo->image,
|
||||
sample_point_undo->sample_point, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_update_sample_point (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
sample_point_undo->sample_point->x = sample_point_undo->x;
|
||||
sample_point_undo->sample_point->y = sample_point_undo->y;
|
||||
gimp_image_update_sample_point (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
}
|
||||
|
||||
sample_point_undo->x = x;
|
||||
sample_point_undo->y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_sample_point_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpSamplePointUndo *sample_point_undo = GIMP_SAMPLE_POINT_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
|
||||
if (sample_point_undo->sample_point)
|
||||
{
|
||||
gimp_sample_point_unref (sample_point_undo->sample_point);
|
||||
sample_point_undo->sample_point = NULL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_SAMPLE_POINT_UNDO_H__
|
||||
#define __GIMP_SAMPLE_POINT_UNDO_H__
|
||||
|
||||
|
||||
#include "gimpundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_SAMPLE_POINT_UNDO (gimp_sample_point_undo_get_type ())
|
||||
#define GIMP_SAMPLE_POINT_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SAMPLE_POINT_UNDO, GimpSamplePointUndo))
|
||||
#define GIMP_SAMPLE_POINT_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SAMPLE_POINT_UNDO, GimpSamplePointUndoClass))
|
||||
#define GIMP_IS_SAMPLE_POINT_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SAMPLE_POINT_UNDO))
|
||||
#define GIMP_IS_SAMPLE_POINT_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SAMPLE_POINT_UNDO))
|
||||
#define GIMP_SAMPLE_POINT_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SAMPLE_POINT_UNDO, GimpSamplePointUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpSamplePointUndoClass GimpSamplePointUndoClass;
|
||||
|
||||
struct _GimpSamplePointUndo
|
||||
{
|
||||
GimpUndo parent_instance;
|
||||
|
||||
GimpSamplePoint *sample_point;
|
||||
gint x;
|
||||
gint y;
|
||||
};
|
||||
|
||||
struct _GimpSamplePointUndoClass
|
||||
{
|
||||
GimpUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_sample_point_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_SAMPLE_POINT_UNDO_H__ */
|
Loading…
Reference in New Issue