chalk

kis_group_layer.h
1/*
2 * Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
3 *
4 * this program is free software; you can redistribute it and/or modify
5 * it under the terms of the gnu general public license as published by
6 * the free software foundation; either version 2 of the license, or
7 * (at your option) any later version.
8 *
9 * this program is distributed in the hope that it will be useful,
10 * but without any warranty; without even the implied warranty of
11 * merchantability or fitness for a particular purpose. see the
12 * gnu general public license for more details.
13 *
14 * you should have received a copy of the gnu general public license
15 * along with this program; if not, write to the free software
16 * foundation, inc., 675 mass ave, cambridge, ma 02139, usa.
17 */
18#ifndef KIS_GROUP_LAYER_H_
19#define KIS_GROUP_LAYER_H_
20
21#include <ksharedptr.h>
22
23#include "kis_layer.h"
24#include "kis_types.h"
25
26#include "kis_paint_layer.h"
27
28class KisMergeVisitor;
29
36class KisGroupLayer : public KisLayer {
37 typedef KisLayer super;
38
39 TQ_OBJECT
40
41
42public:
43 KisGroupLayer(KisImage *img, const TQString &name, TQ_UINT8 opacity);
44 KisGroupLayer(const KisGroupLayer& rhs);
45 virtual ~KisGroupLayer();
46
47 virtual KisLayerSP clone() const;
48public:
49
54 virtual void setDirty(bool propagate = true);
55
61 virtual void setDirty(const TQRect & rect, bool propagate = true);
62
63 virtual void activate() {};
64
65 virtual void deactivate() {};
66
67 virtual TQ_INT32 x() const;
68 virtual void setX(TQ_INT32);
69
70 virtual TQ_INT32 y() const;
71 virtual void setY(TQ_INT32);
72
73 // Sets this layer and all its descendants' owner image to the given image.
74 virtual void setImage(KisImage *image);
75
76 virtual TQRect extent() const;
77 virtual TQRect exactBounds() const;
78
79 virtual bool accept(KisLayerVisitor &v)
80 {
81// kdDebug(41001) << "GROUP\t\t" << name()
82// << " dirty: " << dirty()
83// << ", " << m_layers.count() << " children "
84// << ", projection: " << m_projection
85// << "\n";
86 return v.visit(this);
87 };
88
89 virtual void resetProjection(KisPaintDevice* to = 0);
90 virtual KisPaintDeviceSP projection(const TQRect & rect);
91
92 virtual uint childCount() const;
93
94 virtual KisLayerSP firstChild() const;
95 virtual KisLayerSP lastChild() const;
96
98 virtual KisLayerSP at(int index) const;
99
101 virtual int index(KisLayerSP layer) const;
102
104 virtual void setIndex(KisLayerSP layer, int index);
105
108 virtual bool addLayer(KisLayerSP newLayer, int index);
109
112 virtual bool addLayer(KisLayerSP newLayer, KisLayerSP aboveThis);
113
115 virtual bool removeLayer(int index);
116
118 virtual bool removeLayer(KisLayerSP layer);
119
120 virtual TQImage createThumbnail(TQ_INT32 w, TQ_INT32 h);
121
124signals:
125
126 void sigDirty(TQRect rc);
127
128private:
129
130 void updateProjection(const TQRect & rc);
131
132 inline int reverseIndex(int index) const { return childCount() - 1 - index; };
133 vKisLayerSP m_layers; // Contains the list of all layers
134 KisPaintDeviceSP m_projection; // The cached composition of all layers in this group
135
136 TQ_INT32 m_x;
137 TQ_INT32 m_y;
138};
139
140#endif // KIS_GROUP_LAYER_H_
141
virtual KisLayerSP firstChild() const
Returns the first child layer of this layer (if it supports that).
virtual KisPaintDeviceSP projection(const TQRect &rect)
will copy from to, if !0, CoW!!
virtual uint childCount() const
Returns how many direct child layers this layer has (not recursive).
virtual void deactivate()
Called when another layer is made active.
virtual void resetProjection(KisPaintDevice *to=0)
virtual TQRect exactBounds() const
Returns the exact bounds of where the actual data resides in this layer.
virtual bool accept(KisLayerVisitor &v)
Accept the KisLayerVisitor (for the Visitor design pattern), should call the correct function on the ...
virtual KisLayerSP clone() const
Return a copy of this layer.
virtual void activate()
Called when the layer is made active.
virtual bool addLayer(KisLayerSP newLayer, int index)
Adds the layer to this group at the specified index.
virtual void setDirty(bool propagate=true)
Set the entire layer extent dirty; this percolates up to parent layers all the way to the root layer.
virtual KisLayerSP at(int index) const
Returns the layer at the specified index.
virtual KisLayerSP lastChild() const
Returns the last child layer of this layer (if it supports that).
virtual void setIndex(KisLayerSP layer, int index)
Moves the specified layer to the specified index in the group, if it's already a member of this group...
virtual TQRect extent() const
Returns an approximation of where the bounds on actual data are in this layer.
virtual bool removeLayer(int index)
Removes the layer at the specified index from the group.
virtual bool paintLayerInducesProjectionOptimization(KisPaintLayer *l)
Returns if the layer will induce the projection hack (if the only layer in this group).
virtual int index(KisLayerSP layer) const
Returns the index of the layer if it's in this group, or -1 otherwise.
virtual TQImage createThumbnail(TQ_INT32 w, TQ_INT32 h)
Returns a thumbnail in requested size.
A paint device contains the actual pixel data and offers methods to read and write pixels.
This layer is of a type that can be painted on.