]> git.sesse.net Git - kdenlive/blob - src/customruler.h
Cleanup & fix painting of timeline ruler when seeking:
[kdenlive] / src / customruler.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20 /**
21  * @class CustomRuler
22  * @author Jean-Baptiste Mardelle
23  * @brief Manages the timeline ruler.
24  */
25
26 #ifndef CUSTOMRULER_H
27 #define CUSTOMRULER_H
28
29 #include <QWidget>
30
31 #include "customtrackview.h"
32 #include "timecode.h"
33
34 enum RULER_MOVE { RULER_CURSOR = 0, RULER_START = 1, RULER_MIDDLE = 2, RULER_END = 3 };
35 enum MOUSE_MOVE { NO_MOVE = 0, HORIZONTAL_MOVE = 1, VERTICAL_MOVE = 2 };
36
37 class CustomRuler : public QWidget
38 {
39     Q_OBJECT
40
41 public:
42     CustomRuler(Timecode tc, CustomTrackView *parent);
43     void setPixelPerMark(int rate);
44     static const int comboScale[];
45     int outPoint() const;
46     int inPoint() const;
47     void setDuration(int d);
48     void setZone(QPoint p);
49     int offset() const;
50     void updateProjectFps(Timecode t);
51     void updateFrameSize();
52     void updatePalette();
53     
54 protected:
55     virtual void paintEvent(QPaintEvent * /*e*/);
56     virtual void wheelEvent(QWheelEvent * e);
57     virtual void mousePressEvent(QMouseEvent * event);
58     virtual void mouseReleaseEvent(QMouseEvent * event);
59     virtual void mouseMoveEvent(QMouseEvent * event);
60
61 private:
62     Timecode m_timecode;
63     CustomTrackView *m_view;
64     int m_zoneStart;
65     int m_zoneEnd;
66     int m_duration;
67     QColor m_bgColor;
68     QColor m_cursorColor;
69     QColor m_zoneColor;
70     double m_textSpacing;
71     double m_factor;
72     double m_scale;
73     int m_offset;
74     int m_lastSeekPosition;
75     RULER_MOVE m_moveCursor;
76     QMenu *m_contextMenu;
77     QAction *m_editGuide;
78     QAction *m_deleteGuide;
79     int m_clickedGuide;
80     /** Used for zooming through vertical move */
81     QPoint m_clickPoint;
82     int m_rate;
83     int m_startRate;
84     MOUSE_MOVE m_mouseMove;
85     QMenu *m_goMenu;
86
87
88 public slots:
89     void slotMoveRuler(int newPos);
90     void slotCursorMoved(int oldpos, int newpos);
91     void updateRuler();
92
93 private slots:
94     void slotEditGuide();
95     void slotDeleteGuide();
96     void slotGoToGuide(QAction *act);
97
98 signals:
99     void zoneMoved(int, int);
100     void adjustZoom(int);
101 };
102
103 #endif