krita

kis_group_layer.h

00001 /*
00002  *  Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
00003  *
00004  *  this program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the gnu general public license as published by
00006  *  the free software foundation; either version 2 of the license, or
00007  *  (at your option) any later version.
00008  *
00009  *  this program is distributed in the hope that it will be useful,
00010  *  but without any warranty; without even the implied warranty of
00011  *  merchantability or fitness for a particular purpose.  see the
00012  *  gnu general public license for more details.
00013  *
00014  *  you should have received a copy of the gnu general public license
00015  *  along with this program; if not, write to the free software
00016  *  foundation, inc., 675 mass ave, cambridge, ma 02139, usa.
00017  */
00018 #ifndef KIS_GROUP_LAYER_H_
00019 #define KIS_GROUP_LAYER_H_
00020 
00021 #include <ksharedptr.h>
00022 
00023 #include "kis_layer.h"
00024 #include "kis_types.h"
00025 
00026 #include "kis_paint_layer.h"
00027 
00028 class KisMergeVisitor;
00029 
00036 class KisGroupLayer : public KisLayer {
00037     typedef KisLayer super;
00038 
00039     Q_OBJECT
00040 
00041 public:
00042     KisGroupLayer(KisImage *img, const QString &name, Q_UINT8 opacity);
00043     KisGroupLayer(const KisGroupLayer& rhs);
00044     virtual ~KisGroupLayer();
00045 
00046     virtual KisLayerSP clone() const;
00047 public:
00048 
00053     virtual void setDirty(bool propagate = true);
00054 
00060     virtual void setDirty(const QRect & rect, bool propagate = true);
00061 
00062     virtual void activate() {};
00063 
00064     virtual void deactivate() {};
00065 
00066     virtual Q_INT32 x() const;
00067     virtual void setX(Q_INT32);
00068 
00069     virtual Q_INT32 y() const;
00070     virtual void setY(Q_INT32);
00071 
00072     // Sets this layer and all its descendants' owner image to the given image.
00073     virtual void setImage(KisImage *image);
00074 
00075     virtual QRect extent() const;
00076     virtual QRect exactBounds() const;
00077 
00078     virtual bool accept(KisLayerVisitor &v)
00079         {
00080 //            kdDebug(41001) << "GROUP\t\t" << name()
00081 //                    << " dirty: " << dirty()
00082 //                    << ", " << m_layers.count() << " children "
00083 //                    << ", projection: " << m_projection
00084 //                    << "\n";
00085             return v.visit(this);
00086         };
00087 
00088     virtual void resetProjection();
00089     virtual KisPaintDeviceSP projection(const QRect & rect);
00090 
00091     virtual uint childCount() const;
00092 
00093     virtual KisLayerSP firstChild() const;
00094     virtual KisLayerSP lastChild() const;
00095 
00097     virtual KisLayerSP at(int index) const;
00098 
00100     virtual int index(KisLayerSP layer) const;
00101 
00103     virtual void setIndex(KisLayerSP layer, int index);
00104 
00107     virtual bool addLayer(KisLayerSP newLayer, int index);
00108 
00111     virtual bool addLayer(KisLayerSP newLayer, KisLayerSP aboveThis);
00112 
00114     virtual bool removeLayer(int index);
00115 
00117     virtual bool removeLayer(KisLayerSP layer);
00118 
00119     virtual QImage createThumbnail(Q_INT32 w, Q_INT32 h);
00120     
00121 signals:
00122 
00123     void sigDirty(QRect rc);
00124     
00125 private:
00126     
00127     void updateProjection(const QRect & rc);
00128     
00129     inline int reverseIndex(int index) const { return childCount() - 1 - index; };
00130     vKisLayerSP m_layers; // Contains the list of all layers
00131     KisPaintDeviceSP m_projection; // The cached composition of all layers in this group
00132 
00133     Q_INT32 m_x;
00134     Q_INT32 m_y;
00135 };
00136 
00137 #endif // KIS_GROUP_LAYER_H_
00138 
KDE Home | KDE Accessibility Home | Description of Access Keys