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  KeyFrame& operator=(const KeyFrame& k2);
37 
38  int pos() const { return mFrame; }
39  void setPos(int position) { mFrame = position; }
40 
41  int length() const { return mLength; }
42  void setLength(int len) { mLength = len; }
43 
44  void modification() { mIsModified = true; }
45  void setModified(bool b) { mIsModified = b; }
46  bool isModified() const { return mIsModified; }
47 
48  void setSelected(bool b) { mIsSelected = b; }
49  bool isSelected() const { return mIsSelected; }
50 
51  QString fileName() const { return mAttachedFileName; }
52  void setFileName(QString strFileName) { mAttachedFileName = strFileName; }
53 
54  void addEventListener(KeyFrameEventListener*);
55  void removeEventListner(KeyFrameEventListener*);
56 
57  virtual KeyFrame* clone() const { return nullptr; }
58  virtual void loadFile() {}
59  virtual void unloadFile() {}
60  virtual bool isLoaded() const { return true; }
61 
62  virtual quint64 memoryUsage() { return 0; }
63 
64 private:
65  int mFrame = -1;
66  int mLength = 1;
67  bool mIsModified = true;
68  bool mIsSelected = false;
69  QString mAttachedFileName;
70 
71  std::vector<KeyFrameEventListener*> mEventListeners;
72 };
73 
75 {
76 public:
77  virtual void onKeyFrameDestroy(KeyFrame*) = 0;
78 };
79 
80 #endif // KeyFrame_H