Remove old Connect() wxWidgets API and use Bind().
[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
27 class wxToggleButton;
28 class FFmpegPlayer;
29 class Image;
30 class RGBPlusAlphaImage;
31
32 /** @class FilmViewer
33  *  @brief A wx widget to view a preview of a Film.
34  *
35  *  The film takes the following path through the viewer:
36  *
37  *  1.  fetch_next_frame() asks our _player to decode some data.  If it does, process_video()
38  *      will be called.
39  *
40  *  2.  process_video() takes the image from the player (_frame).
41  *
42  *  3.  fetch_next_frame() calls _panel->Refresh() and _panel->Update() which results in
43  *      paint_panel() being called; this creates frame_bitmap from _frame and blits it to the display.
44  *
45  * fetch_current_frame_again() asks the player to re-emit its current frame on the next pass(), and then
46  * starts from step #1.
47  */
48 class FilmViewer : public wxPanel
49 {
50 public:
51         FilmViewer (boost::shared_ptr<Film>, wxWindow *);
52
53         void set_film (boost::shared_ptr<Film>);
54
55 private:
56         void paint_panel ();
57         void panel_sized (wxSizeEvent &);
58         void slider_moved ();
59         void play_clicked ();
60         void timer ();
61         void process_video (boost::shared_ptr<const Image>, Eyes, Time);
62         void calculate_sizes ();
63         void check_play_state ();
64         void fetch_current_frame_again ();
65         void fetch_next_frame ();
66         void active_jobs_changed (bool);
67         void back_clicked ();
68         void forward_clicked ();
69         void player_changed (bool);
70         void set_position_text (Time);
71
72         boost::shared_ptr<Film> _film;
73         boost::shared_ptr<Player> _player;
74
75         wxSizer* _v_sizer;
76         wxPanel* _panel;
77         wxSlider* _slider;
78         wxButton* _back_button;
79         wxButton* _forward_button;
80         wxStaticText* _frame_number;
81         wxStaticText* _timecode;
82         wxToggleButton* _play_button;
83         wxTimer _timer;
84
85         boost::shared_ptr<const Image> _frame;
86         bool _got_frame;
87
88         /** Size of our output (including padding if we have any) */
89         libdcp::Size _out_size;
90         /** Size of the panel that we have available */
91         libdcp::Size _panel_size;
92
93         std::list<std::pair<boost::shared_ptr<const Image>, Time> > _queue;
94 };