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