Bump version
[dcpomatic.git] / src / wx / film_viewer.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file  src/film_viewer.h
21  *  @brief A wx widget to view `thumbnails' of a Film.
22  */
23
24 #include <wx/wx.h>
25 #include "lib/film.h"
26 #include "lib/decoder_factory.h"
27
28 class wxToggleButton;
29 class FFmpegPlayer;
30 class Image;
31 class RGBPlusAlphaImage;
32 class Subtitle;
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 (boost::shared_ptr<Film>, wxWindow *);
41
42         void set_film (boost::shared_ptr<Film>);
43
44 private:
45         void film_changed (Film::Property);
46         void paint_panel (wxPaintEvent &);
47         void panel_sized (wxSizeEvent &);
48         void slider_moved (wxScrollEvent &);
49         void play_clicked (wxCommandEvent &);
50         void timer (wxTimerEvent &);
51         void process_video (boost::shared_ptr<const Image>, bool, boost::shared_ptr<Subtitle>, double);
52         void calculate_sizes ();
53         void check_play_state ();
54         void update_from_raw ();
55         void decoder_changed ();
56         void raw_to_display ();
57         void get_frame ();
58         void active_jobs_changed (bool);
59         void back_clicked (wxCommandEvent &);
60         void forward_clicked (wxCommandEvent &);
61
62         boost::shared_ptr<Film> _film;
63
64         wxSizer* _v_sizer;
65         wxPanel* _panel;
66         wxSlider* _slider;
67         wxButton* _back_button;
68         wxButton* _forward_button;
69         wxStaticText* _frame;
70         wxStaticText* _timecode;
71         wxToggleButton* _play_button;
72         wxTimer _timer;
73
74         Decoders _decoders;
75         boost::shared_ptr<const Image> _raw_frame;
76         boost::shared_ptr<Subtitle> _raw_sub;
77         boost::shared_ptr<const Image> _display_frame;
78         /* The x offset at which we display the actual film content; this corresponds
79            to the film's padding converted to our coordinates.
80         */
81         int _display_frame_x;
82         boost::shared_ptr<RGBPlusAlphaImage> _display_sub;
83         Position _display_sub_position;
84         bool _got_frame;
85
86         /** Size of our output (including padding if we have any) */
87         libdcp::Size _out_size;
88         /** Size that we will make our film (equal to _out_size unless we have padding) */
89         libdcp::Size _film_size;
90         /** Size of the panel that we have available */
91         libdcp::Size _panel_size;
92 };