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