2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 /** @file src/film_viewer.h
21 * @brief A wx widget to view `thumbnails' of a Film.
30 class RGBPlusAlphaImage;
34 * @brief A wx widget to view a preview of a Film.
36 * The film takes the following path through the viewer:
38 * 1. get_frame() asks our _player to decode some data. If it does, process_video()
41 * 2. process_video() takes the image and subtitle from the decoder (_raw_frame and _raw_sub)
42 * and calls raw_to_display().
44 * 3. raw_to_display() copies _raw_frame to _display_frame, processing it and scaling it.
46 * 4. calling _panel->Refresh() and _panel->Update() results in paint_panel() being called;
47 * this creates frame_bitmap from _display_frame and blits it to the display. It also
48 * blits the subtitle, if required.
50 * update_from_decoder() asks the player to re-emit its current frame on the next pass(), and then
51 * starts from step #1.
53 * update_from_raw() starts at step #3, then calls _panel->Refresh and _panel->Update.
55 class FilmViewer : public wxPanel
58 FilmViewer (boost::shared_ptr<Film>, wxWindow *);
60 void set_film (boost::shared_ptr<Film>);
63 void film_changed (Film::Property);
64 void film_content_changed (boost::weak_ptr<Content>, int);
65 void paint_panel (wxPaintEvent &);
66 void panel_sized (wxSizeEvent &);
67 void slider_moved (wxScrollEvent &);
68 void play_clicked (wxCommandEvent &);
69 void timer (wxTimerEvent &);
70 void process_video (boost::shared_ptr<const Image>, bool, boost::shared_ptr<Subtitle>, double);
71 void calculate_sizes ();
72 void check_play_state ();
73 void update_from_raw ();
74 void update_from_decoder ();
75 void raw_to_display ();
77 void active_jobs_changed (bool);
78 void back_clicked (wxCommandEvent &);
79 void forward_clicked (wxCommandEvent &);
81 boost::shared_ptr<Film> _film;
82 boost::shared_ptr<Player> _player;
87 wxButton* _back_button;
88 wxButton* _forward_button;
90 wxStaticText* _timecode;
91 wxToggleButton* _play_button;
94 boost::shared_ptr<const Image> _raw_frame;
95 boost::shared_ptr<Subtitle> _raw_sub;
96 boost::shared_ptr<const Image> _display_frame;
97 /* The x offset at which we display the actual film content; this corresponds
98 to the film's padding converted to our coordinates.
100 int _display_frame_x;
101 boost::shared_ptr<RGBPlusAlphaImage> _display_sub;
102 Position _display_sub_position;
105 /** Size of our output (including padding if we have any) */
106 libdcp::Size _out_size;
107 /** Size that we will make our film (equal to _out_size unless we have padding) */
108 libdcp::Size _film_size;
109 /** Size of the panel that we have available */
110 libdcp::Size _panel_size;