mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
app/tools/gimpforegroundselecttool-undo.[ch] removed...
2007-02-03 Michael Natterer <mitch@gimp.org> * app/tools/gimpforegroundselecttool-undo.[ch] * app/tools/gimptransformtool-undo.[ch]: removed... * app/tools/Makefile.am * app/tools/tools-types.h * app/tools/gimpforegroundselecttoolundo.[ch] * app/tools/gimptransformtoolundo.[ch]: ...and added a proper undo classes. * app/tools/gimptransformtool.c: push undos using the new class. svn path=/trunk/; revision=21843
This commit is contained in:
parent
792ba89818
commit
426020da7b
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2007-02-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimpforegroundselecttool-undo.[ch]
|
||||
* app/tools/gimptransformtool-undo.[ch]: removed...
|
||||
|
||||
* app/tools/Makefile.am
|
||||
* app/tools/tools-types.h
|
||||
* app/tools/gimpforegroundselecttoolundo.[ch]
|
||||
* app/tools/gimptransformtoolundo.[ch]: ...and added a proper undo
|
||||
classes.
|
||||
|
||||
* app/tools/gimptransformtool.c: push undos using the new class.
|
||||
|
||||
2007-02-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/paint/gimppaintcore-undo.[ch]
|
||||
|
|
|
@ -74,8 +74,8 @@ libapptools_a_sources = \
|
|||
gimpforegroundselectoptions.h \
|
||||
gimpforegroundselecttool.c \
|
||||
gimpforegroundselecttool.h \
|
||||
gimpforegroundselecttool-undo.c \
|
||||
gimpforegroundselecttool-undo.h \
|
||||
gimpforegroundselecttoolundo.c \
|
||||
gimpforegroundselecttoolundo.h \
|
||||
gimpfuzzyselecttool.c \
|
||||
gimpfuzzyselecttool.h \
|
||||
gimphealtool.c \
|
||||
|
@ -162,8 +162,8 @@ libapptools_a_sources = \
|
|||
gimptransformoptions.h \
|
||||
gimptransformtool.c \
|
||||
gimptransformtool.h \
|
||||
gimptransformtool-undo.c \
|
||||
gimptransformtool-undo.h \
|
||||
gimptransformtoolundo.c \
|
||||
gimptransformtoolundo.h \
|
||||
gimpvectoroptions.c \
|
||||
gimpvectoroptions.h \
|
||||
gimpvectortool.c \
|
||||
|
|
|
@ -1,107 +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 <gtk/gtk.h>
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "core/gimpimage-undo.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpundo.h"
|
||||
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimpforegroundselecttool.h"
|
||||
#include "gimpforegroundselecttool-undo.h"
|
||||
#include "tool_manager.h"
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint tool_ID;
|
||||
} FgSelectUndo;
|
||||
|
||||
|
||||
static gboolean undo_pop_foreground_select (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_foreground_select (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_foreground_select_tool_push_undo (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
gint tool_ID)
|
||||
{
|
||||
GimpUndo *new;
|
||||
|
||||
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
|
||||
sizeof (FgSelectUndo),
|
||||
sizeof (FgSelectUndo),
|
||||
GIMP_UNDO_FOREGROUND_SELECT, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_foreground_select,
|
||||
undo_free_foreground_select,
|
||||
NULL)))
|
||||
{
|
||||
FgSelectUndo *undo = new->data;
|
||||
|
||||
undo->tool_ID = tool_ID;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_foreground_select (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpTool *active_tool;
|
||||
|
||||
active_tool = tool_manager_get_active (undo->image->gimp);
|
||||
|
||||
if (GIMP_IS_FOREGROUND_SELECT_TOOL (active_tool))
|
||||
{
|
||||
FgSelectUndo *fg_undo = undo->data;
|
||||
|
||||
/* only pop if the active tool is the tool that pushed this undo */
|
||||
if (fg_undo->tool_ID == active_tool->ID)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_foreground_select (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
FgSelectUndo *fg_undo = undo->data;
|
||||
|
||||
|
||||
g_free (fg_undo);
|
||||
}
|
|
@ -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_FOREGROUND_SELECT_TOOL_UNDO_H__
|
||||
#define __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__
|
||||
|
||||
|
||||
gboolean gimp_foreground_select_tool_push_undo (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
gint tool_ID);
|
||||
|
||||
|
||||
#endif /* __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__ */
|
179
app/tools/gimpforegroundselecttoolundo.c
Normal file
179
app/tools/gimpforegroundselecttoolundo.c
Normal file
|
@ -0,0 +1,179 @@
|
|||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "gimpforegroundselecttool.h"
|
||||
#include "gimpforegroundselecttoolundo.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_FOREGROUND_SELECT_TOOL
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_foreground_select_tool_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_foreground_select_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_foreground_select_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_foreground_select_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_foreground_select_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpForegroundSelectToolUndo, gimp_foreground_select_tool_undo,
|
||||
GIMP_TYPE_UNDO)
|
||||
|
||||
#define parent_class gimp_foreground_select_tool_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_foreground_select_tool_undo_class_init (GimpForegroundSelectToolUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_foreground_select_tool_undo_constructor;
|
||||
object_class->set_property = gimp_foreground_select_tool_undo_set_property;
|
||||
object_class->get_property = gimp_foreground_select_tool_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_foreground_select_tool_undo_pop;
|
||||
undo_class->free = gimp_foreground_select_tool_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_FOREGROUND_SELECT_TOOL,
|
||||
g_param_spec_object ("foreground-select-tool",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_FOREGROUND_SELECT_TOOL,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_foreground_select_tool_undo_init (GimpForegroundSelectToolUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_foreground_select_tool_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpForegroundSelectToolUndo *foreground_select_tool_undo;
|
||||
GimpForegroundSelectTool *foreground_select_tool;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
foreground_select_tool_undo = GIMP_FOREGROUND_SELECT_TOOL_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_FOREGROUND_SELECT_TOOL (foreground_select_tool_undo->foreground_select_tool));
|
||||
|
||||
foreground_select_tool = GIMP_FOREGROUND_SELECT_TOOL (foreground_select_tool_undo->foreground_select_tool);
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (foreground_select_tool_undo->foreground_select_tool),
|
||||
(gpointer) &foreground_select_tool_undo->foreground_select_tool);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_foreground_select_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpForegroundSelectToolUndo *foreground_select_tool_undo =
|
||||
GIMP_FOREGROUND_SELECT_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_FOREGROUND_SELECT_TOOL:
|
||||
foreground_select_tool_undo->foreground_select_tool =
|
||||
g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_foreground_select_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpForegroundSelectToolUndo *foreground_select_tool_undo =
|
||||
GIMP_FOREGROUND_SELECT_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_FOREGROUND_SELECT_TOOL:
|
||||
g_value_set_object (value,
|
||||
foreground_select_tool_undo->foreground_select_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_foreground_select_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpForegroundSelectToolUndo *foreground_select_tool_undo =
|
||||
GIMP_FOREGROUND_SELECT_TOOL_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_foreground_select_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpForegroundSelectToolUndo *foreground_select_tool_undo = GIMP_FOREGROUND_SELECT_TOOL_UNDO (undo);
|
||||
|
||||
if (foreground_select_tool_undo->foreground_select_tool)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (foreground_select_tool_undo->foreground_select_tool),
|
||||
(gpointer) &foreground_select_tool_undo->foreground_select_tool);
|
||||
foreground_select_tool_undo->foreground_select_tool = NULL;
|
||||
}
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
}
|
52
app/tools/gimpforegroundselecttoolundo.h
Normal file
52
app/tools/gimpforegroundselecttoolundo.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* 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_FOREGROUND_SELECT_TOOL_UNDO_H__
|
||||
#define __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__
|
||||
|
||||
|
||||
#include "core/gimpundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO (gimp_foreground_select_tool_undo_get_type ())
|
||||
#define GIMP_FOREGROUND_SELECT_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO, GimpForegroundSelectToolUndo))
|
||||
#define GIMP_FOREGROUND_SELECT_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO, GimpForegroundSelectToolUndoClass))
|
||||
#define GIMP_IS_FOREGROUND_SELECT_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO))
|
||||
#define GIMP_IS_FOREGROUND_SELECT_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO))
|
||||
#define GIMP_FOREGROUND_SELECT_TOOL_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_FOREGROUND_SELECT_TOOL_UNDO, GimpForegroundSelectToolUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpForegroundSelectToolUndoClass GimpForegroundSelectToolUndoClass;
|
||||
|
||||
struct _GimpForegroundSelectToolUndo
|
||||
{
|
||||
GimpUndo parent_instance;
|
||||
|
||||
GimpForegroundSelectTool *foreground_select_tool;
|
||||
};
|
||||
|
||||
struct _GimpForegroundSelectToolUndoClass
|
||||
{
|
||||
GimpUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_foreground_select_tool_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_FOREGROUND_SELECT_TOOL_UNDO_H__ */
|
|
@ -1,155 +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 <gtk/gtk.h>
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "core/gimpimage-undo.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpundo.h"
|
||||
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformtool-undo.h"
|
||||
#include "tool_manager.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/********************/
|
||||
/* Transform Undo */
|
||||
/********************/
|
||||
|
||||
typedef struct _TransformUndo TransformUndo;
|
||||
|
||||
struct _TransformUndo
|
||||
{
|
||||
gint tool_ID;
|
||||
GType tool_type;
|
||||
|
||||
TransInfo trans_info;
|
||||
TileManager *original;
|
||||
};
|
||||
|
||||
static gboolean undo_pop_transform (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_transform (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_push_undo (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
gint tool_ID,
|
||||
GType tool_type,
|
||||
gdouble *trans_info,
|
||||
TileManager *original)
|
||||
{
|
||||
GimpUndo *new;
|
||||
|
||||
if ((new = gimp_image_undo_push (image, GIMP_TYPE_UNDO,
|
||||
sizeof (TransformUndo),
|
||||
sizeof (TransformUndo),
|
||||
GIMP_UNDO_TRANSFORM, undo_desc,
|
||||
FALSE,
|
||||
undo_pop_transform,
|
||||
undo_free_transform,
|
||||
NULL)))
|
||||
{
|
||||
TransformUndo *tu = new->data;
|
||||
gint i;
|
||||
|
||||
tu->tool_ID = tool_ID;
|
||||
tu->tool_type = tool_type;
|
||||
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
tu->trans_info[i] = trans_info[i];
|
||||
|
||||
if (original)
|
||||
tu->original = tile_manager_ref (original);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_transform (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpTool *active_tool;
|
||||
|
||||
active_tool = tool_manager_get_active (undo->image->gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
{
|
||||
GimpTransformTool *tt = GIMP_TRANSFORM_TOOL (active_tool);
|
||||
TransformUndo *tu = undo->data;
|
||||
|
||||
/* only pop if the active tool is the tool that pushed this undo */
|
||||
if (tu->tool_ID == active_tool->ID)
|
||||
{
|
||||
TileManager *temp;
|
||||
gdouble d;
|
||||
gint i;
|
||||
|
||||
/* swap the transformation information arrays */
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
{
|
||||
d = tu->trans_info[i];
|
||||
tu->trans_info[i] = tt->trans_info[i];
|
||||
tt->trans_info[i] = d;
|
||||
}
|
||||
|
||||
/* swap the original buffer--the source buffer for repeated transforms
|
||||
*/
|
||||
temp = tu->original;
|
||||
tu->original = tt->original;
|
||||
tt->original = temp;
|
||||
|
||||
/* If we're re-implementing the first transform, reactivate tool */
|
||||
if (undo_mode == GIMP_UNDO_MODE_REDO && tt->original)
|
||||
{
|
||||
gimp_tool_control_activate (active_tool->control);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_transform (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
TransformUndo * tu = undo->data;
|
||||
|
||||
if (tu->original)
|
||||
tile_manager_unref (tu->original);
|
||||
|
||||
g_free (tu);
|
||||
}
|
|
@ -1,31 +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_TRANSFORM_TOOL_UNDO_H__
|
||||
#define __GIMP_TRANSFORM_TOOL_UNDO_H__
|
||||
|
||||
|
||||
gboolean gimp_transform_tool_push_undo (GimpImage *image,
|
||||
const gchar *undo_desc,
|
||||
gint tool_ID,
|
||||
GType tool_type,
|
||||
gdouble *trans_info,
|
||||
TileManager *original);
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_TOOL_UNDO_H__ */
|
|
@ -61,7 +61,7 @@
|
|||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformoptions.h"
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformtool-undo.h"
|
||||
#include "gimptransformtoolundo.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
@ -1280,11 +1280,13 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool,
|
|||
*/
|
||||
tool->drawable = gimp_image_active_drawable (display->image);
|
||||
|
||||
gimp_transform_tool_push_undo (display->image, NULL,
|
||||
tool->ID,
|
||||
G_TYPE_FROM_INSTANCE (tool),
|
||||
tr_tool->old_trans_info,
|
||||
NULL);
|
||||
gimp_image_undo_push (display->image, GIMP_TYPE_TRANSFORM_TOOL_UNDO,
|
||||
0, 0,
|
||||
GIMP_UNDO_TRANSFORM, NULL,
|
||||
0,
|
||||
NULL, NULL,
|
||||
"transform-tool", tr_tool,
|
||||
NULL);
|
||||
|
||||
/* push the undo group end */
|
||||
gimp_image_undo_group_end (display->image);
|
||||
|
|
223
app/tools/gimptransformtoolundo.c
Normal file
223
app/tools/gimptransformtoolundo.c
Normal file
|
@ -0,0 +1,223 @@
|
|||
/* 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 <gtk/gtk.h>
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "gimptoolcontrol.h"
|
||||
#include "gimptransformtool.h"
|
||||
#include "gimptransformtoolundo.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TRANSFORM_TOOL
|
||||
};
|
||||
|
||||
|
||||
static GObject * gimp_transform_tool_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_transform_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_transform_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_transform_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void gimp_transform_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpTransformToolUndo, gimp_transform_tool_undo, GIMP_TYPE_UNDO)
|
||||
|
||||
#define parent_class gimp_transform_tool_undo_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_class_init (GimpTransformToolUndoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_transform_tool_undo_constructor;
|
||||
object_class->set_property = gimp_transform_tool_undo_set_property;
|
||||
object_class->get_property = gimp_transform_tool_undo_get_property;
|
||||
|
||||
undo_class->pop = gimp_transform_tool_undo_pop;
|
||||
undo_class->free = gimp_transform_tool_undo_free;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TRANSFORM_TOOL,
|
||||
g_param_spec_object ("transform-tool",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_TRANSFORM_TOOL,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_init (GimpTransformToolUndo *undo)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_transform_tool_undo_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpTransformToolUndo *transform_tool_undo;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint i;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (object);
|
||||
|
||||
g_assert (GIMP_IS_TRANSFORM_TOOL (transform_tool_undo->transform_tool));
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (transform_tool_undo->transform_tool);
|
||||
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
transform_tool_undo->trans_info[i] = transform_tool->old_trans_info[i];
|
||||
|
||||
#if 0
|
||||
if (transform_tool->original)
|
||||
transform_tool_undo->original = tile_manager_ref (transform_tool->original);
|
||||
#endif
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (transform_tool_undo->transform_tool),
|
||||
(gpointer) &transform_tool_undo->transform_tool);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSFORM_TOOL:
|
||||
transform_tool_undo->transform_tool = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TRANSFORM_TOOL:
|
||||
g_value_set_object (value, transform_tool_undo->transform_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (undo);
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
|
||||
|
||||
if (transform_tool_undo->transform_tool)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
TileManager *temp;
|
||||
gdouble d;
|
||||
gint i;
|
||||
|
||||
transform_tool = transform_tool_undo->transform_tool;
|
||||
|
||||
/* swap the transformation information arrays */
|
||||
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
||||
{
|
||||
d = transform_tool_undo->trans_info[i];
|
||||
transform_tool_undo->trans_info[i] = transform_tool->trans_info[i];
|
||||
transform_tool->trans_info[i] = d;
|
||||
}
|
||||
|
||||
/* swap the original buffer--the source buffer for repeated transforms
|
||||
*/
|
||||
temp = transform_tool_undo->original;
|
||||
transform_tool_undo->original = transform_tool->original;
|
||||
transform_tool->original = temp;
|
||||
|
||||
/* If we're re-implementing the first transform, reactivate tool */
|
||||
if (undo_mode == GIMP_UNDO_MODE_REDO && transform_tool->original)
|
||||
{
|
||||
gimp_tool_control_activate (GIMP_TOOL (transform_tool)->control);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (transform_tool));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_undo_free (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
GimpTransformToolUndo *transform_tool_undo = GIMP_TRANSFORM_TOOL_UNDO (undo);
|
||||
|
||||
if (transform_tool_undo->transform_tool)
|
||||
{
|
||||
g_object_remove_weak_pointer (G_OBJECT (transform_tool_undo->transform_tool),
|
||||
(gpointer) &transform_tool_undo->transform_tool);
|
||||
transform_tool_undo->transform_tool = NULL;
|
||||
}
|
||||
|
||||
if (transform_tool_undo->original)
|
||||
{
|
||||
tile_manager_unref (transform_tool_undo->original);
|
||||
transform_tool_undo->original = NULL;
|
||||
}
|
||||
|
||||
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);
|
||||
}
|
54
app/tools/gimptransformtoolundo.h
Normal file
54
app/tools/gimptransformtoolundo.h
Normal file
|
@ -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_TRANSFORM_TOOL_UNDO_H__
|
||||
#define __GIMP_TRANSFORM_TOOL_UNDO_H__
|
||||
|
||||
|
||||
#include "core/gimpundo.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_TOOL_UNDO (gimp_transform_tool_undo_get_type ())
|
||||
#define GIMP_TRANSFORM_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TRANSFORM_TOOL_UNDO, GimpTransformToolUndo))
|
||||
#define GIMP_TRANSFORM_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TRANSFORM_TOOL_UNDO, GimpTransformToolUndoClass))
|
||||
#define GIMP_IS_TRANSFORM_TOOL_UNDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TRANSFORM_TOOL_UNDO))
|
||||
#define GIMP_IS_TRANSFORM_TOOL_UNDO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TRANSFORM_TOOL_UNDO))
|
||||
#define GIMP_TRANSFORM_TOOL_UNDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TRANSFORM_TOOL_UNDO, GimpTransformToolUndoClass))
|
||||
|
||||
|
||||
typedef struct _GimpTransformToolUndoClass GimpTransformToolUndoClass;
|
||||
|
||||
struct _GimpTransformToolUndo
|
||||
{
|
||||
GimpUndo parent_instance;
|
||||
|
||||
GimpTransformTool *transform_tool;
|
||||
TransInfo trans_info;
|
||||
TileManager *original;
|
||||
};
|
||||
|
||||
struct _GimpTransformToolUndoClass
|
||||
{
|
||||
GimpUndoClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_transform_tool_undo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_TOOL_UNDO_H__ */
|
|
@ -28,18 +28,20 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef struct _GimpTool GimpTool;
|
||||
typedef struct _GimpToolControl GimpToolControl;
|
||||
typedef struct _GimpTool GimpTool;
|
||||
typedef struct _GimpToolControl GimpToolControl;
|
||||
|
||||
typedef struct _GimpBrushTool GimpBrushTool;
|
||||
typedef struct _GimpColorTool GimpColorTool;
|
||||
typedef struct _GimpDrawTool GimpDrawTool;
|
||||
typedef struct _GimpImageMapTool GimpImageMapTool;
|
||||
typedef struct _GimpPaintTool GimpPaintTool;
|
||||
typedef struct _GimpTransformTool GimpTransformTool;
|
||||
typedef struct _GimpBrushTool GimpBrushTool;
|
||||
typedef struct _GimpColorTool GimpColorTool;
|
||||
typedef struct _GimpDrawTool GimpDrawTool;
|
||||
typedef struct _GimpForegroundSelectToolUndo GimpForegroundSelectToolUndo;
|
||||
typedef struct _GimpImageMapTool GimpImageMapTool;
|
||||
typedef struct _GimpPaintTool GimpPaintTool;
|
||||
typedef struct _GimpTransformTool GimpTransformTool;
|
||||
typedef struct _GimpTransformToolUndo GimpTransformToolUndo;
|
||||
|
||||
typedef struct _GimpColorOptions GimpColorOptions;
|
||||
typedef struct _GimpImageMapOptions GimpImageMapOptions;
|
||||
typedef struct _GimpColorOptions GimpColorOptions;
|
||||
typedef struct _GimpImageMapOptions GimpImageMapOptions;
|
||||
|
||||
|
||||
/* functions */
|
||||
|
|
Loading…
Reference in a new issue