2007-11-16 18:25:45 +00:00
|
|
|
/* ASE - Allegro Sprite Editor
|
2009-01-24 00:41:01 +00:00
|
|
|
* Copyright (C) 2001-2009 David Capello
|
2007-09-18 23:57:02 +00:00
|
|
|
*
|
|
|
|
* 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 RASTER_UNDO_H
|
|
|
|
#define RASTER_UNDO_H
|
|
|
|
|
|
|
|
#include <string.h> /* for strlen */
|
|
|
|
|
|
|
|
#include "raster/gfxobj.h"
|
2009-06-11 15:11:11 +00:00
|
|
|
#include "ase_exception.h"
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
class Cel;
|
|
|
|
class Image;
|
|
|
|
class Layer;
|
|
|
|
class Mask;
|
|
|
|
class Sprite;
|
|
|
|
class Stock;
|
|
|
|
|
2007-09-18 23:57:02 +00:00
|
|
|
struct Dirty;
|
|
|
|
struct UndoStream;
|
|
|
|
|
2009-06-11 15:11:11 +00:00
|
|
|
class undo_exception : public ase_exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
undo_exception(const char* msg) throw() : ase_exception(msg) { }
|
|
|
|
};
|
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
class Undo : public GfxObj
|
2007-09-18 23:57:02 +00:00
|
|
|
{
|
2008-10-01 01:27:51 +00:00
|
|
|
public:
|
|
|
|
Sprite* sprite; /* related sprite */
|
|
|
|
UndoStream *undo_stream;
|
|
|
|
UndoStream *redo_stream;
|
2007-09-18 23:57:02 +00:00
|
|
|
int diff_count;
|
|
|
|
int diff_saved;
|
|
|
|
unsigned enabled : 1; /* is undo enabled? */
|
2008-03-27 14:29:33 +00:00
|
|
|
const char *label; /* current label to be applied to all
|
|
|
|
next undo operations */
|
2008-10-01 01:27:51 +00:00
|
|
|
|
|
|
|
Undo(Sprite* sprite);
|
|
|
|
virtual ~Undo();
|
2007-09-18 23:57:02 +00:00
|
|
|
};
|
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
Undo* undo_new(Sprite* sprite);
|
|
|
|
void undo_free(Undo* undo);
|
|
|
|
|
2009-06-11 00:59:57 +00:00
|
|
|
int undo_get_memsize(const Undo* undo);
|
2008-10-01 01:27:51 +00:00
|
|
|
|
|
|
|
void undo_enable(Undo* undo);
|
|
|
|
void undo_disable(Undo* undo);
|
|
|
|
|
2009-06-11 00:59:57 +00:00
|
|
|
bool undo_is_enabled(const Undo* undo);
|
|
|
|
bool undo_is_disabled(const Undo* undo);
|
2008-10-01 01:27:51 +00:00
|
|
|
|
2009-06-11 00:59:57 +00:00
|
|
|
bool undo_can_undo(const Undo* undo);
|
|
|
|
bool undo_can_redo(const Undo* undo);
|
2008-10-01 01:27:51 +00:00
|
|
|
|
2008-10-02 02:31:07 +00:00
|
|
|
void undo_do_undo(Undo* undo);
|
|
|
|
void undo_do_redo(Undo* undo);
|
|
|
|
|
|
|
|
void undo_clear_redo(Undo* undo);
|
2008-10-01 01:27:51 +00:00
|
|
|
|
|
|
|
void undo_set_label(Undo* undo, const char *label);
|
2009-06-11 00:59:57 +00:00
|
|
|
const char* undo_get_next_undo_label(const Undo* undo);
|
|
|
|
const char* undo_get_next_redo_label(const Undo* undo);
|
2008-10-01 01:27:51 +00:00
|
|
|
|
|
|
|
void undo_open(Undo* undo);
|
|
|
|
void undo_close(Undo* undo);
|
|
|
|
void undo_data(Undo* undo, GfxObj *gfxobj, void *data, int size);
|
|
|
|
void undo_image(Undo* undo, Image *image, int x, int y, int w, int h);
|
|
|
|
void undo_flip(Undo* undo, Image *image, int x1, int y1, int x2, int y2, int horz);
|
|
|
|
void undo_dirty(Undo* undo, Dirty *dirty);
|
|
|
|
void undo_add_image(Undo* undo, Stock *stock, int image_index);
|
|
|
|
void undo_remove_image(Undo* undo, Stock *stock, int image_index);
|
|
|
|
void undo_replace_image(Undo* undo, Stock *stock, int image_index);
|
|
|
|
void undo_add_cel(Undo* undo, Layer *layer, Cel *cel);
|
|
|
|
void undo_remove_cel(Undo* undo, Layer *layer, Cel *cel);
|
|
|
|
void undo_add_layer(Undo* undo, Layer *set, Layer *layer);
|
|
|
|
void undo_remove_layer(Undo* undo, Layer *layer);
|
|
|
|
void undo_move_layer(Undo* undo, Layer *layer);
|
|
|
|
void undo_set_layer(Undo* undo, Sprite* sprite);
|
2009-06-11 15:11:11 +00:00
|
|
|
void undo_add_palette(Undo* undo, Sprite* sprite, Palette* palette);
|
|
|
|
void undo_remove_palette(Undo* undo, Sprite* sprite, Palette* palette);
|
2008-10-01 01:27:51 +00:00
|
|
|
void undo_set_mask(Undo* undo, Sprite* sprite);
|
|
|
|
void undo_set_frames(Undo* undo, Sprite* sprite);
|
|
|
|
void undo_set_frlen(Undo* undo, Sprite* sprite, int frame);
|
2007-09-18 23:57:02 +00:00
|
|
|
|
|
|
|
#define undo_int(undo, gfxobj, value_address) \
|
2007-09-27 18:02:23 +00:00
|
|
|
undo_data((undo), (gfxobj), (void *)(value_address), sizeof(int))
|
2007-09-18 23:57:02 +00:00
|
|
|
|
|
|
|
#define undo_double(undo, gfxobj, value_address) \
|
2007-09-27 18:02:23 +00:00
|
|
|
undo_data((undo), (gfxobj), (void *)(value_address), sizeof(double))
|
2007-09-18 23:57:02 +00:00
|
|
|
|
|
|
|
#endif /* RASTER_UNDO_H */
|