Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
timelinecells.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2017 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 TIMELINECELLS_H
19 #define TIMELINECELLS_H
20 
21 #include <QWidget>
22 #include <QString>
23 
24 
25 class TimeLine;
26 class QPaintEvent;
27 class QMouseEvent;
28 class QResizeEvent;
29 class Editor;
30 class PreferenceManager;
31 enum class SETTING;
32 
33 enum class TIMELINE_CELL_TYPE
34 {
35  Layers,
36  Tracks
37 };
38 
39 class TimeLineCells : public QWidget
40 {
41  Q_OBJECT
42 
43 public:
44  TimeLineCells( TimeLine* parent, Editor* editor, TIMELINE_CELL_TYPE );
45  ~TimeLineCells();
46  int getLayerNumber(int y);
47  int getLayerY(int layerNumber);
48  int getFrameNumber(int x);
49  int getFrameX(int frameNumber);
50  int getMouseMoveY() { return mouseMoveY; }
51  int getOffsetX() { return m_offsetX; }
52  int getOffsetY() { return m_offsetY; }
53  int getLayerHeight() { return layerHeight; }
54  int getFrameLength() {return frameLength;}
55  int getFrameSize() { return frameSize; }
56  void clearCache() { if ( m_pCache ) delete m_pCache; m_pCache = new QPixmap( size() ); }
57 
58 Q_SIGNALS:
59  void mouseMovedY(int);
60  void lengthChanged(int);
61  void offsetChanged(int);
62 
63 public slots:
64  void updateContent();
65  void updateFrame(int frameNumber);
66  void hScrollChange(int);
67  void vScrollChange(int);
68  void setMouseMoveY(int x);
69 
70 protected:
71  void drawContent();
72  void paintOnionSkin(QPainter& painter);
73  void paintEvent(QPaintEvent* event);
74  void resizeEvent(QResizeEvent* event);
75  void mousePressEvent(QMouseEvent* event);
76  void mouseMoveEvent(QMouseEvent* event);
77  void mouseReleaseEvent(QMouseEvent* event);
78  void mouseDoubleClickEvent(QMouseEvent* event);
79 
80 private slots:
81  void loadSetting(SETTING setting);
82 
83 private:
84  TimeLine* timeLine;
85  Editor* mEditor; // the editor for which this timeLine operates
86  PreferenceManager* mPrefs;
87 
88  TIMELINE_CELL_TYPE m_eType;
89 
90  QPixmap* m_pCache;
91  bool drawFrameNumber;
92  bool shortScrub;
93  int frameLength;
94  int frameSize;
95  int fontSize;
96  bool scrubbing;
97  int layerHeight;
98  const static int m_offsetX = 0;
99  const static int m_offsetY = 20;
100  int startY, endY, startLayerNumber;
101  int startFrameNumber;
102  int lastFrameNumber = -1;
103  int mouseMoveY, mouseMoveX;
104  int frameOffset, layerOffset;
105  Qt::MouseButton primaryButton = Qt::NoButton;
106 
107  bool canMoveFrame = false;
108  bool movingFrames = false;
109 
110  bool canBoxSelect = false;
111  bool boxSelecting = false;
112 
113  bool clickSelecting = false;
114 
115 };
116 
117 #endif // TIMELINECELLS_H
Definition: editor.h:45