377960425ba2807e5982ede7f25ffd4ec8e376a5
[dcpomatic.git] / src / wx / controls.h
1 /*
2     Copyright (C) 2018-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 #ifndef DCPOMATIC_CONTROLS_H
23 #define DCPOMATIC_CONTROLS_H
24
25
26 #include "lib/dcpomatic_time.h"
27 #include "lib/types.h"
28 #include "lib/film.h"
29 #include "lib/warnings.h"
30 DCPOMATIC_DISABLE_WARNINGS
31 #include <wx/wx.h>
32 DCPOMATIC_ENABLE_WARNINGS
33 #include <boost/signals2.hpp>
34
35
36 class FilmViewer;
37 class Film;
38 class ClosedCaptionsDialog;
39 class Content;
40 class PlayerVideo;
41 class wxToggleButton;
42 class wxListCtrl;
43 class ContentView;
44
45
46 namespace dcp {
47         class CPL;
48 }
49
50
51 class Controls : public wxPanel
52 {
53 public:
54         Controls (
55                 wxWindow* parent,
56                 std::shared_ptr<FilmViewer>,
57                 bool editor_controls = true
58                 );
59
60         virtual void log (wxString) {}
61         virtual void set_film (std::shared_ptr<Film> film);
62
63         virtual void play () {};
64         virtual void stop () {};
65         void seek (int slider);
66
67         std::shared_ptr<Film> film () const;
68         void back_frame ();
69         void forward_frame ();
70
71 protected:
72
73         virtual void started ();
74         virtual void stopped ();
75         virtual void setup_sensitivity ();
76         virtual void config_changed (int property);
77
78         wxSizer* _v_sizer;
79         wxBoxSizer* _button_sizer;
80         std::shared_ptr<Film> _film;
81         wxSlider* _slider;
82         std::weak_ptr<FilmViewer> _viewer;
83         boost::optional<std::string> _active_job;
84
85 private:
86
87         void update_position_label ();
88         void update_position_slider ();
89         void rewind_clicked (wxMouseEvent &);
90         void back_clicked (wxKeyboardState& s);
91         void forward_clicked (wxKeyboardState &);
92         void slider_moved (bool page);
93         void slider_released ();
94         void frame_number_clicked ();
95         void jump_to_selected_clicked ();
96         void timecode_clicked ();
97         void active_jobs_changed (boost::optional<std::string>);
98         dcpomatic::DCPTime nudge_amount (wxKeyboardState& ev);
99         void image_changed (std::weak_ptr<PlayerVideo>);
100         void outline_content_changed ();
101         void eye_changed ();
102         void update_position ();
103         void film_change (ChangeType, Film::Property);
104
105         typedef std::pair<std::shared_ptr<dcp::CPL>, boost::filesystem::path> CPL;
106
107         bool _slider_being_moved;
108
109         wxCheckBox* _outline_content;
110         wxChoice* _eye;
111         wxCheckBox* _jump_to_selected;
112         wxButton* _rewind_button;
113         wxButton* _back_button;
114         wxButton* _forward_button;
115         wxStaticText* _frame_number;
116         wxStaticText* _timecode;
117
118         ClosedCaptionsDialog* _closed_captions_dialog;
119
120         wxTimer _timer;
121
122         boost::signals2::scoped_connection _film_change_connection;
123         boost::signals2::scoped_connection _config_changed_connection;
124 };
125
126
127 #endif