]> git.sesse.net Git - nageru/blob - mainwindow.h
Move transitioning to the next clip away from the done callback.
[nageru] / mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3
4 #include <stdbool.h>
5 #include <sys/types.h>
6
7 #include <QLabel>
8 #include <QMainWindow>
9
10 #include "clip_list.h"
11 #include "db.h"
12 #include "state.pb.h"
13
14 namespace Ui {
15 class MainWindow;
16 }  // namespace Ui
17
18 class Player;
19
20 class MainWindow : public QMainWindow
21 {
22         Q_OBJECT
23
24 public:
25         MainWindow();
26
27 //private:
28         Ui::MainWindow *ui;
29
30 private:
31         QLabel *disk_free_label;
32         Player *preview_player, *live_player;
33         DB db;
34
35         // State when doing a scrub operation on a timestamp with the mouse.
36         bool scrubbing = false;
37         int scrub_x_origin;  // In pixels on the viewport.
38         int64_t scrub_pts_origin;
39
40         // Which element (e.g. pts_in on clip 4) we are scrubbing.
41         enum ScrubType { SCRUBBING_CLIP_LIST, SCRUBBING_PLAYLIST } scrub_type;
42         int scrub_row;
43         int scrub_column;
44
45         // Used to keep track of small mouse wheel motions on the camera index in the playlist.
46         int last_mousewheel_camera_row = -1;
47         int leftover_angle_degrees = 0;
48
49         // Some operations, notably scrubbing and scrolling, happen in so large increments
50         // that we want to group them instead of saving to disk every single time.
51         // If they happen (ie., we get a callback from the model that it's changed) while
52         // currently_deferring_model_changes, we fire off this timer. If it manages to elapse
53         // before some other event happens, we count the event. (If the other event is of the
54         // same kind, we just fire off the timer anew instead of taking any action.)
55         QTimer *defer_timeout;
56         std::string deferred_change_id;
57         StateProto deferred_state;
58
59         // Before a change that should be deferred (see above), currently_deferring_model_changes
60         // must be set to true, and current_change_id must be given contents describing what's
61         // changed to avoid accidental grouping.
62         bool currently_deferring_model_changes = false;
63         std::string current_change_id;
64
65         void cue_in_clicked();
66         void cue_out_clicked();
67         void queue_clicked();
68         void preview_clicked();
69         void preview_angle_clicked(unsigned stream_idx);
70         void play_clicked();
71         void live_player_clip_done();
72         Clip live_player_get_next_clip();
73         void live_player_clip_progress(double played_this_clip, double total_length);
74         void playlist_duplicate();
75         void playlist_remove();
76         void playlist_move(int delta);
77
78         void defer_timer_expired();
79         void content_changed();  // In clip_list or play_list.
80         void state_changed(const StateProto &state);  // Called post-filtering.
81
82         enum Rounding { FIRST_AT_OR_AFTER, LAST_BEFORE };
83         void preview_single_frame(int64_t pts, unsigned stream_idx, Rounding rounding);
84
85         // Also covers when the playlist itself changes.
86         void playlist_selection_changed();
87
88         void resizeEvent(QResizeEvent *event) override;
89         bool eventFilter(QObject *watched, QEvent *event) override;
90
91         void report_disk_space(off_t free_bytes, double estimated_seconds_left);
92         void exit_triggered();
93
94 private slots:
95         void relayout();
96 };
97
98 extern MainWindow *global_mainwindow;
99
100 #endif
101