All Classes Namespaces Functions Variables Enumerations Properties Pages
layermanager.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef LAYER_MANAGER_H
19 #define LAYER_MANAGER_H
20 
21 #include "basemanager.h"
22 #include "layer.h"
23 
24 class LayerBitmap;
25 class LayerVector;
26 class LayerCamera;
27 class LayerSound;
28 
29 
30 class LayerManager : public BaseManager
31 {
32  Q_OBJECT
33 
34 public:
35  explicit LayerManager(Editor* editor);
36  ~LayerManager() override;
37  bool init() override;
38  Status load(Object*) override;
39  Status save(Object*) override;
40 
41  // Layer Management
42  Layer* currentLayer();
43  Layer* currentLayer(int offset);
44  Layer* getLayer(int index);
45  Layer* findLayerByName(QString sName, Layer::LAYER_TYPE type = Layer::UNDEFINED);
46  Layer* getLastCameraLayer();
47  int currentLayerIndex();
48  void setCurrentLayer(int nIndex);
49  void setCurrentLayer(Layer* layer);
50  int count();
51 
52  Status deleteLayer(int index);
53  Status renameLayer(Layer*, const QString& newName);
54  void notifyLayerChanged(Layer*);
55 
56  void gotoNextLayer();
57  void gotoPreviouslayer();
58 
60  Layer* createLayer(Layer::LAYER_TYPE type, const QString& strLayerName);
61  LayerBitmap* createBitmapLayer(const QString& strLayerName);
62  LayerVector* createVectorLayer(const QString& strLayerName);
63  LayerCamera* createCameraLayer(const QString& strLayerName);
64  LayerSound* createSoundLayer(const QString& strLayerName);
65 
66  // KeyFrame Management
67  int lastFrameAtFrame(int frameIndex);
68  int firstKeyFrameIndex();
69  int lastKeyFrameIndex();
70 
71  int animationLength(bool includeSounds = true);
72 
75 
76  QString nameSuggestLayer(const QString& name);
77  int getLastLayerIndex() { return count() - 1; }
78 
79 signals:
80  void currentLayerChanged(int index);
81  void layerCountChanged(int count);
82  void animationLengthChanged(int length);
83  void layerDeleted(int index);
84 
85 private:
86  int getIndex(Layer*) const;
87 
88  int mLastCameraLayerIdx = 0;
89 };
90 
91 #endif
Q_OBJECTQ_OBJECT
Definition: layer.h:38
Layer * createLayer(Layer::LAYER_TYPE type, const QString &strLayerName)
Returns a new Layer with the given LAYER_TYPE.
Definition: object.h:41
Definition: editor.h:55
int animationLength(bool includeSounds=true)
Get the length of current project.
void notifyAnimationLengthChanged()
This should be emitted whenever the animation length frames, eg.