2007-11-16 18:25:45 +00:00
|
|
|
/* ASE - Allegro Sprite Editor
|
2012-01-06 00:52:11 -03:00
|
|
|
* Copyright (C) 2001-2012 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
|
|
|
|
*/
|
|
|
|
|
2009-08-17 21:38:00 +00:00
|
|
|
#ifndef RASTER_LAYER_H_INCLUDED
|
|
|
|
#define RASTER_LAYER_H_INCLUDED
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2009-11-17 13:12:26 +00:00
|
|
|
#include <string>
|
2007-09-18 23:57:02 +00:00
|
|
|
#include "raster/gfxobj.h"
|
2010-12-05 11:44:01 -03:00
|
|
|
#include "raster/blend.h"
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
class Cel;
|
|
|
|
class Image;
|
|
|
|
class Sprite;
|
2009-11-17 13:12:26 +00:00
|
|
|
class Layer;
|
|
|
|
class LayerImage;
|
|
|
|
class LayerFolder;
|
2008-03-23 02:08:06 +00:00
|
|
|
|
2009-11-17 13:12:26 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Layer class
|
|
|
|
|
2011-03-27 18:15:00 -03:00
|
|
|
enum {
|
|
|
|
LAYER_IS_READABLE = 0x0001,
|
|
|
|
LAYER_IS_WRITABLE = 0x0002,
|
|
|
|
LAYER_IS_LOCKMOVE = 0x0004,
|
|
|
|
LAYER_IS_BACKGROUND = 0x0008,
|
|
|
|
};
|
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
class Layer : public GfxObj
|
2007-09-18 23:57:02 +00:00
|
|
|
{
|
2009-11-17 13:12:26 +00:00
|
|
|
protected:
|
2010-09-18 20:49:13 -03:00
|
|
|
Layer(GfxObjType type, Sprite* sprite);
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
public:
|
2009-11-17 13:12:26 +00:00
|
|
|
virtual ~Layer();
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2010-10-03 15:51:03 -03:00
|
|
|
int getMemSize() const;
|
|
|
|
|
2010-09-19 00:03:32 -03:00
|
|
|
std::string getName() const { return m_name; }
|
|
|
|
void setName(const std::string& name) { m_name = name; }
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2010-03-01 22:59:16 -02:00
|
|
|
Sprite* getSprite() const { return m_sprite; }
|
2009-11-17 13:12:26 +00:00
|
|
|
LayerFolder* get_parent() const { return m_parent; }
|
|
|
|
void set_parent(LayerFolder* folder) { m_parent = folder; }
|
|
|
|
Layer* get_prev() const;
|
|
|
|
Layer* get_next() const;
|
|
|
|
|
2010-09-18 20:49:13 -03:00
|
|
|
bool is_image() const { return getType() == GFXOBJ_LAYER_IMAGE; }
|
|
|
|
bool is_folder() const { return getType() == GFXOBJ_LAYER_FOLDER; }
|
2009-11-17 13:12:26 +00:00
|
|
|
bool is_background() const { return (m_flags & LAYER_IS_BACKGROUND) == LAYER_IS_BACKGROUND; }
|
|
|
|
bool is_moveable() const { return (m_flags & LAYER_IS_LOCKMOVE) == 0; }
|
|
|
|
bool is_readable() const { return (m_flags & LAYER_IS_READABLE) == LAYER_IS_READABLE; }
|
|
|
|
bool is_writable() const { return (m_flags & LAYER_IS_WRITABLE) == LAYER_IS_WRITABLE; }
|
|
|
|
|
|
|
|
void set_background(bool b) { if (b) m_flags |= LAYER_IS_BACKGROUND; else m_flags &= ~LAYER_IS_BACKGROUND; }
|
|
|
|
void set_moveable(bool b) { if (b) m_flags &= ~LAYER_IS_LOCKMOVE; else m_flags |= LAYER_IS_LOCKMOVE; }
|
|
|
|
void set_readable(bool b) { if (b) m_flags |= LAYER_IS_READABLE; else m_flags &= ~LAYER_IS_READABLE; }
|
|
|
|
void set_writable(bool b) { if (b) m_flags |= LAYER_IS_WRITABLE; else m_flags &= ~LAYER_IS_WRITABLE; }
|
|
|
|
|
2011-03-27 18:15:00 -03:00
|
|
|
uint32_t getFlags() const { return m_flags; }
|
|
|
|
void setFlags(uint32_t flags) { m_flags = flags; }
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2011-03-27 18:15:00 -03:00
|
|
|
virtual void getCels(CelList& cels) = 0;
|
2010-09-19 00:15:44 -03:00
|
|
|
|
|
|
|
private:
|
2012-01-05 19:45:03 -03:00
|
|
|
std::string m_name; // layer name
|
|
|
|
Sprite* m_sprite; // owner of the layer
|
|
|
|
LayerFolder* m_parent; // parent layer
|
2010-09-19 00:15:44 -03:00
|
|
|
unsigned short m_flags;
|
2011-03-22 21:11:25 -03:00
|
|
|
|
|
|
|
// Disable assigment
|
|
|
|
Layer& operator=(const Layer& other);
|
2009-11-17 13:12:26 +00:00
|
|
|
};
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2009-11-17 13:12:26 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// LayerImage class
|
2008-10-01 01:27:51 +00:00
|
|
|
|
2009-11-17 13:12:26 +00:00
|
|
|
class LayerImage : public Layer
|
|
|
|
{
|
|
|
|
public:
|
2011-03-22 21:11:25 -03:00
|
|
|
explicit LayerImage(Sprite* sprite);
|
2009-11-17 13:12:26 +00:00
|
|
|
virtual ~LayerImage();
|
|
|
|
|
2010-10-03 15:51:03 -03:00
|
|
|
int getMemSize() const;
|
|
|
|
|
2010-12-05 11:44:01 -03:00
|
|
|
int getBlendMode() const { return BLEND_MODE_NORMAL; }
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2010-09-19 00:26:33 -03:00
|
|
|
void addCel(Cel *cel);
|
|
|
|
void removeCel(Cel *cel);
|
|
|
|
const Cel* getCel(int frame) const;
|
|
|
|
Cel* getCel(int frame);
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2010-09-19 00:15:44 -03:00
|
|
|
void getCels(CelList& cels);
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2010-09-19 00:17:21 -03:00
|
|
|
void configureAsBackground();
|
2009-11-17 13:12:26 +00:00
|
|
|
|
2010-09-19 00:15:44 -03:00
|
|
|
CelIterator getCelBegin() { return m_cels.begin(); }
|
|
|
|
CelIterator getCelEnd() { return m_cels.end(); }
|
|
|
|
CelConstIterator getCelBegin() const { return m_cels.begin(); }
|
|
|
|
CelConstIterator getCelEnd() const { return m_cels.end(); }
|
|
|
|
int getCelsCount() const { return m_cels.size(); }
|
2009-11-17 13:12:26 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-24 13:15:09 -03:00
|
|
|
void destroyAllCels();
|
2010-09-19 00:15:44 -03:00
|
|
|
|
|
|
|
CelList m_cels; // List of all cels inside this layer used by frames.
|
2009-11-17 13:12:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// LayerFolder class
|
|
|
|
|
|
|
|
class LayerFolder : public Layer
|
|
|
|
{
|
|
|
|
public:
|
2011-03-22 21:11:25 -03:00
|
|
|
explicit LayerFolder(Sprite* sprite);
|
2009-11-17 13:12:26 +00:00
|
|
|
virtual ~LayerFolder();
|
|
|
|
|
2010-10-03 15:51:03 -03:00
|
|
|
int getMemSize() const;
|
|
|
|
|
2011-03-27 23:21:22 -03:00
|
|
|
const LayerList& get_layers_list() { return m_layers; }
|
2009-11-17 13:12:26 +00:00
|
|
|
LayerIterator get_layer_begin() { return m_layers.begin(); }
|
|
|
|
LayerIterator get_layer_end() { return m_layers.end(); }
|
|
|
|
LayerConstIterator get_layer_begin() const { return m_layers.begin(); }
|
|
|
|
LayerConstIterator get_layer_end() const { return m_layers.end(); }
|
|
|
|
int get_layers_count() const { return m_layers.size(); }
|
|
|
|
|
|
|
|
void add_layer(Layer* layer);
|
|
|
|
void remove_layer(Layer* layer);
|
|
|
|
void move_layer(Layer* layer, Layer* after);
|
|
|
|
|
2010-09-19 00:15:44 -03:00
|
|
|
void getCels(CelList& cels);
|
2009-11-17 13:12:26 +00:00
|
|
|
|
|
|
|
private:
|
2010-09-19 00:15:44 -03:00
|
|
|
void destroyAllLayers();
|
|
|
|
|
|
|
|
LayerList m_layers;
|
2007-09-18 23:57:02 +00:00
|
|
|
};
|
|
|
|
|
2011-03-27 23:21:22 -03:00
|
|
|
LayerImage* layer_new_flatten_copy(Sprite* dst_sprite, const Layer* src_layer,
|
2012-01-05 19:45:03 -03:00
|
|
|
int x, int y, int w, int h, int frmin, int frmax);
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2008-10-01 01:27:51 +00:00
|
|
|
void layer_render(const Layer* layer, Image *image, int x, int y, int frame);
|
2007-09-18 23:57:02 +00:00
|
|
|
|
2009-08-17 21:38:00 +00:00
|
|
|
#endif
|