app/paint/gimppaintcore-undo.[ch] removed...

2007-02-03  Michael Natterer  <mitch@gimp.org>

	* app/paint/gimppaintcore-undo.[ch]
	* app/paint/gimpink-undo.[ch]: removed...

	* app/paint/Makefile.am
	* app/paint/paint-types.h
	* app/paint/gimppaintcoreundo.[ch]
	* app/paint/gimpinkundo.[ch]: ...and added as proper undo classes.

	* app/paint/gimppaintcore.[ch]
	* app/paint/gimpink.c: push undos using the new classes.


svn path=/trunk/; revision=21842
This commit is contained in:
Michael Natterer 2007-02-03 18:48:00 +00:00 committed by Michael Natterer
parent f6902727b8
commit 792ba89818
14 changed files with 555 additions and 395 deletions

View File

@ -1,3 +1,16 @@
2007-02-03 Michael Natterer <mitch@gimp.org>
* app/paint/gimppaintcore-undo.[ch]
* app/paint/gimpink-undo.[ch]: removed...
* app/paint/Makefile.am
* app/paint/paint-types.h
* app/paint/gimppaintcoreundo.[ch]
* app/paint/gimpinkundo.[ch]: ...and added as proper undo classes.
* app/paint/gimppaintcore.[ch]
* app/paint/gimpink.c: push undos using the new classes.
2007-02-03 Mukund Sivaraman <muks@mukund.org>
* plug-ins/common/psd.c

View File

@ -48,16 +48,16 @@ libapppaint_a_sources = \
gimpink.h \
gimpink-blob.c \
gimpink-blob.h \
gimpink-undo.c \
gimpink-undo.h \
gimpinkoptions.c \
gimpinkoptions.h \
gimpinkundo.c \
gimpinkundo.h \
gimppaintcore.c \
gimppaintcore.h \
gimppaintcore-stroke.c \
gimppaintcore-stroke.h \
gimppaintcore-undo.c \
gimppaintcore-undo.h \
gimppaintcoreundo.c \
gimppaintcoreundo.h \
gimppaintoptions.c \
gimppaintoptions.h \
gimppencil.c \

View File

