Olive
timeline.h
1 #ifndef TIMELINE_H
2 #define TIMELINE_H
3 
4 #include "ui/timelinetools.h"
5 #include "project/selection.h"
6 
7 #include <QDockWidget>
8 #include <QVector>
9 #include <QTime>
10 
11 #define TRACK_DEFAULT_HEIGHT 40
12 
13 #define ADD_OBJ_TITLE 0
14 #define ADD_OBJ_SOLID 1
15 #define ADD_OBJ_BARS 2
16 #define ADD_OBJ_TONE 3
17 #define ADD_OBJ_NOISE 4
18 #define ADD_OBJ_AUDIO 5
19 
20 class QPushButton;
21 class SourceTable;
22 class ViewerWidget;
23 class ComboAction;
24 class Effect;
25 class Media;
26 class Transition;
27 class TimelineHeader;
28 class TimelineWidget;
29 class ResizableScrollBar;
30 class AudioMonitor;
31 class QScrollBar;
32 struct EffectMeta;
33 struct Sequence;
34 class Clip;
35 struct Footage;
36 struct FootageStream;
37 
38 bool is_clip_selected(Clip* clip, bool containing);
39 int getScreenPointFromFrame(double zoom, long frame);
40 long getFrameFromScreenPoint(double zoom, int x);
41 bool selection_contains_transition(const Selection& s, Clip* c, int type);
42 void move_clip(ComboAction *ca, Clip *c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions = true, bool relative = false);
43 void ripple_clips(ComboAction *ca, Sequence* s, long point, long length, const QVector<int>& ignore = QVector<int>());
44 
45 struct Ghost {
46  int clip;
47  long in;
48  long out;
49  int track;
50  long clip_in;
51 
52  long old_in;
53  long old_out;
54  int old_track;
55  long old_clip_in;
56 
57  // importing variables
58  Media* media;
59  int media_stream;
60 
61  // other variables
62  long ghost_length;
63  long media_length;
64  bool trim_in;
65  bool trimming;
66 
67  // transition trimming
68  Transition* transition;
69 };
70 
71 class Timeline : public QDockWidget
72 {
73  Q_OBJECT
74 public:
75  explicit Timeline(QWidget *parent = nullptr);
76  ~Timeline();
77 
78  bool focused();
79  void set_zoom(bool in);
80  void copy(bool del);
81  Clip* split_clip(ComboAction* ca, bool transitions, int p, long frame);
82  Clip* split_clip(ComboAction* ca, bool transitions, int p, long frame, long post_in);
83  bool split_selection(ComboAction* ca);
84  bool split_all_clips_at_point(ComboAction *ca, long point);
85  bool split_clip_and_relink(ComboAction* ca, int clip, long frame, bool relink);
86  void clean_up_selections(QVector<Selection>& areas);
87  void deselect_area(long in, long out, int track);
88  void delete_areas_and_relink(ComboAction *ca, QVector<Selection>& areas, bool deselect_areas);
89  void relink_clips_using_ids(QVector<int>& old_clips, QVector<Clip*>& new_clips);
90  void update_sequence();
91 
92  QVector<int> get_tracks_of_linked_clips(int i);
93  bool has_clip_been_split(int c);
94  void edit_to_point_internal(bool in, bool ripple);
95  void delete_in_out_internal(bool ripple);
96 
97  void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<Media *> &media_list);
98  void add_clips_from_ghosts(ComboAction *ca, Sequence *s);
99 
100  int getTimelineScreenPointFromFrame(long frame);
101  long getTimelineFrameFromScreenPoint(int x);
102  int getDisplayScreenPointFromFrame(long frame);
103  long getDisplayFrameFromScreenPoint(int x);
104 
105  int get_snap_range();
106  bool snap_to_point(long point, long* l);
107  bool snap_to_timeline(long* l, bool use_playhead, bool use_markers, bool use_workarea);
108  void set_marker();
109 
110  // shared information
111  int tool;
112  long cursor_frame;
113  int cursor_track;
114  double zoom;
115  bool zoom_just_changed;
116  long drag_frame_start;
117  int drag_track_start;
118  void update_effect_controls();
119  bool showing_all;
120  double old_zoom;
121 
122  QVector<int> video_track_heights;
123  QVector<int> audio_track_heights;
124  int get_track_height_size(bool video);
125  int calculate_track_height(int track, int height);
126 
127  // snapping
128  bool snapping;
129  bool snapped;
130  long snap_point;
131 
132  // selecting functions
133  bool selecting;
134  int selection_offset;
135  void delete_selection(QVector<Selection> &selections, bool ripple);
136  void select_all();
137  bool rect_select_init;
138  bool rect_select_proc;
139  int rect_select_x;
140  int rect_select_y;
141  int rect_select_w;
142  int rect_select_h;
143 
144  // moving
145  bool moving_init;
146  bool moving_proc;
147  QVector<Ghost> ghosts;
148  bool video_ghosts;
149  bool audio_ghosts;
150  bool move_insert;
151 
152  // trimming
153  int trim_target;
154  bool trim_in_point;
155  int transition_select;
156 
157  // splitting
158  bool splitting;
159  QVector<int> split_tracks;
160  QVector<int> split_cache;
161 
162  // importing
163  bool importing;
164  bool importing_files;
165 
166  // creating variables
167  bool creating;
168  int creating_object;
169 
170  // transition variables
171  bool transition_tool_init;
172  bool transition_tool_proc;
173  int transition_tool_pre_clip;
174  int transition_tool_post_clip;
175  int transition_tool_type;
176  const EffectMeta* transition_tool_meta;
177  int transition_tool_side;
178 
179  // hand tool variables
180  bool hand_moving;
181  int drag_x_start;
182  int drag_y_start;
183 
184  bool block_repaints;
185 
186  TimelineHeader* headers;
187  AudioMonitor* audio_monitor;
188  ResizableScrollBar* horizontalScrollBar;
189 
190  QPushButton* toolArrowButton;
191  QPushButton* toolEditButton;
192  QPushButton* toolRippleButton;
193  QPushButton* toolRazorButton;
194  QPushButton* toolSlipButton;
195  QPushButton* toolSlideButton;
196  QPushButton* toolHandButton;
197  QPushButton* toolTransitionButton;
198  QPushButton* snappingButton;
199 
200  void scroll_to_frame(long frame);
201  void select_from_playhead();
202 
203  bool can_ripple_empty_space(long frame, int track);
204 
205  void resizeEvent(QResizeEvent *event);
206 public slots:
207  void paste(bool insert = false);
208  void repaint_timeline();
209  void toggle_show_all();
210  void deselect();
211  void toggle_links();
212  void split_at_playhead();
213  void ripple_delete();
214  void ripple_delete_empty_space();
215  void toggle_enable_on_selected_clips();
216 
217  void delete_inout();
218  void ripple_delete_inout();
219 
220  void ripple_to_in_point();
221  void ripple_to_out_point();
222  void edit_to_in_point();
223  void edit_to_out_point();
224 
225  void increase_track_height();
226  void decrease_track_height();
227 
228  void previous_cut();
229  void next_cut();
230 
231  void add_transition();
232 
233  void nest();
234 
235 private slots:
236  void zoom_in();
237  void zoom_out();
238  void snapping_clicked(bool checked);
239  void add_btn_click();
240  void add_menu_item(QAction*);
241  void setScroll(int);
242  void record_btn_click();
243  void transition_tool_click();
244  void transition_menu_select(QAction*);
245  void resize_move(double d);
246  void set_tool();
247 
248 private:
249  void set_zoom_value(double v);
250  QVector<QPushButton*> tool_buttons;
251  void decheck_tool_buttons(QObject* sender);
252  void set_tool(int tool);
253  int scroll;
254  void set_sb_max();
255 
256  void setup_ui();
257 
258  int default_track_height;
259 
260  // ripple delete empty space variables
261  long rc_ripple_min;
262  long rc_ripple_max;
263 
264  QWidget* timeline_area;
265  TimelineWidget* video_area;
266  TimelineWidget* audio_area;
267  QWidget* editAreas;
268  QScrollBar* videoScrollbar;
269  QScrollBar* audioScrollbar;
270  QPushButton* zoomInButton;
271  QPushButton* zoomOutButton;
272  QPushButton* recordButton;
273  QPushButton* addButton;
274  QWidget* tool_button_widget;
275 };
276 
277 #endif // TIMELINE_H
Definition: sequence.h:13
Definition: selection.h:4
Definition: sourcetable.h:11
Definition: undo.h:32
Definition: audiomonitor.h:7
Definition: effect.h:146
Definition: effect.h:27
Definition: timelinewidget.h:27
Definition: timeline.h:71
Definition: timelineheader.h:11
Definition: media.h:20
Definition: footage.h:25
Definition: viewerwidget.h:24
Definition: resizablescrollbar.h:6
Definition: timeline.h:45
Definition: clip.h:33
Definition: transition.h:19
Definition: footage.h:46