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