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 
59  LayerBitmap* createBitmapLayer(const QString& strLayerName);
60  LayerVector* createVectorLayer(const QString& strLayerName);
61  LayerCamera* createCameraLayer(const QString& strLayerName);
62  LayerSound* createSoundLayer(const QString& strLayerName);
63 
64  // KeyFrame Management
65  int lastFrameAtFrame(int frameIndex);
66  int firstKeyFrameIndex();
67  int lastKeyFrameIndex();
68 
69  int animationLength(bool includeSounds = true);
70  void notifyAnimationLengthChanged();
71 
72  QString nameSuggestLayer(const QString& name);
73  int getLastLayerIndex() { return count() - 1; }
74 
75 signals:
76  void currentLayerChanged(int index);
77  void layerCountChanged(int count);
78  void animationLengthChanged(int length);
79  void layerDeleted(int index);
80 
81 private:
82  int getIndex(Layer*) const;
83 
84  int mLastCameraLayerIdx = 0;
85 };
86 
87 #endif
Q_OBJECTQ_OBJECT
Definition: layer.h:39
Definition: object.h:54
Definition: editor.h:51
int animationLength(bool includeSounds=true)
Get the length of current project.