]> git.sesse.net Git - kdenlive/blob - src/customruler.h
Add menu to timeline ruler to easily scroll to a guide
[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 #ifndef CUSTOMRULER_H
21 #define CUSTOMRULER_H
22
23 #include <QWidget>
24
25 #include "customtrackview.h"
26 #include "timecode.h"
27
28 enum RULER_MOVE { RULER_CURSOR = 0, RULER_START = 1, RULER_MIDDLE = 2, RULER_END = 3 };
29 enum MOUSE_MOVE { NO_MOVE = 0, HORIZONTAL_MOVE = 1, VERTICAL_MOVE = 2 };
30
31 class CustomRuler : public QWidget
32 {
33     Q_OBJECT
34
35 public:
36     CustomRuler(Timecode tc, CustomTrackView *parent);
37     void setPixelPerMark(int rate);
38     static const int comboScale[];
39     int outPoint() const;
40     int inPoint() const;
41     void setDuration(int d);
42     void setZone(QPoint p);
43     int offset() const;
44     void updateProjectFps(Timecode t);
45
46 protected:
47     virtual void paintEvent(QPaintEvent * /*e*/);
48     virtual void wheelEvent(QWheelEvent * e);
49     virtual void mousePressEvent(QMouseEvent * event);
50     virtual void mouseReleaseEvent(QMouseEvent * event);
51     virtual void mouseMoveEvent(QMouseEvent * event);
52
53 private:
54     Timecode m_timecode;
55     CustomTrackView *m_view;
56     int m_zoneStart;
57     int m_zoneEnd;
58     int m_duration;
59     QColor m_bgColor;
60     QColor m_cursorColor;
61     QColor m_zoneColor;
62     double m_textSpacing;
63     double m_factor;
64     double m_scale;
65     int m_offset;
66     RULER_MOVE m_moveCursor;
67     QMenu *m_contextMenu;
68     QAction *m_editGuide;
69     QAction *m_deleteGuide;
70     int m_clickedGuide;
71     /** Used for zooming through vertical move */
72     QPoint m_clickPoint;
73     int m_rate;
74     int m_startRate;
75     MOUSE_MOVE m_mouseMove;
76     QMenu *m_goMenu;
77
78
79 public slots:
80     void slotMoveRuler(int newPos);
81     void slotCursorMoved(int oldpos, int newpos);
82
83 private slots:
84     void slotEditGuide();
85     void slotDeleteGuide();
86     void slotGoToGuide(QAction *act);
87
88 signals:
89     void zoneMoved(int, int);
90     void adjustZoom(int);
91 };
92
93 #endif