Olive
timelinewidget.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
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  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef TIMELINEWIDGET_H
22 #define TIMELINEWIDGET_H
23 
24 #include <QTimer>
25 #include <QWidget>
26 #include <QScrollBar>
27 #include <QPainter>
28 #include <QApplication>
29 #include <QDesktopWidget>
30 
31 #include "project/sequence.h"
32 #include "project/clip.h"
33 #include "project/footage.h"
34 #include "project/media.h"
35 #include "project/undo.h"
36 #include "timelinetools.h"
37 
38 class Timeline;
39 
40 namespace olive {
41  namespace timeline {
42  const int kGhostThickness = 2;
43  const int kClipTextPadding = 3;
44 
45  const int kTrackDefaultHeight = 40/* * QApplication::desktop()->devicePixelRatio()*/;
46  const int kTrackMinHeight = 30;
47  const int kTrackHeightIncrement = 10;
48  }
49 }
50 
52  int index;
53  int height;
54 };
55 
56 bool same_sign(int a, int b);
57 void draw_waveform(ClipPtr clip, const FootageStream *ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom);
58 
59 class TimelineWidget : public QWidget {
60  Q_OBJECT
61 public:
62  explicit TimelineWidget(QWidget *parent = 0);
63  QScrollBar* scrollBar;
65 
66 public slots:
67 
68 protected:
69  void paintEvent(QPaintEvent*);
70 
71  void resizeEvent(QResizeEvent *event);
72 
73  void mouseDoubleClickEvent(QMouseEvent *event);
74  void mousePressEvent(QMouseEvent *event);
75  void mouseReleaseEvent(QMouseEvent *event);
76  void mouseMoveEvent(QMouseEvent *event);
77  void leaveEvent(QEvent *event);
78 
79  void dragEnterEvent(QDragEnterEvent *event);
80  void dragLeaveEvent(QDragLeaveEvent *event);
81  void dropEvent(QDropEvent* event);
82  void dragMoveEvent(QDragMoveEvent *event);
83 
84  void wheelEvent(QWheelEvent *event);
85 private:
86  void init_ghosts();
87  void update_ghosts(const QPoint& mouse_pos, bool lock_frame);
88  bool is_track_visible(int track);
89  int getTrackFromScreenPoint(int y);
90  int getScreenPointFromTrack(int track);
91  int getClipIndexFromCoords(long frame, int track);
92 
94 
97 
98  QVector<ClipPtr> pre_clips;
99  QVector<ClipPtr> post_clips;
100 
102 
104 
107 
108  int scroll;
109 
111 signals:
112 
113 public slots:
114  void setScroll(int);
115 
116 private slots:
117  void reveal_media();
118  void show_context_menu(const QPoint& pos);
119  void toggle_autoscale();
120  void tooltip_timer_timeout();
121  void rename_clip();
123 };
124 
125 #endif // TIMELINEWIDGET_H
Definition: timelinewidget.h:51
void open_sequence_properties()
Definition: timelinewidget.cpp:244
int getTrackFromScreenPoint(int y)
Definition: timelinewidget.cpp:3342
void wheelEvent(QWheelEvent *event)
Definition: timelinewidget.cpp:357
QTimer tooltip_timer
Definition: timelinewidget.h:105
QScrollBar * scrollBar
Definition: timelinewidget.h:63
void show_context_menu(const QPoint &pos)
Definition: timelinewidget.cpp:84
const int kGhostThickness
Definition: timelinewidget.h:42
int getClipIndexFromCoords(long frame, int track)
Definition: timelinewidget.cpp:3401
void dragMoveEvent(QDragMoveEvent *event)
Definition: timelinewidget.cpp:344
int height
Definition: timelinewidget.h:53
void mouseDoubleClickEvent(QMouseEvent *event)
Definition: timelinewidget.cpp:543
QVector< ClipPtr > pre_clips
Definition: timelinewidget.h:98
void mousePressEvent(QMouseEvent *event)
Definition: timelinewidget.cpp:573
bool same_sign(int a, int b)
Definition: timelinewidget.cpp:261
void rename_clip()
Definition: timelinewidget.cpp:219
int tooltip_clip
Definition: timelinewidget.h:106
int track_target
Definition: timelinewidget.h:96
const int kTrackDefaultHeight
Definition: timelinewidget.h:45
Definition: timelinewidget.h:59
Definition: timeline.h:85
void setScroll(int)
Definition: timelinewidget.cpp:3411
const int kTrackMinHeight
Definition: timelinewidget.h:46
bool is_track_visible(int track)
Definition: timelinewidget.cpp:3334
Definition: debugdialog.h:39
void toggle_autoscale()
Definition: timelinewidget.cpp:186
TimelineWidget(QWidget *parent=0)
Definition: timelinewidget.cpp:66
SequencePtr self_created_sequence
Definition: timelinewidget.h:103
Definition: media.h:42
void mouseMoveEvent(QMouseEvent *event)
Definition: timelinewidget.cpp:1992
std::shared_ptr< Clip > ClipPtr
Definition: cacher.h:28
void mouseReleaseEvent(QMouseEvent *event)
Definition: timelinewidget.cpp:984
void draw_waveform(ClipPtr clip, const FootageStream *ms, long media_length, QPainter *p, const QRect &clip_rect, int waveform_start, int waveform_limit, double zoom)
Definition: timelinewidget.cpp:2792
Definition: undo.h:431
bool bottom_align
Definition: timelinewidget.h:64
const int kClipTextPadding
Definition: timelinewidget.h:43
Definition: footage.h:44
int index
Definition: timelinewidget.h:52
int getScreenPointFromTrack(int track)
Definition: timelinewidget.cpp:3381
std::shared_ptr< Sequence > SequencePtr
Definition: clip.h:48
void init_ghosts()
Definition: timelinewidget.cpp:1545
int scroll
Definition: timelinewidget.h:108
Media * rc_reveal_media
Definition: timelinewidget.h:101
void paintEvent(QPaintEvent *)
Definition: timelinewidget.cpp:2890
void reveal_media()
Definition: timelinewidget.cpp:3416
void update_ghosts(const QPoint &mouse_pos, bool lock_frame)
Definition: timelinewidget.cpp:1616
void tooltip_timer_timeout()
Definition: timelinewidget.cpp:201
void VerifyTransitionHelper()
void dragEnterEvent(QDragEnterEvent *event)
Definition: timelinewidget.cpp:265
const int kTrackHeightIncrement
Definition: timelinewidget.h:47
SetSelectionsCommand * selection_command
Definition: timelinewidget.h:110
QVector< ClipPtr > post_clips
Definition: timelinewidget.h:99
void resizeEvent(QResizeEvent *event)
Definition: timelinewidget.cpp:3330
bool track_resizing
Definition: timelinewidget.h:95
void dropEvent(QDropEvent *event)
Definition: timelinewidget.cpp:514
void dragLeaveEvent(QDragLeaveEvent *event)
Definition: timelinewidget.cpp:404
void leaveEvent(QEvent *event)
Definition: timelinewidget.cpp:2784