aseprite/src/undoable.h

111 lines
3.4 KiB
C
Raw Normal View History

2008-10-02 02:31:07 +00:00
/* ASE - Allegro Sprite Editor
2010-02-01 21:25:40 +00:00
* Copyright (C) 2001-2010 David Capello
2008-10-02 02:31:07 +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
*/
2009-08-17 21:38:00 +00:00
#ifndef UNDOABLE_H_INCLUDED
#define UNDOABLE_H_INCLUDED
2008-10-02 02:31:07 +00:00
class Cel;
class Mask;
2008-10-02 02:31:07 +00:00
class Layer;
class LayerImage;
2008-10-02 02:31:07 +00:00
class Sprite;
class SpriteWriter;
2008-10-02 02:31:07 +00:00
/**
* Class with high-level set of routines to modify a sprite.
*
* In this class, all modifications in the sprite have an undo
* counterpart (if the sprite's undo is enabled).
*/
class Undoable
{
public:
Undoable(SpriteWriter& sprite, const char* label);
2008-10-02 02:31:07 +00:00
virtual ~Undoable();
inline Sprite* getSprite() const { return m_sprite; }
2010-09-19 13:33:07 +00:00
inline bool isEnabled() const { return m_enabledFlag; }
2008-10-02 02:31:07 +00:00
void commit();
// for sprite
2010-09-19 13:33:07 +00:00
void setNumberOfFrames(int frames);
void setCurrentFrame(int frame);
void setCurrentLayer(Layer* layer);
void setSpriteSize(int w, int h);
void cropSprite(int x, int y, int w, int h, int bgcolor);
void autocropSprite(int bgcolor);
void setImgType(int new_imgtype, int dithering_method);
2008-10-02 02:31:07 +00:00
// for images in stock
2010-09-19 13:33:07 +00:00
int addImageInStock(Image* image);
void removeImageFromStock(int image_index);
void replaceStockImage(int image_index, Image* new_image);
2008-10-02 02:31:07 +00:00
// for layers
2010-09-19 13:33:07 +00:00
Layer* newLayer();
void removeLayer(Layer* layer);
void moveLayerAfter(Layer *layer, Layer *after_this);
void cropLayer(Layer* layer, int x, int y, int w, int h, int bgcolor);
void displaceLayers(Layer* layer, int dx, int dy);
void backgroundFromLayer(LayerImage* layer, int bgcolor);
void layerFromBackground();
void flattenLayers(int bgcolor);
private:
2010-09-19 13:33:07 +00:00
void configureLayerAsBackground(LayerImage* layer);
2008-10-02 02:31:07 +00:00
public:
2008-10-02 02:31:07 +00:00
// for frames
2010-09-19 13:33:07 +00:00
void newFrame();
void newFrameForLayer(Layer* layer, int frame);
void removeFrame(int frame);
void removeFrameOfLayer(Layer* layer, int frame);
void copyPreviousFrame(Layer* layer, int frame);
void setFrameDuration(int frame, int msecs);
void setConstantFrameRate(int msecs);
void moveFrameBefore(int frame, int before_frame);
void moveFrameBeforeLayer(Layer* layer, int frame, int before_frame);
2008-10-02 02:31:07 +00:00
// for cels
2010-09-19 13:33:07 +00:00
void addCel(LayerImage* layer, Cel* cel);
void removeCel(LayerImage* layer, Cel* cel);
void setCelFramePosition(Cel* cel, int frame);
void setCelPosition(Cel* cel, int x, int y);
Cel* getCurrentCel();
void cropCel(Cel* cel, int x, int y, int w, int h, int bgcolor);
// for image
2010-09-19 13:33:07 +00:00
Image* getCelImage(Cel* cel);
void clearMask(int bgcolor);
void flipImage(Image* image, int x1, int y1, int x2, int y2,
bool flip_horizontal, bool flip_vertical);
void pasteImage(const Image* src_image, int x, int y, int opacity);
2008-10-02 02:31:07 +00:00
// for mask
2010-09-19 13:33:07 +00:00
void copyToCurrentMask(Mask* mask);
void setMaskPosition(int x, int y);
void deselectMask();
2010-09-19 13:33:07 +00:00
private:
Sprite* m_sprite;
bool m_committed;
bool m_enabledFlag;
2008-10-02 02:31:07 +00:00
};
2009-08-17 21:38:00 +00:00
#endif