Basic display of markers above the playback timeline (#1921).
[dcpomatic.git] / src / wx / markers_panel.h
1 /*
2     Copyright (C) 2021 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 #include "lib/dcpomatic_time.h"
23 #include "lib/film.h"
24 #include <wx/wx.h>
25 #include <map>
26
27
28 class wxTipWindow;
29
30
31 class MarkersPanel : public wxPanel
32 {
33 public:
34         MarkersPanel (wxWindow* parent, std::weak_ptr<FilmViewer> viewer);
35
36         void set_film (std::weak_ptr<Film> film);
37
38 private:
39         void paint ();
40         void mouse_moved (wxMouseEvent& ev);
41         void mouse_left_down ();
42         void mouse_right_down (wxMouseEvent& ev);
43         int position (dcpomatic::DCPTime time, int width) const;
44         void move_marker_to_current_position ();
45         void remove_marker ();
46         void add_marker (wxCommandEvent& ev);
47         void film_changed (ChangeType type, Film::Property property);
48         void update_from_film (std::shared_ptr<Film> film);
49
50         wxTipWindow* _tip = nullptr;
51
52         class Marker {
53         public:
54                 Marker () {}
55
56                 Marker (dcpomatic::DCPTime t, bool b)
57                         : time (t)
58                         , line_before_label (b)
59                 {}
60
61                 dcpomatic::DCPTime time;
62                 int width = 0;
63                 bool line_before_label = false;
64         };
65
66         std::weak_ptr<Film> _film;
67         std::map<dcp::Marker, Marker> _markers;
68         boost::optional<dcp::Marker> _over;
69         std::weak_ptr<FilmViewer> _viewer;
70         boost::optional<dcp::Marker> _menu_marker;
71 };
72