@ -1,187 +0,0 @@
/* 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 <string.h>
#include <glib-object.h>
#include "paint-types.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
#include "core/gimpundo.h"
#include "gimpink.h"
#include "gimpink-blob.h"
#include "gimpink-undo.h"
/**************/
/* Ink Undo */
/**************/
typedef struct _InkUndo InkUndo;
struct _InkUndo
{
GimpInk *ink;
Blob *last_blob;
gdouble dt_buffer[DIST_SMOOTHER_BUFFER];
gint dt_index;
guint32 ts_buffer[TIME_SMOOTHER_BUFFER];
gint ts_index;
gdouble last_time;
gboolean init_velocity;
};
static gboolean undo_pop_ink (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_ink (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc)
{
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_INK (core), FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
if (! GIMP_PAINT_CORE_CLASS (g_type_class_peek_parent (GIMP_INK_GET_CLASS (core)))->push_undo (core, image, undo_desc))
return FALSE;
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
sizeof (InkUndo),
sizeof (InkUndo),
GIMP_UNDO_INK, undo_desc,
FALSE,
undo_pop_ink,
undo_free_ink,
NULL)))
{
GimpInk *ink = GIMP_INK (core);
InkUndo *ink_undo = new->data;
ink_undo->ink = ink;
if (ink->start_blob)
ink_undo->last_blob = blob_duplicate (ink->start_blob);
memcpy (ink_undo->dt_buffer, ink->dt_buffer,
sizeof (ink_undo->dt_buffer));
ink_undo->dt_index = ink->dt_index;
memcpy (ink_undo->ts_buffer, ink->ts_buffer,
sizeof (ink_undo->ts_buffer));
ink_undo->ts_index = ink->ts_index;
ink_undo->last_time = ink->last_time;
ink_undo->init_velocity = ink->init_velocity;
g_object_add_weak_pointer (G_OBJECT (ink), (gpointer) &ink_undo->ink);
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_ink (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
InkUndo *ink_undo = undo->data;
/* only pop if the core still exists */
if (ink_undo->ink)
{
Blob *tmp_blob;
gint tmp_int;
gdouble tmp_double;
guint32 tmp_int_buf[DIST_SMOOTHER_BUFFER];
gdouble tmp_double_buf[DIST_SMOOTHER_BUFFER];
tmp_blob = ink_undo->ink->last_blob;
ink_undo->ink->last_blob = ink_undo->last_blob;
ink_undo->last_blob = tmp_blob;
memcpy (tmp_double_buf, ink_undo->ink->dt_buffer,
sizeof (tmp_double_buf));
memcpy (ink_undo->ink->dt_buffer, ink_undo->dt_buffer,
sizeof (tmp_double_buf));
memcpy (ink_undo->dt_buffer, tmp_double_buf,
sizeof (tmp_double_buf));
tmp_int = ink_undo->ink->dt_index;
ink_undo->ink->dt_index = ink_undo->dt_index;
ink_undo->dt_index = tmp_int;
memcpy (tmp_int_buf, ink_undo->ink->ts_buffer,
sizeof (tmp_int_buf));
memcpy (ink_undo->ink->ts_buffer, ink_undo->ts_buffer,
sizeof (tmp_int_buf));
memcpy (ink_undo->ts_buffer, tmp_int_buf,
sizeof (tmp_int_buf));
tmp_int = ink_undo->ink->ts_index;
ink_undo->ink->ts_index = ink_undo->ts_index;
ink_undo->ts_index = tmp_int;
tmp_double = ink_undo->ink->last_time;
ink_undo->ink->last_time = ink_undo->last_time;
ink_undo->last_time = tmp_double;
tmp_int = ink_undo->ink->init_velocity;
ink_undo->ink->init_velocity = ink_undo->init_velocity;
ink_undo->init_velocity = tmp_int;
}
return TRUE;
}
static void
undo_free_ink (GimpUndo *undo,
GimpUndoMode undo_mode)
{
InkUndo *ink_undo = undo->data;
if (ink_undo->ink)
g_object_remove_weak_pointer (G_OBJECT (ink_undo->ink),
(gpointer) &ink_undo->ink);
if (ink_undo->last_blob)
g_free (ink_undo->last_blob);
g_free (ink_undo);
}

View File

@ -1,28 +0,0 @@
/* 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_INK_UNDO_H__
#define __GIMP_INK_UNDO_H__
gboolean gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
#endif /* __GIMP_INK_UNDO_H__ */

View File

@ -33,11 +33,12 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "gimpinkoptions.h"
#include "gimpink.h"
#include "gimpink-blob.h"
#include "gimpink-undo.h"
#include "gimpinkundo.h"
#include "gimp-intl.h"
@ -57,6 +58,9 @@ static void gimp_ink_paint (GimpPaintCore *paint_core,
static TempBuf * gimp_ink_get_paint_area (GimpPaintCore *paint_core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
static GimpUndo* gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
static void gimp_ink_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,
@ -226,6 +230,20 @@ gimp_ink_get_paint_area (GimpPaintCore *paint_core,
return paint_core->canvas_buf;
}
static GimpUndo *
gimp_ink_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc)
{
return gimp_image_undo_push (image, GIMP_TYPE_INK_UNDO,
0, 0,
GIMP_UNDO_INK, undo_desc,
0,
NULL, NULL,
"paint-core", core,
NULL);
}
static void
gimp_ink_motion (GimpPaintCore *paint_core,
GimpDrawable *drawable,

169
app/paint/gimpinkundo.c Normal file
View File

@ -0,0 +1,169 @@
/* 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 <string.h>
#include <glib-object.h>
#include "paint-types.h"
#include "gimpink.h"
#include "gimpink-blob.h"
#include "gimpinkundo.h"
static GObject * gimp_ink_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_ink_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void gimp_ink_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode);
G_DEFINE_TYPE (GimpInkUndo, gimp_ink_undo, GIMP_TYPE_PAINT_CORE_UNDO)
#define parent_class gimp_ink_undo_parent_class
static void
gimp_ink_undo_class_init (GimpInkUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_ink_undo_constructor;
undo_class->pop = gimp_ink_undo_pop;
undo_class->free = gimp_ink_undo_free;
}
static void
gimp_ink_undo_init (GimpInkUndo *undo)
{
}
static GObject *
gimp_ink_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpInkUndo *ink_undo;
GimpInk *ink;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
ink_undo = GIMP_INK_UNDO (object);
g_assert (GIMP_IS_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core));
ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
if (ink->start_blob)
ink_undo->last_blob = blob_duplicate (ink->start_blob);
memcpy (ink_undo->dt_buffer, ink->dt_buffer,
sizeof (ink_undo->dt_buffer));
ink_undo->dt_index = ink->dt_index;
memcpy (ink_undo->ts_buffer, ink->ts_buffer,
sizeof (ink_undo->ts_buffer));
ink_undo->ts_index = ink->ts_index;
ink_undo->last_time = ink->last_time;
ink_undo->init_velocity = ink->init_velocity;
return object;
}
static void
gimp_ink_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GimpInkUndo *ink_undo = GIMP_INK_UNDO (undo);
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
if (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core)
{
GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
Blob *tmp_blob;
gint tmp_int;
gdouble tmp_double;
guint32 tmp_int_buf[DIST_SMOOTHER_BUFFER];
gdouble tmp_double_buf[DIST_SMOOTHER_BUFFER];
tmp_blob = ink->last_blob;
ink->last_blob = ink_undo->last_blob;
ink_undo->last_blob = tmp_blob;
memcpy (tmp_double_buf, ink->dt_buffer,
sizeof (tmp_double_buf));
memcpy (ink->dt_buffer, ink_undo->dt_buffer,
sizeof (tmp_double_buf));
memcpy (ink_undo->dt_buffer, tmp_double_buf,
sizeof (tmp_double_buf));
tmp_int = ink->dt_index;
ink->dt_index = ink_undo->dt_index;
ink_undo->dt_index = tmp_int;
memcpy (tmp_int_buf, ink->ts_buffer,
sizeof (tmp_int_buf));
memcpy (ink->ts_buffer, ink_undo->ts_buffer,
sizeof (tmp_int_buf));
memcpy (ink_undo->ts_buffer, tmp_int_buf,
sizeof (tmp_int_buf));
tmp_int = ink->ts_index;
ink->ts_index = ink_undo->ts_index;
ink_undo->ts_index = tmp_int;
tmp_double = ink->last_time;
ink->last_time = ink_undo->last_time;
ink_undo->last_time = tmp_double;
tmp_int = ink->init_velocity;
ink->init_velocity = ink_undo->init_velocity;
ink_undo->init_velocity = tmp_int;
}
}
static void
gimp_ink_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode)
{
GimpInkUndo *ink_undo = GIMP_INK_UNDO (undo);
if (ink_undo->last_blob)
{
g_free (ink_undo->last_blob);
ink_undo->last_blob = NULL;
}
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
}

62
app/paint/gimpinkundo.h Normal file
View File

@ -0,0 +1,62 @@
/* 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_INK_UNDO_H__
#define __GIMP_INK_UNDO_H__
#include "gimppaintcoreundo.h"
#define GIMP_TYPE_INK_UNDO (gimp_ink_undo_get_type ())
#define GIMP_INK_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_INK_UNDO, GimpInkUndo))
#define GIMP_INK_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_INK_UNDO, GimpInkUndoClass))
#define GIMP_IS_INK_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_INK_UNDO))
#define GIMP_IS_INK_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_INK_UNDO))
#define GIMP_INK_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_INK_UNDO, GimpInkUndoClass))
typedef struct _GimpInkUndoClass GimpInkUndoClass;
struct _GimpInkUndo
{
GimpPaintCoreUndo parent_instance;
Blob *last_blob;
gdouble dt_buffer[DIST_SMOOTHER_BUFFER];
gint dt_index;
guint32 ts_buffer[TIME_SMOOTHER_BUFFER];
gint ts_index;
gdouble last_time;
gboolean init_velocity;
};
struct _GimpInkUndoClass
{
GimpPaintCoreUndoClass parent_class;
};
GType gimp_ink_undo_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_INK_UNDO_H__ */

View File

@ -1,113 +0,0 @@
/* 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 "paint-types.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage.h"
#include "core/gimpundo.h"
#include "gimppaintcore.h"
#include "gimppaintcore-undo.h"
/****************/
/* Paint Undo */
/****************/
typedef struct _PaintUndo PaintUndo;
struct _PaintUndo
{
GimpPaintCore *core;
GimpCoords last_coords;
};
static gboolean undo_pop_paint (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void undo_free_paint (GimpUndo *undo,
GimpUndoMode undo_mode);
gboolean
gimp_paint_core_real_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc)
{
GimpUndo *new;
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
sizeof (PaintUndo),
sizeof (PaintUndo),
GIMP_UNDO_PAINT, undo_desc,
FALSE,
undo_pop_paint,
undo_free_paint,
NULL)))
{
PaintUndo *pu = new->data;
pu->core = core;
pu->last_coords = core->start_coords;
g_object_add_weak_pointer (G_OBJECT (core), (gpointer) &pu->core);
return TRUE;
}
return FALSE;
}
static gboolean
undo_pop_paint (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
PaintUndo *pu = undo->data;
/* only pop if the core still exists */
if (pu->core)
{
GimpCoords tmp_coords;
tmp_coords = pu->core->last_coords;
pu->core->last_coords = pu->last_coords;
pu->last_coords = tmp_coords;
}
return TRUE;
}
static void
undo_free_paint (GimpUndo *undo,
GimpUndoMode undo_mode)
{
PaintUndo *pu = undo->data;
if (pu->core)
g_object_remove_weak_pointer (G_OBJECT (pu->core), (gpointer) &pu->core);
g_free (pu);
}

