Add new interface for setting reel breaks (#2678).
[dcpomatic.git] / src / wx / dcp_timeline.h
1 /*
2     Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #ifndef DCPOMATIC_DCP_TIMELINE_H
23 #define DCPOMATIC_DCP_TIMELINE_H
24
25
26 #include "timecode.h"
27 #include "timeline.h"
28 #include "lib/rect.h"
29 #include <dcp/warnings.h>
30 LIBDCP_DISABLE_WARNINGS
31 #include <wx/wx.h>
32 LIBDCP_ENABLE_WARNINGS
33 #include <memory>
34
35
36 class CheckBox;
37 class Choice;
38 class Film;
39 class ReelBoundary;
40 class SpinCtrl;
41 class wxGridBagSizer;
42
43
44 class DCPTimeline : public Timeline
45 {
46 public:
47         DCPTimeline(wxWindow* parent, std::shared_ptr<Film> film);
48
49         void force_redraw(dcpomatic::Rect<int> const &);
50
51 private:
52         void paint();
53         void paint_reels(wxGraphicsContext* gc);
54         void paint_content(wxGraphicsContext* gc);
55         void setup_pixels_per_second();
56         void left_down(wxMouseEvent& ev);
57         void right_down(wxMouseEvent& ev);
58         void left_up(wxMouseEvent& ev);
59         void mouse_moved(wxMouseEvent& ev);
60         void reel_mode_changed();
61         void maximum_reel_size_changed();
62         void film_changed(ChangeType type, FilmProperty property);
63         std::shared_ptr<Film> film() const;
64         void setup_sensitivity();
65
66         void add_reel_boundary();
67         void setup_reel_settings();
68         void setup_reel_boundaries();
69         std::shared_ptr<ReelBoundary> event_to_reel_boundary(wxMouseEvent& ev) const;
70         void set_reel_boundary(int index, dcpomatic::DCPTime time);
71         bool editable() const;
72
73         std::weak_ptr<Film> _film;
74
75         wxScrolledCanvas* _canvas;
76
77         class Drag
78         {
79         public:
80                 Drag(
81                         std::shared_ptr<ReelBoundary> reel_boundary_,
82                         std::vector<std::shared_ptr<ReelBoundary>> const& reel_boundaries,
83                         std::shared_ptr<const Film> film,
84                         int offset_,
85                         bool snap,
86                         dcpomatic::DCPTime snap_distance
87                     );
88
89                 std::shared_ptr<ReelBoundary> reel_boundary;
90                 std::shared_ptr<ReelBoundary> previous;
91                 std::shared_ptr<ReelBoundary> next;
92                 int offset = 0;
93
94                 void set_time(dcpomatic::DCPTime time);
95                 dcpomatic::DCPTime time() const;
96
97         private:
98                 std::vector<dcpomatic::DCPTime> _snaps;
99                 dcpomatic::DCPTime _snap_distance;
100         };
101
102         boost::optional<Drag> _drag;
103
104         wxPoint _right_down_position;
105
106         wxPanel* _reel_settings;
107         Choice* _reel_type;
108         SpinCtrl* _maximum_reel_size;
109         CheckBox* _snap;
110         wxPanel* _reel_detail;
111         wxGridBagSizer* _reel_detail_sizer;
112
113         wxMenu* _menu;
114         wxMenuItem* _add_reel_boundary;
115
116         boost::signals2::scoped_connection _film_connection;
117
118         std::vector<std::shared_ptr<ReelBoundary>> _reel_boundaries;
119 };
120
121
122 #endif
123