All Classes Namespaces Functions Variables Enumerations Properties Pages
keyframe.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 KeyFrame_H
19 #define KeyFrame_H
20 
21 #include <cstdint>
22 #include <vector>
23 #include <memory>
24 #include <QString>
25 #include "pencilerror.h"
27 
28 
29 class KeyFrame
30 {
31 public:
32  explicit KeyFrame();
33  explicit KeyFrame(const KeyFrame& k2);
34  virtual ~KeyFrame();
35 
36  int pos() const { return mFrame; }
37  void setPos(int position) { mFrame = position; }
38 
39  int length() const { return mLength; }
40  void setLength(int len) { mLength = len; }
41 
42  void modification() { mIsModified = true; }
43  void setModified(bool b) { mIsModified = b; }
44  bool isModified() const { return mIsModified; }
45 
46  void setSelected(bool b) { mIsSelected = b; }
47  bool isSelected() const { return mIsSelected; }
48 
49  QString fileName() const { return mAttachedFileName; }
50  void setFileName(QString strFileName) { mAttachedFileName = strFileName; }
51 
52  void addEventListener(KeyFrameEventListener*);
53  void removeEventListner(KeyFrameEventListener*);
54 
55  virtual KeyFrame* clone() { return nullptr; }
56  virtual void loadFile() {}
57  virtual void unloadFile() {}
58  virtual bool isLoaded() { return true; }
59 
60  virtual quint64 memoryUsage() { return 0; }
61 
62 private:
63  int mFrame = -1;
64  int mLength = 1;
65  bool mIsModified = true;
66  bool mIsSelected = false;
67  QString mAttachedFileName;
68 
69  std::vector<KeyFrameEventListener*> mEventListeners;
70 };
71 
73 {
74 public:
75  virtual void onKeyFrameDestroy(KeyFrame*) = 0;
76 };
77 
78 #endif // KeyFrame_H