Olive
viewer.h
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 VIEWER_H
22 #define VIEWER_H
23 
24 #include <QDockWidget>
25 #include <QTimer>
26 #include <QIcon>
27 
28 class Timeline;
29 class Media;
30 struct Sequence;
31 class TimelineHeader;
32 class ResizableScrollBar;
33 class ViewerContainer;
34 class LabelSlider;
35 class QPushButton;
36 class QLabel;
37 
38 #include "project/marker.h"
39 #include "ui/viewerwidget.h"
40 
41 bool frame_rate_is_droppable(float rate);
42 long timecode_to_frame(const QString& s, int view, double frame_rate);
43 QString frame_to_timecode(long f, int view, double frame_rate);
44 
45 class Viewer : public QDockWidget
46 {
47  Q_OBJECT
48 
49 public:
50  explicit Viewer(QWidget *parent = nullptr);
51  ~Viewer();
52 
53  bool is_focused();
54  bool is_main_sequence();
55  void set_main_sequence();
56  void set_media(Media *m);
57  void compose();
58  void set_playpause_icon(bool play);
59  void update_playhead_timecode(long p);
60  void update_end_timecode();
61  void update_header_zoom();
62  void clear_in();
63  void clear_out();
64  void clear_inout_point();
65  void set_in_point();
66  void set_out_point();
67  void set_zoom(bool in);
68  void set_panel_name(const QString& n);
69 
70  // playback functions
71  void seek(long p);
72  void play(bool in_to_out = false);
73  void pause();
74  bool playing;
75  long playhead_start;
76  qint64 start_msecs;
77  QTimer playback_updater;
78  bool just_played;
79 
80  void cue_recording(long start, long end, int track);
81  void uncue_recording();
82  bool is_recording_cued();
83  long recording_start;
84  long recording_end;
85  int recording_track;
86 
87  void reset_all_audio();
88  void update_parents(bool reload_fx = false);
89 
90  int get_playback_speed();
91 
92  ViewerWidget* viewer_widget;
93 
94  Media* media;
95  Sequence* seq;
96  QVector<Marker>* marker_ref;
97 
98  void set_marker();
99 
100  TimelineHeader* headers;
101 
102  void resizeEvent(QResizeEvent *event);
103 
104 public slots:
105  void play_wake();
106  void go_to_start();
107  void go_to_in();
108  void previous_frame();
109  void toggle_play();
110  void increase_speed();
111  void decrease_speed();
112  void next_frame();
113  void go_to_out();
114  void go_to_end();
115  void close_media();
116  void update_viewer();
117 
118 private slots:
119  void update_playhead();
120  void timer_update();
121  void recording_flasher_update();
122  void resize_move(double d);
123 
124 private:
125  void update_window_title();
126  void clean_created_seq();
127  void set_sequence(bool main, Sequence* s);
128  bool main_sequence;
129  bool created_sequence;
130  long cached_end_frame;
131  QString panel_name;
132  double minimum_zoom;
133  bool playing_in_to_out;
134  long last_playhead;
135  void set_zoom_value(double d);
136  void set_sb_max();
137  void set_playback_speed(int s);
138 
139  long get_seq_in();
140  long get_seq_out();
141 
142  QIcon playIcon;
143 
144  void setup_ui();
145 
146  ResizableScrollBar* horizontal_bar;
147  ViewerContainer* viewer_container;
148  LabelSlider* current_timecode_slider;
149  QLabel* end_timecode;
150 
151  QPushButton* go_to_start_button;
152  QPushButton* prev_frame_button;
153  QPushButton* play_button;
154  QPushButton* next_frame_button;
155  QPushButton* go_to_end_frame;
156 
157  bool cue_recording_internal;
158  QTimer recording_flasher;
159 
160  long previous_playhead;
161  int playback_speed;
162 };
163 
164 #endif // VIEWER_H
Definition: sequence.h:33
Definition: viewercontainer.h:29
Definition: timeline.h:91
Definition: timelineheader.h:31
Definition: media.h:40
Definition: viewerwidget.h:44
The LabelSlider class.
Definition: labelslider.h:40
Definition: resizablescrollbar.h:26
Definition: viewer.h:45