Initial and not-working information panel in player.
[dcpomatic.git] / src / wx / film_viewer.h
1 /*
2     Copyright (C) 2012-2017 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 /** @file  src/film_viewer.h
22  *  @brief A wx widget to view `thumbnails' of a Film.
23  */
24
25 #include "lib/film.h"
26 #include "lib/config.h"
27 #include <RtAudio.h>
28 #include <wx/wx.h>
29
30 class wxToggleButton;
31 class FFmpegPlayer;
32 class Image;
33 class RGBPlusAlphaImage;
34 class PlayerVideo;
35 class Player;
36 class Butler;
37
38 /** @class FilmViewer
39  *  @brief A wx widget to view a preview of a Film.
40  */
41 class FilmViewer : public wxPanel
42 {
43 public:
44         FilmViewer (wxWindow *, bool outline_content = true, bool jump_to_selected = true);
45         ~FilmViewer ();
46
47         void set_film (boost::shared_ptr<Film>);
48         boost::shared_ptr<Film> film () const {
49                 return _film;
50         }
51
52         /** @return our `playhead' position; this may not lie exactly on a frame boundary */
53         DCPTime position () const {
54                 return _video_position;
55         }
56
57         void set_position (DCPTime p);
58         void set_coalesce_player_changes (bool c);
59
60         void refresh ();
61
62         int audio_callback (void* out, unsigned int frames);
63
64         boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
65
66 private:
67         void paint_panel ();
68         void panel_sized (wxSizeEvent &);
69         void slider_moved (bool update_slider);
70         void play_clicked ();
71         void timer ();
72         void calculate_sizes ();
73         void check_play_state ();
74         void active_jobs_changed (boost::optional<std::string>);
75         void back_clicked (wxMouseEvent &);
76         void forward_clicked (wxMouseEvent &);
77         void player_changed (bool);
78         void update_position_label ();
79         void update_position_slider ();
80         void get ();
81         void seek (DCPTime t, bool accurate);
82         void refresh_panel ();
83         void setup_sensitivity ();
84         void film_changed (Film::Property);
85         DCPTime nudge_amount (wxMouseEvent &);
86         void timecode_clicked ();
87         void frame_number_clicked ();
88         void go_to (DCPTime t);
89         void jump_to_selected_clicked ();
90         void recreate_butler ();
91         void config_changed (Config::Property);
92         DCPTime time () const;
93         void start ();
94         bool stop ();
95         Frame average_latency () const;
96
97         boost::shared_ptr<Film> _film;
98         boost::shared_ptr<Player> _player;
99
100         wxSizer* _v_sizer;
101         wxPanel* _panel;
102         wxCheckBox* _outline_content;
103         wxRadioButton* _left_eye;
104         wxRadioButton* _right_eye;
105         wxCheckBox* _jump_to_selected;
106         wxSlider* _slider;
107         wxButton* _back_button;
108         wxButton* _forward_button;
109         wxStaticText* _frame_number;
110         wxStaticText* _timecode;
111         wxToggleButton* _play_button;
112         wxTimer _timer;
113         bool _coalesce_player_changes;
114         bool _pending_player_change;
115
116         boost::shared_ptr<const Image> _frame;
117         DCPTime _video_position;
118         Position<int> _inter_position;
119         dcp::Size _inter_size;
120
121         /** Size of our output (including padding if we have any) */
122         dcp::Size _out_size;
123         /** Size of the panel that we have available */
124         dcp::Size _panel_size;
125         /** true if the last call to Player::seek() was specified to be accurate;
126          *  this is used so that when re-fetching the current frame we
127          *  can get the same one that we got last time.
128          */
129         bool _last_seek_accurate;
130
131         RtAudio _audio;
132         int _audio_channels;
133         unsigned int _audio_block_size;
134         bool _playing;
135         boost::shared_ptr<Butler> _butler;
136
137         std::list<Frame> _latency_history;
138         /** Mutex to protect _latency_history */
139         mutable boost::mutex _latency_history_mutex;
140         int _latency_history_count;
141
142         boost::signals2::scoped_connection _config_changed_connection;
143 };