View File

@ -1,28 +0,0 @@
/* 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_PAINT_CORE_UNDO_H__
#define __GIMP_PAINT_CORE_UNDO_H__
gboolean gimp_paint_core_real_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
#endif /* __GIMP_PAINT_CORE_UNDO_H__ */

View File

@ -38,7 +38,7 @@
#include "core/gimppickable.h"
#include "gimppaintcore.h"
#include "gimppaintcore-undo.h"
#include "gimppaintcoreundo.h"
#include "gimppaintoptions.h"
#include "gimpairbrush.h"
@ -92,6 +92,9 @@ static void gimp_paint_core_real_interpolate (GimpPaintCore *core,
static TempBuf * gimp_paint_core_real_get_paint_area (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *options);
static GimpUndo* gimp_paint_core_real_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
static void paint_mask_to_canvas_tiles (GimpPaintCore *core,
PixelRegion *paint_maskPR,
@ -271,6 +274,20 @@ gimp_paint_core_real_get_paint_area (GimpPaintCore *core,
return NULL;
}
static GimpUndo *
gimp_paint_core_real_push_undo (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc)
{
return gimp_image_undo_push (image, GIMP_TYPE_PAINT_CORE_UNDO,
0, 0,
GIMP_UNDO_PAINT, undo_desc,
0,
NULL, NULL,
"paint-core", core,
NULL);
}
void
gimp_paint_core_paint (GimpPaintCore *core,
GimpDrawable *drawable,

View File

@ -71,40 +71,40 @@ struct _GimpPaintCoreClass
GimpObjectClass parent_class;
/* virtual functions */
gboolean (* start) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpCoords *coords,
GError **error);
gboolean (* start) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpCoords *coords,
GError **error);
gboolean (* pre_paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
void (* paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
void (* post_paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
gboolean (* pre_paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
void (* paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
void (* post_paint) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
GimpPaintState paint_state,
guint32 time);
void (* interpolate) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
guint32 time);
void (* interpolate) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options,
guint32 time);
TempBuf * (* get_paint_area) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
TempBuf * (* get_paint_area) (GimpPaintCore *core,
GimpDrawable *drawable,
GimpPaintOptions *paint_options);
gboolean (* push_undo) (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
GimpUndo * (* push_undo) (GimpPaintCore *core,
GimpImage *image,
const gchar *undo_desc);
};

View File

@ -0,0 +1,181 @@
/* 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 "paint-types.h"
#include "gimppaintcore.h"
#include "gimppaintcoreundo.h"
enum
{
PROP_0,
PROP_PAINT_CORE
};
static GObject * gimp_paint_core_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_paint_core_undo_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_paint_core_undo_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_paint_core_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum);
static void gimp_paint_core_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode);
G_DEFINE_TYPE (GimpPaintCoreUndo, gimp_paint_core_undo, GIMP_TYPE_UNDO)
#define parent_class gimp_paint_core_undo_parent_class
static void
gimp_paint_core_undo_class_init (GimpPaintCoreUndoClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
object_class->constructor = gimp_paint_core_undo_constructor;
object_class->set_property = gimp_paint_core_undo_set_property;
object_class->get_property = gimp_paint_core_undo_get_property;
undo_class->pop = gimp_paint_core_undo_pop;
undo_class->free = gimp_paint_core_undo_free;
g_object_class_install_property (object_class, PROP_PAINT_CORE,
g_param_spec_object ("paint-core", NULL, NULL,
GIMP_TYPE_PAINT_CORE,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
gimp_paint_core_undo_init (GimpPaintCoreUndo *undo)
{
}
static GObject *
gimp_paint_core_undo_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
GimpPaintCoreUndo *paint_core_undo;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
g_assert (GIMP_IS_PAINT_CORE (paint_core_undo->paint_core));
paint_core_undo->last_coords = paint_core_undo->paint_core->start_coords;
g_object_add_weak_pointer (G_OBJECT (paint_core_undo->paint_core),
(gpointer) &paint_core_undo->paint_core);
return object;
}
static void
gimp_paint_core_undo_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
switch (property_id)
{
case PROP_PAINT_CORE:
paint_core_undo->paint_core = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_paint_core_undo_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
switch (property_id)
{
case PROP_PAINT_CORE:
g_value_set_object (value, paint_core_undo->paint_core);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_paint_core_undo_pop (GimpUndo *undo,
GimpUndoMode undo_mode,
GimpUndoAccumulator *accum)
{
GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (undo);
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
/* only pop if the core still exists */
if (paint_core_undo->paint_core)
{
GimpCoords tmp_coords;
tmp_coords = paint_core_undo->paint_core->last_coords;
paint_core_undo->paint_core->last_coords = paint_core_undo->last_coords;
paint_core_undo->last_coords = tmp_coords;
}
}
static void
gimp_paint_core_undo_free (GimpUndo *undo,
GimpUndoMode undo_mode)
{
GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (undo);
if (paint_core_undo->paint_core)
{
g_object_remove_weak_pointer (G_OBJECT (paint_core_undo->paint_core),
(gpointer) &paint_core_undo->paint_core);
paint_core_undo->paint_core = NULL;
}
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
}

View File

@ -0,0 +1,53 @@
/* 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_PAINT_CORE_UNDO_H__
#define __GIMP_PAINT_CORE_UNDO_H__
#include "core/gimpundo.h"
#define GIMP_TYPE_PAINT_CORE_UNDO (gimp_paint_core_undo_get_type ())
#define GIMP_PAINT_CORE_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_PAINT_CORE_UNDO, GimpPaintCoreUndo))
#define GIMP_PAINT_CORE_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PAINT_CORE_UNDO, GimpPaintCoreUndoClass))
#define GIMP_IS_PAINT_CORE_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_PAINT_CORE_UNDO))
#define GIMP_IS_PAINT_CORE_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PAINT_CORE_UNDO))
#define GIMP_PAINT_CORE_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_PAINT_CORE_UNDO, GimpPaintCoreUndoClass))
typedef struct _GimpPaintCoreUndoClass GimpPaintCoreUndoClass;
struct _GimpPaintCoreUndo
{
GimpUndo parent_instance;
GimpPaintCore *paint_core;
GimpCoords last_coords;
};
struct _GimpPaintCoreUndoClass
{
GimpUndoClass parent_class;
};
GType gimp_paint_core_undo_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_PAINT_CORE_UNDO_H__ */

View File

@ -26,9 +26,12 @@
/* objects */
typedef struct _GimpPaintCore GimpPaintCore;
typedef struct _GimpBrushCore GimpBrushCore;
typedef struct _GimpPaintOptions GimpPaintOptions;
typedef struct _GimpPaintCore GimpPaintCore;
typedef struct _GimpPaintCoreUndo GimpPaintCoreUndo;
typedef struct _GimpBrushCore GimpBrushCore;
typedef struct _GimpInkUndo GimpInkUndo;
typedef struct _GimpPaintOptions GimpPaintOptions;
/* functions */