Initial butler work.
[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 <wx/wx.h>
27
28 class wxToggleButton;
29 class FFmpegPlayer;
30 class Image;
31 class RGBPlusAlphaImage;
32 class PlayerVideo;
33 class Player;
34 class Butler;
35
36 /** @class FilmViewer
37  *  @brief A wx widget to view a preview of a Film.
38  */
39 class FilmViewer : public wxPanel
40 {
41 public:
42         FilmViewer (wxWindow *);
43
44         void set_film (boost::shared_ptr<Film>);
45
46         /** @return our `playhead' position; this may not lie exactly on a frame boundary */
47         DCPTime position () const {
48                 return _position;
49         }
50
51         void set_position (DCPTime p);
52         void set_coalesce_player_changes (bool c);
53
54         void refresh ();
55
56         boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
57
58 private:
59         void paint_panel ();
60         void panel_sized (wxSizeEvent &);
61         void slider_moved ();
62         void play_clicked ();
63         void timer ();
64         void calculate_sizes ();
65         void check_play_state ();
66         void active_jobs_changed (boost::optional<std::string>);
67         void back_clicked (wxMouseEvent &);
68         void forward_clicked (wxMouseEvent &);
69         void player_changed (bool);
70         void update_position_label ();
71         void update_position_slider ();
72         void get ();
73         void seek (DCPTime t, bool accurate);
74         void refresh_panel ();
75         void setup_sensitivity ();
76         void film_changed (Film::Property);
77         DCPTime nudge_amount (wxMouseEvent &);
78         void timecode_clicked ();
79         void frame_number_clicked ();
80         void go_to (DCPTime t);
81         void jump_to_selected_clicked ();
82         void recreate_butler ();
83
84         boost::shared_ptr<Film> _film;
85         boost::shared_ptr<Player> _player;
86
87         wxSizer* _v_sizer;
88         wxPanel* _panel;
89         wxCheckBox* _outline_content;
90         wxRadioButton* _left_eye;
91         wxRadioButton* _right_eye;
92         wxCheckBox* _jump_to_selected;
93         wxSlider* _slider;
94         wxButton* _back_button;
95         wxButton* _forward_button;
96         wxStaticText* _frame_number;
97         wxStaticText* _timecode;
98         wxToggleButton* _play_button;
99         wxTimer _timer;
100         bool _coalesce_player_changes;
101         bool _pending_player_change;
102
103         boost::shared_ptr<const Image> _frame;
104         DCPTime _position;
105         Position<int> _inter_position;
106         dcp::Size _inter_size;
107
108         /** Size of our output (including padding if we have any) */
109         dcp::Size _out_size;
110         /** Size of the panel that we have available */
111         dcp::Size _panel_size;
112         /** true if the last call to Player::seek() was specified to be accurate;
113          *  this is used so that when re-fetching the current frame we
114          *  can get the same one that we got last time.
115          */
116         bool _last_seek_accurate;
117
118         boost::shared_ptr<Butler> _butler;
119 };