diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-09-11 01:25:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-09-11 11:58:15 +0100 |
| commit | c370a1f38215f6461cf4366e6885757e7aa2b96a (patch) | |
| tree | 6d660895988652297260c2434115b903032bc60d /src | |
| parent | 23b60bec13fa8f0b88c34922a169aa0084d99476 (diff) | |
Separate out management of controls.
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/dcpomatic.cc | 14 | ||||
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 34 | ||||
| -rw-r--r-- | src/wx/content_panel.cc | 8 | ||||
| -rw-r--r-- | src/wx/content_panel.h | 8 | ||||
| -rw-r--r-- | src/wx/control_film_viewer.cc | 183 | ||||
| -rw-r--r-- | src/wx/control_film_viewer.h | 21 | ||||
| -rw-r--r-- | src/wx/film_editor.cc | 3 | ||||
| -rw-r--r-- | src/wx/film_editor.h | 4 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 2 | ||||
| -rw-r--r-- | src/wx/film_viewer.h | 1 | ||||
| -rw-r--r-- | src/wx/player_information.cc | 21 | ||||
| -rw-r--r-- | src/wx/player_information.h | 7 | ||||
| -rw-r--r-- | src/wx/text_view.cc | 17 | ||||
| -rw-r--r-- | src/wx/text_view.h | 10 | ||||
| -rw-r--r-- | src/wx/timing_panel.cc | 59 | ||||
| -rw-r--r-- | src/wx/timing_panel.h | 6 | ||||
| -rw-r--r-- | src/wx/video_waveform_dialog.cc | 9 | ||||
| -rw-r--r-- | src/wx/video_waveform_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/video_waveform_plot.cc | 9 | ||||
| -rw-r--r-- | src/wx/video_waveform_plot.h | 4 |
20 files changed, 196 insertions, 230 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 7392c830c..d7862a803 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -23,6 +23,7 @@ */ #include "wx/control_film_viewer.h" +#include "wx/film_viewer.h" #include "wx/film_editor.h" #include "wx/job_manager_view.h" #include "wx/full_config_dialog.h" @@ -317,12 +318,14 @@ public: */ wxPanel* overall_panel = new wxPanel (this, wxID_ANY); - _film_viewer = new ControlFilmViewer (overall_panel); + _film_viewer.reset (new FilmViewer (overall_panel)); + _controls = new Controls (overall_panel, _film_viewer); _film_editor = new FilmEditor (overall_panel, _film_viewer); JobManagerView* job_manager_view = new JobManagerView (overall_panel, false); wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL); - right_sizer->Add (_film_viewer, 2, wxEXPAND | wxALL, 6); + right_sizer->Add (_film_viewer->panel(), 2, wxEXPAND | wxALL, 6); + right_sizer->Add (_controls, 0, wxEXPAND | wxALL, 6); right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6); wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL); @@ -1298,16 +1301,17 @@ private: void back_frame () { - _film_viewer->back_frame (); + _film_viewer->move (-_film_viewer->one_video_frame()); } void forward_frame () { - _film_viewer->forward_frame (); + _film_viewer->move (_film_viewer->one_video_frame()); } FilmEditor* _film_editor; - ControlFilmViewer* _film_viewer; + boost::shared_ptr<FilmViewer> _film_viewer; + Controls* _controls; VideoWaveformDialog* _video_waveform_dialog; HintsDialog* _hints_dialog; ServersListDialog* _servers_list_dialog; diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 03ace74c9..a8895e8e8 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -18,6 +18,17 @@ */ + +#include "wx/wx_signal_manager.h" +#include "wx/wx_util.h" +#include "wx/about_dialog.h" +#include "wx/report_problem_dialog.h" +#include "wx/film_viewer.h" +#include "wx/player_information.h" +#include "wx/update_dialog.h" +#include "wx/player_config_dialog.h" +#include "wx/verify_dcp_dialog.h" +#include "wx/control_film_viewer.h" #include "lib/cross.h" #include "lib/config.h" #include "lib/util.h" @@ -35,15 +46,6 @@ #include "lib/examine_content_job.h" #include "lib/server.h" #include "lib/dcpomatic_socket.h" -#include "wx/wx_signal_manager.h" -#include "wx/wx_util.h" -#include "wx/about_dialog.h" -#include "wx/report_problem_dialog.h" -#include "wx/control_film_viewer.h" -#include "wx/player_information.h" -#include "wx/update_dialog.h" -#include "wx/player_config_dialog.h" -#include "wx/verify_dcp_dialog.h" #include <wx/wx.h> #include <wx/stdpaths.h> #include <wx/splash.h> @@ -109,7 +111,6 @@ public: , _history_items (0) , _history_position (0) , _history_separator (0) - , _viewer (0) { #if defined(DCPOMATIC_WINDOWS) @@ -151,11 +152,13 @@ public: */ wxPanel* overall_panel = new wxPanel (this, wxID_ANY); - _viewer = new ControlFilmViewer (overall_panel, false, false); + _viewer.reset (new FilmViewer (overall_panel)); + _controls = new Controls (overall_panel, _viewer); _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ()); _info = new PlayerInformation (overall_panel, _viewer); wxSizer* main_sizer = new wxBoxSizer (wxVERTICAL); - main_sizer->Add (_viewer, 1, wxEXPAND | wxALL, 6); + main_sizer->Add (_viewer->panel(), 1, wxEXPAND | wxALL, 6); + main_sizer->Add (_controls, 0, wxEXPAND | wxALL, 6); main_sizer->Add (_info, 0, wxEXPAND | wxALL, 6); overall_panel->SetSizer (main_sizer); @@ -576,12 +579,12 @@ private: void back_frame () { - _viewer->back_frame (); + _viewer->move (-_viewer->one_video_frame()); } void forward_frame () { - _viewer->forward_frame (); + _viewer->move (_viewer->one_video_frame()); } private: @@ -649,7 +652,8 @@ private: int _history_items; int _history_position; wxMenuItem* _history_separator; - ControlFilmViewer* _viewer; + shared_ptr<FilmViewer> _viewer; + Controls* _controls; boost::shared_ptr<Film> _film; boost::signals2::scoped_connection _config_changed_connection; wxMenuItem* _file_add_ov; diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index e5990a564..04e35c758 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -26,7 +26,7 @@ #include "timing_panel.h" #include "timeline_dialog.h" #include "image_sequence_dialog.h" -#include "control_film_viewer.h" +#include "film_viewer.h" #include "lib/audio_content.h" #include "lib/text_content.h" #include "lib/video_content.h" @@ -61,7 +61,7 @@ using boost::optional; #define LOG_GENERAL(...) _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); -ContentPanel::ContentPanel (wxNotebook* n, boost::shared_ptr<Film> film, ControlFilmViewer* viewer) +ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer) : _video_panel (0) , _audio_panel (0) , _timeline_dialog (0) @@ -302,7 +302,9 @@ ContentPanel::check_selection () } if (go_to && Config::instance()->jump_to_selected() && signal_manager) { - signal_manager->when_idle(boost::bind(&ControlFilmViewer::set_position, _film_viewer, go_to.get().ceil(_film->video_frame_rate()))); + shared_ptr<FilmViewer> fv = _film_viewer.lock (); + DCPOMATIC_ASSERT (fv); + signal_manager->when_idle(boost::bind(&FilmViewer::set_position, fv.get(), go_to.get().ceil(_film->video_frame_rate()))); } if (_timeline_dialog) { diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index e9f942d09..4a41ad189 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -37,12 +37,12 @@ class VideoPanel; class AudioPanel; class TimingPanel; class Film; -class ControlFilmViewer; +class FilmViewer; class ContentPanel : public boost::noncopyable { public: - ContentPanel (wxNotebook *, boost::shared_ptr<Film>, ControlFilmViewer* viewer); + ContentPanel (wxNotebook *, boost::shared_ptr<Film>, boost::weak_ptr<FilmViewer> viewer); boost::shared_ptr<Film> film () const { return _film; @@ -74,7 +74,7 @@ public: bool remove_clicked (bool hotkey); void timeline_clicked (); - ControlFilmViewer* film_viewer () const { + boost::weak_ptr<FilmViewer> film_viewer () const { return _film_viewer; } @@ -120,7 +120,7 @@ private: wxWindow* _last_selected_tab; boost::shared_ptr<Film> _film; - ControlFilmViewer* _film_viewer; + boost::weak_ptr<FilmViewer> _film_viewer; bool _generally_sensitive; bool _ignore_deselect; }; diff --git a/src/wx/control_film_viewer.cc b/src/wx/control_film_viewer.cc index 739b02765..c0dc53d89 100644 --- a/src/wx/control_film_viewer.cc +++ b/src/wx/control_film_viewer.cc @@ -15,9 +15,9 @@ using boost::weak_ptr; /** @param outline_content true if viewer should present an "outline content" checkbox. * @param jump_to_selected true if viewer should present a "jump to selected" checkbox. */ -ControlFilmViewer::ControlFilmViewer (wxWindow* parent, bool outline_content, bool jump_to_selected) +Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool outline_content, bool jump_to_selected) : wxPanel (parent) - , _viewer (new FilmViewer(this)) + , _viewer (viewer) , _slider_being_moved (false) , _was_running_before_slider (false) , _outline_content (0) @@ -33,7 +33,6 @@ ControlFilmViewer::ControlFilmViewer (wxWindow* parent, bool outline_content, bo { _v_sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_v_sizer); - _v_sizer->Add (_viewer->panel(), 1, wxEXPAND); wxBoxSizer* view_options = new wxBoxSizer (wxHORIZONTAL); if (outline_content) { @@ -74,73 +73,73 @@ ControlFilmViewer::ControlFilmViewer (wxWindow* parent, bool outline_content, bo _back_button->SetMinSize (wxSize (32, -1)); _forward_button->SetMinSize (wxSize (32, -1)); - _eye->Bind (wxEVT_CHOICE, boost::bind (&ControlFilmViewer::eye_changed, this)); + _eye->Bind (wxEVT_CHOICE, boost::bind (&Controls::eye_changed, this)); if (_outline_content) { - _outline_content->Bind (wxEVT_CHECKBOX, boost::bind (&ControlFilmViewer::outline_content_changed, this)); + _outline_content->Bind (wxEVT_CHECKBOX, boost::bind (&Controls::outline_content_changed, this)); } - _slider->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind (&ControlFilmViewer::slider_moved, this, false)); - _slider->Bind (wxEVT_SCROLL_PAGEUP, boost::bind (&ControlFilmViewer::slider_moved, this, true)); - _slider->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind (&ControlFilmViewer::slider_moved, this, true)); - _slider->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind (&ControlFilmViewer::slider_released, this)); - _play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind (&ControlFilmViewer::play_clicked, this)); - _rewind_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&ControlFilmViewer::rewind_clicked, this, _1)); - _back_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&ControlFilmViewer::back_clicked, this, _1)); - _forward_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&ControlFilmViewer::forward_clicked, this, _1)); - _frame_number->Bind (wxEVT_LEFT_DOWN, boost::bind (&ControlFilmViewer::frame_number_clicked, this)); - _timecode->Bind (wxEVT_LEFT_DOWN, boost::bind (&ControlFilmViewer::timecode_clicked, this)); + _slider->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind (&Controls::slider_moved, this, false)); + _slider->Bind (wxEVT_SCROLL_PAGEUP, boost::bind (&Controls::slider_moved, this, true)); + _slider->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind (&Controls::slider_moved, this, true)); + _slider->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind (&Controls::slider_released, this)); + _play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind (&Controls::play_clicked, this)); + _rewind_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::rewind_clicked, this, _1)); + _back_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::back_clicked, this, _1)); + _forward_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::forward_clicked, this, _1)); + _frame_number->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::frame_number_clicked, this)); + _timecode->Bind (wxEVT_LEFT_DOWN, boost::bind (&Controls::timecode_clicked, this)); if (_jump_to_selected) { - _jump_to_selected->Bind (wxEVT_CHECKBOX, boost::bind (&ControlFilmViewer::jump_to_selected_clicked, this)); + _jump_to_selected->Bind (wxEVT_CHECKBOX, boost::bind (&Controls::jump_to_selected_clicked, this)); _jump_to_selected->SetValue (Config::instance()->jump_to_selected ()); } - _viewer->ImageChanged.connect (boost::bind(&ControlFilmViewer::image_changed, this, _1)); - _viewer->PositionChanged.connect (boost::bind(&ControlFilmViewer::position_changed, this)); - _viewer->Started.connect (boost::bind(&ControlFilmViewer::started, this)); - _viewer->Stopped.connect (boost::bind(&ControlFilmViewer::stopped, this)); + _viewer->PositionChanged.connect (boost::bind(&Controls::position_changed, this)); + _viewer->Started.connect (boost::bind(&Controls::started, this)); + _viewer->Stopped.connect (boost::bind(&Controls::stopped, this)); + _viewer->FilmChanged.connect (boost::bind(&Controls::film_changed, this)); - set_film (shared_ptr<Film> ()); + film_changed (); setup_sensitivity (); JobManager::instance()->ActiveJobsChanged.connect ( - bind (&ControlFilmViewer::active_jobs_changed, this, _2) + bind (&Controls::active_jobs_changed, this, _2) ); } void -ControlFilmViewer::started () +Controls::started () { _play_button->SetValue (true); } void -ControlFilmViewer::stopped () +Controls::stopped () { _play_button->SetValue (false); } void -ControlFilmViewer::position_changed () +Controls::position_changed () { update_position_label (); update_position_slider (); } void -ControlFilmViewer::eye_changed () +Controls::eye_changed () { _viewer->set_eyes (_eye->GetSelection() == 0 ? EYES_LEFT : EYES_RIGHT); } void -ControlFilmViewer::outline_content_changed () +Controls::outline_content_changed () { _viewer->set_outline_content (_outline_content->GetValue()); } void -ControlFilmViewer::film_change (ChangeType type, Film::Property p) +Controls::film_change (ChangeType type, Film::Property p) { if (type != CHANGE_TYPE_DONE) { return; @@ -151,15 +150,9 @@ ControlFilmViewer::film_change (ChangeType type, Film::Property p) } } -void -ControlFilmViewer::image_changed (weak_ptr<PlayerVideo> pv) -{ - ImageChanged (pv); -} - /** @param page true if this was a PAGEUP/PAGEDOWN event for which we won't receive a THUMBRELEASE */ void -ControlFilmViewer::slider_moved (bool page) +Controls::slider_moved (bool page) { if (!_film) { return; @@ -167,7 +160,7 @@ ControlFilmViewer::slider_moved (bool page) if (!page && !_slider_being_moved) { /* This is the first event of a drag; stop playback for the duration of the drag */ - _was_running_before_slider = stop (); + _was_running_before_slider = _viewer->stop (); _slider_being_moved = true; } @@ -182,37 +175,37 @@ ControlFilmViewer::slider_moved (bool page) } void -ControlFilmViewer::slider_released () +Controls::slider_released () { if (_was_running_before_slider) { /* Restart after a drag */ - start (); + _viewer->start (); } _slider_being_moved = false; } void -ControlFilmViewer::play_clicked () +Controls::play_clicked () { check_play_state (); } void -ControlFilmViewer::check_play_state () +Controls::check_play_state () { if (!_film || _film->video_frame_rate() == 0) { return; } if (_play_button->GetValue()) { - start (); + _viewer->start (); } else { - stop (); + _viewer->stop (); } } void -ControlFilmViewer::update_position_slider () +Controls::update_position_slider () { if (!_film) { _slider->SetValue (0); @@ -230,7 +223,7 @@ ControlFilmViewer::update_position_slider () } void -ControlFilmViewer::update_position_label () +Controls::update_position_label () { if (!_film) { _frame_number->SetLabel ("0"); @@ -245,7 +238,7 @@ ControlFilmViewer::update_position_label () } void -ControlFilmViewer::active_jobs_changed (optional<string> j) +Controls::active_jobs_changed (optional<string> j) { /* examine content is the only job which stops the viewer working */ bool const a = !j || *j != "examine_content"; @@ -254,7 +247,7 @@ ControlFilmViewer::active_jobs_changed (optional<string> j) } DCPTime -ControlFilmViewer::nudge_amount (wxKeyboardState& ev) +Controls::nudge_amount (wxKeyboardState& ev) { DCPTime amount = _viewer->one_video_frame (); @@ -270,38 +263,38 @@ ControlFilmViewer::nudge_amount (wxKeyboardState& ev) } void -ControlFilmViewer::rewind_clicked (wxMouseEvent& ev) +Controls::rewind_clicked (wxMouseEvent& ev) { _viewer->go_to (DCPTime()); ev.Skip(); } void -ControlFilmViewer::back_frame () +Controls::back_frame () { _viewer->move (-_viewer->one_video_frame()); } void -ControlFilmViewer::forward_frame () +Controls::forward_frame () { _viewer->move (_viewer->one_video_frame()); } void -ControlFilmViewer::back_clicked (wxKeyboardState& ev) +Controls::back_clicked (wxKeyboardState& ev) { _viewer->move (-nudge_amount(ev)); } void -ControlFilmViewer::forward_clicked (wxKeyboardState& ev) +Controls::forward_clicked (wxKeyboardState& ev) { _viewer->move (nudge_amount(ev)); } void -ControlFilmViewer::setup_sensitivity () +Controls::setup_sensitivity () { bool const c = _film && !_film->content().empty (); @@ -323,7 +316,7 @@ ControlFilmViewer::setup_sensitivity () } void -ControlFilmViewer::timecode_clicked () +Controls::timecode_clicked () { PlayheadToTimecodeDialog* dialog = new PlayheadToTimecodeDialog (this, _film->video_frame_rate ()); if (dialog->ShowModal() == wxID_OK) { @@ -333,7 +326,7 @@ ControlFilmViewer::timecode_clicked () } void -ControlFilmViewer::frame_number_clicked () +Controls::frame_number_clicked () { PlayheadToFrameDialog* dialog = new PlayheadToFrameDialog (this, _film->video_frame_rate ()); if (dialog->ShowModal() == wxID_OK) { @@ -343,15 +336,15 @@ ControlFilmViewer::frame_number_clicked () } void -ControlFilmViewer::jump_to_selected_clicked () +Controls::jump_to_selected_clicked () { Config::instance()->set_jump_to_selected (_jump_to_selected->GetValue ()); } void -ControlFilmViewer::set_film (shared_ptr<Film> film) +Controls::film_changed () { - _viewer->set_film (film); + shared_ptr<Film> film = _viewer->film (); if (_film == film) { return; @@ -364,83 +357,11 @@ ControlFilmViewer::set_film (shared_ptr<Film> film) update_position_slider (); update_position_label (); - _film->Change.connect (boost::bind (&ControlFilmViewer::film_change, this, _1, _2)); -} - -void -ControlFilmViewer::set_position (DCPTime p) -{ - _viewer->set_position (p); -} - -void -ControlFilmViewer::set_position (shared_ptr<Content> content, ContentTime t) -{ - _viewer->set_position (content, t); -} - -void -ControlFilmViewer::set_dcp_decode_reduction (boost::optional<int> reduction) -{ - _viewer->set_dcp_decode_reduction (reduction); -} - -void -ControlFilmViewer::show_closed_captions () -{ - _viewer->show_closed_captions (); -} - -void -ControlFilmViewer::start () -{ - _viewer->start (); -} - -bool -ControlFilmViewer::stop () -{ - return _viewer->stop (); -} - -bool -ControlFilmViewer::playing () const -{ - return _viewer->playing (); -} - -void -ControlFilmViewer::slow_refresh () -{ - _viewer->slow_refresh (); -} - -int -ControlFilmViewer::dropped () const -{ - return _viewer->dropped (); + _film->Change.connect (boost::bind (&Controls::film_change, this, _1, _2)); } shared_ptr<Film> -ControlFilmViewer::film () const +Controls::film () const { return _film; } - -optional<int> -ControlFilmViewer::dcp_decode_reduction () const -{ - return _viewer->dcp_decode_reduction (); -} - -DCPTime -ControlFilmViewer::position () const -{ - return _viewer->position (); -} - -void -ControlFilmViewer::set_coalesce_player_changes (bool c) -{ - _viewer->set_coalesce_player_changes (c); -} diff --git a/src/wx/control_film_viewer.h b/src/wx/control_film_viewer.h index 9200cad32..1795612af 100644 --- a/src/wx/control_film_viewer.h +++ b/src/wx/control_film_viewer.h @@ -12,31 +12,15 @@ class Content; class PlayerVideo; class wxToggleButton; -class ControlFilmViewer : public wxPanel +class Controls : public wxPanel { public: - ControlFilmViewer (wxWindow* parent, bool outline_content = true, bool jump_to_selected = true); + Controls (wxWindow* parent, boost::shared_ptr<FilmViewer>, bool outline_content = true, bool jump_to_selected = true); - void set_film (boost::shared_ptr<Film> film); boost::shared_ptr<Film> film () const; void back_frame (); void forward_frame (); - /* FilmViewer proxies */ - void set_position (DCPTime p); - void set_position (boost::shared_ptr<Content> content, ContentTime p); - void set_dcp_decode_reduction (boost::optional<int> reduction); - void show_closed_captions (); - void start (); - bool stop (); - bool playing () const; - void slow_refresh (); - int dropped () const; - boost::optional<int> dcp_decode_reduction () const; - DCPTime position () const; - void set_coalesce_player_changes (bool c); - boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged; - private: void update_position_label (); void update_position_slider (); @@ -60,6 +44,7 @@ private: void position_changed (); void started (); void stopped (); + void film_changed (); boost::shared_ptr<Film> _film; boost::shared_ptr<FilmViewer> _viewer; diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 965497234..34aad9078 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -39,9 +39,10 @@ using std::cout; using std::string; using std::list; using boost::shared_ptr; +using boost::weak_ptr; using boost::optional; -FilmEditor::FilmEditor (wxWindow* parent, ControlFilmViewer* viewer) +FilmEditor::FilmEditor (wxWindow* parent, weak_ptr<FilmViewer> viewer) : wxPanel (parent) { wxBoxSizer* s = new wxBoxSizer (wxVERTICAL); diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 48e944fc6..b8d862f81 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -30,7 +30,7 @@ class wxNotebook; class Film; class ContentPanel; class DCPPanel; -class ControlFilmViewer; +class FilmViewer; /** @class FilmEditor * @brief A wx widget to edit a film's metadata, and perform various functions. @@ -38,7 +38,7 @@ class ControlFilmViewer; class FilmEditor : public wxPanel { public: - FilmEditor (wxWindow *, ControlFilmViewer* viewer); + FilmEditor (wxWindow *, boost::weak_ptr<FilmViewer> viewer); void set_film (boost::shared_ptr<Film>); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 85b0effbe..2d53db9ef 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -116,6 +116,8 @@ FilmViewer::set_film (shared_ptr<Film> film) _film = film; + FilmChanged (); + _frame.reset (); _closed_captions_dialog->clear (); diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index d080c79a5..0da656fa9 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -97,6 +97,7 @@ public: boost::signals2::signal<void ()> PositionChanged; boost::signals2::signal<void ()> Started; boost::signals2::signal<void ()> Stopped; + boost::signals2::signal<void ()> FilmChanged; private: void paint_panel (); diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index c66c6c1e9..c0821510c 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -20,7 +20,7 @@ #include "player_information.h" #include "wx_util.h" -#include "control_film_viewer.h" +#include "film_viewer.h" #include "lib/playlist.h" #include "lib/compose.hpp" #include "lib/video_content.h" @@ -31,13 +31,14 @@ using std::cout; using std::string; using boost::shared_ptr; +using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::optional; /* This should be even */ static int const dcp_lines = 6; -PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewer) +PlayerInformation::PlayerInformation (wxWindow* parent, weak_ptr<FilmViewer> viewer) : wxPanel (parent) , _viewer (viewer) , _sizer (new wxBoxSizer (wxHORIZONTAL)) @@ -87,15 +88,23 @@ PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewe void PlayerInformation::periodic_update () { - checked_set (_dropped, wxString::Format(_("Dropped frames: %d"), _viewer->dropped())); + shared_ptr<FilmViewer> fv = _viewer.lock (); + if (fv) { + checked_set (_dropped, wxString::Format(_("Dropped frames: %d"), fv->dropped())); + } } void PlayerInformation::triggered_update () { + shared_ptr<FilmViewer> fv = _viewer.lock (); + if (!fv) { + return; + } + shared_ptr<DCPContent> dcp; - if (_viewer->film()) { - ContentList content = _viewer->film()->content(); + if (fv->film()) { + ContentList content = fv->film()->content(); if (content.size() == 1) { dcp = dynamic_pointer_cast<DCPContent>(content.front()); } @@ -151,7 +160,7 @@ PlayerInformation::triggered_update () checked_set (_dcp[r++], std_to_wx(len)); dcp::Size decode = dcp->video->size(); - optional<int> reduction = _viewer->dcp_decode_reduction(); + optional<int> reduction = fv->dcp_decode_reduction(); if (reduction) { decode.width /= pow(2, *reduction); decode.height /= pow(2, *reduction); diff --git a/src/wx/player_information.h b/src/wx/player_information.h index f82cd7aa4..b93228174 100644 --- a/src/wx/player_information.h +++ b/src/wx/player_information.h @@ -20,13 +20,14 @@ #include <wx/wx.h> #include <boost/scoped_ptr.hpp> +#include <boost/weak_ptr.hpp> -class ControlFilmViewer; +class FilmViewer; class PlayerInformation : public wxPanel { public: - PlayerInformation (wxWindow* parent, ControlFilmViewer* viewer); + PlayerInformation (wxWindow* parent, boost::weak_ptr<FilmViewer> viewer); void triggered_update (); @@ -34,7 +35,7 @@ private: void periodic_update (); - ControlFilmViewer* _viewer; + boost::weak_ptr<FilmViewer> _viewer; wxSizer* _sizer; wxStaticText** _dcp; wxStaticText* _dropped; diff --git a/src/wx/text_view.cc b/src/wx/text_view.cc index 442335b92..16ec2213f 100644 --- a/src/wx/text_view.cc +++ b/src/wx/text_view.cc @@ -18,6 +18,9 @@ */ +#include "text_view.h" +#include "film_viewer.h" +#include "wx_util.h" #include "lib/string_text_file_decoder.h" #include "lib/content_text.h" #include "lib/video_decoder.h" @@ -26,17 +29,15 @@ #include "lib/config.h" #include "lib/string_text_file_content.h" #include "lib/text_decoder.h" -#include "text_view.h" -#include "control_film_viewer.h" -#include "wx_util.h" using std::list; using boost::shared_ptr; +using boost::weak_ptr; using boost::bind; using boost::dynamic_pointer_cast; TextView::TextView ( - wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<TextContent> text, shared_ptr<Decoder> decoder, ControlFilmViewer* viewer + wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content, shared_ptr<TextContent> text, shared_ptr<Decoder> decoder, weak_ptr<FilmViewer> viewer ) : wxDialog (parent, wxID_ANY, _("Captions"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , _content (content) @@ -135,7 +136,9 @@ TextView::subtitle_selected (wxListEvent& ev) } DCPOMATIC_ASSERT (ev.GetIndex() < int(_start_times.size())); - shared_ptr<Content> locked = _content.lock (); - DCPOMATIC_ASSERT (locked); - _film_viewer->set_position (locked, _start_times[ev.GetIndex()]); + shared_ptr<Content> lc = _content.lock (); + DCPOMATIC_ASSERT (lc); + shared_ptr<FilmViewer> fv = _film_viewer.lock (); + DCPOMATIC_ASSERT (fv); + fv->set_position (lc, _start_times[ev.GetIndex()]); } diff --git a/src/wx/text_view.h b/src/wx/text_view.h index 12cbb6d08..1fe07a999 100644 --- a/src/wx/text_view.h +++ b/src/wx/text_view.h @@ -19,12 +19,14 @@ */ #include "lib/content_text.h" -#include <boost/shared_ptr.hpp> #include <wx/wx.h> #include <wx/listctrl.h> +#include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> class Decoder; -class ControlFilmViewer; +class FilmViewer; +class Film; class TextView : public wxDialog { @@ -35,7 +37,7 @@ public: boost::shared_ptr<Content> content, boost::shared_ptr<TextContent> caption, boost::shared_ptr<Decoder>, - ControlFilmViewer* viewer + boost::weak_ptr<FilmViewer> viewer ); private: @@ -49,5 +51,5 @@ private: boost::optional<int> _last_count; std::vector<ContentTime> _start_times; boost::weak_ptr<Content> _content; - ControlFilmViewer* _film_viewer; + boost::weak_ptr<FilmViewer> _film_viewer; }; diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 25ea179f6..4a221c650 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -20,7 +20,7 @@ #include "timing_panel.h" #include "wx_util.h" -#include "control_film_viewer.h" +#include "film_viewer.h" #include "timecode.h" #include "content_panel.h" #include "move_to_dialog.h" @@ -40,11 +40,12 @@ using std::cout; using std::string; using std::set; using boost::shared_ptr; +using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::optional; using dcp::locale_convert; -TimingPanel::TimingPanel (ContentPanel* p, ControlFilmViewer* viewer) +TimingPanel::TimingPanel (ContentPanel* p, weak_ptr<FilmViewer> viewer) /* horrid hack for apparent lack of context support with wxWidgets i18n code */ /// TRANSLATORS: translate the word "Timing" here; do not include the "Timing|" prefix : ContentSubPanel (p, S_("Timing|Timing")) @@ -133,7 +134,9 @@ TimingPanel::TimingPanel (ContentPanel* p, ControlFilmViewer* viewer) _video_frame_rate->Bind (wxEVT_TEXT, boost::bind (&TimingPanel::video_frame_rate_changed, this)); _set_video_frame_rate->Bind (wxEVT_BUTTON, boost::bind (&TimingPanel::set_video_frame_rate, this)); - _viewer->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this)); + shared_ptr<FilmViewer> fv = _viewer.lock (); + DCPOMATIC_ASSERT (fv); + fv->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this)); setup_sensitivity (); add_to_grid (); @@ -388,9 +391,14 @@ TimingPanel::full_length_changed () void TimingPanel::trim_start_changed () { - DCPTime const ph = _viewer->position (); + shared_ptr<FilmViewer> fv = _viewer.lock (); + if (!fv) { + return; + } + + DCPTime const ph = fv->position (); - _viewer->set_coalesce_player_changes (true); + fv->set_coalesce_player_changes (true); shared_ptr<Content> ref; optional<FrameRateChange> ref_frc; @@ -413,16 +421,21 @@ TimingPanel::trim_start_changed () } if (ref) { - _viewer->set_position (max (DCPTime(), ref_ph.get() + ref->position() - DCPTime (ref->trim_start(), ref_frc.get()))); + fv->set_position (max (DCPTime(), ref_ph.get() + ref->position() - DCPTime (ref->trim_start(), ref_frc.get()))); } - _viewer->set_coalesce_player_changes (false); + fv->set_coalesce_player_changes (false); } void TimingPanel::trim_end_changed () { - _viewer->set_coalesce_player_changes (true); + shared_ptr<FilmViewer> fv = _viewer.lock (); + if (!fv) { + return; + } + + fv->set_coalesce_player_changes (true); ContentTime const trim = _trim_end->get (_parent->film()->video_frame_rate ()); BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) { @@ -430,11 +443,11 @@ TimingPanel::trim_end_changed () } /* XXX: maybe playhead-off-the-end-of-the-film should be handled elsewhere */ - if (_viewer->position() >= _parent->film()->length()) { - _viewer->set_position (_parent->film()->length() - DCPTime::from_frames (1, _parent->film()->video_frame_rate())); + if (fv->position() >= _parent->film()->length()) { + fv->set_position (_parent->film()->length() - DCPTime::from_frames (1, _parent->film()->video_frame_rate())); } - _viewer->set_coalesce_player_changes (true); + fv->set_coalesce_player_changes (true); } void @@ -497,11 +510,16 @@ TimingPanel::film_changed (Film::Property p) void TimingPanel::trim_start_to_playhead_clicked () { + shared_ptr<FilmViewer> fv = _viewer.lock (); + if (!fv) { + return; + } + shared_ptr<const Film> film = _parent->film (); - DCPTime const ph = _viewer->position().floor (film->video_frame_rate ()); + DCPTime const ph = fv->position().floor (film->video_frame_rate ()); optional<DCPTime> new_ph; - _viewer->set_coalesce_player_changes (true); + fv->set_coalesce_player_changes (true); BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) { if (i->position() < ph && ph < i->end ()) { @@ -512,17 +530,22 @@ TimingPanel::trim_start_to_playhead_clicked () } if (new_ph) { - _viewer->set_position (new_ph.get()); + fv->set_position (new_ph.get()); } - _viewer->set_coalesce_player_changes (false); + fv->set_coalesce_player_changes (false); } void TimingPanel::trim_end_to_playhead_clicked () { + shared_ptr<FilmViewer> fv = _viewer.lock (); + if (!fv) { + return; + } + shared_ptr<const Film> film = _parent->film (); - DCPTime const ph = _viewer->position().floor (film->video_frame_rate ()); + DCPTime const ph = fv->position().floor (film->video_frame_rate ()); BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) { if (i->position() < ph && ph < i->end ()) { FrameRateChange const frc = film->active_frame_rate_change (i->position ()); @@ -544,7 +567,9 @@ TimingPanel::setup_sensitivity () _play_length->Enable (e); _video_frame_rate->Enable (e); - DCPTime const ph = _viewer->position (); + shared_ptr<FilmViewer> fv = _viewer.lock (); + DCPOMATIC_ASSERT (fv); + DCPTime const ph = fv->position (); bool any_over_ph = false; BOOST_FOREACH (shared_ptr<const Content> i, _parent->selected ()) { if (i->position() <= ph && ph < i->end()) { diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h index 7e38d86b8..65d8aabc9 100644 --- a/src/wx/timing_panel.h +++ b/src/wx/timing_panel.h @@ -21,12 +21,12 @@ #include "content_sub_panel.h" #include "timecode.h" -class ControlFilmViewer; +class FilmViewer; class TimingPanel : public ContentSubPanel { public: - TimingPanel (ContentPanel *, ControlFilmViewer* viewer); + TimingPanel (ContentPanel *, boost::weak_ptr<FilmViewer> viewer); void film_changed (Film::Property); void film_content_changed (int); @@ -48,7 +48,7 @@ private: void setup_sensitivity (); void add_to_grid (); - ControlFilmViewer* _viewer; + boost::weak_ptr<FilmViewer> _viewer; wxStaticText* _h_label; wxStaticText* _m_label; diff --git a/src/wx/video_waveform_dialog.cc b/src/wx/video_waveform_dialog.cc index 28efe5125..6b0ed4410 100644 --- a/src/wx/video_waveform_dialog.cc +++ b/src/wx/video_waveform_dialog.cc @@ -20,7 +20,7 @@ #include "video_waveform_dialog.h" #include "video_waveform_plot.h" -#include "control_film_viewer.h" +#include "film_viewer.h" #include "wx_util.h" #include <boost/bind.hpp> #include <iostream> @@ -28,8 +28,9 @@ using std::cout; using boost::bind; using boost::weak_ptr; +using boost::shared_ptr; -VideoWaveformDialog::VideoWaveformDialog (wxWindow* parent, weak_ptr<const Film> film, ControlFilmViewer* viewer) +VideoWaveformDialog::VideoWaveformDialog (wxWindow* parent, weak_ptr<const Film> film, weak_ptr<FilmViewer> viewer) : wxDialog ( parent, wxID_ANY, @@ -106,7 +107,9 @@ VideoWaveformDialog::shown (wxShowEvent& ev) { _plot->set_enabled (ev.IsShown ()); if (ev.IsShown ()) { - _viewer->slow_refresh (); + shared_ptr<FilmViewer> fv = _viewer.lock (); + DCPOMATIC_ASSERT (fv); + fv->slow_refresh (); } } diff --git a/src/wx/video_waveform_dialog.h b/src/wx/video_waveform_dialog.h index 1cfbb73b7..ac3a72dde 100644 --- a/src/wx/video_waveform_dialog.h +++ b/src/wx/video_waveform_dialog.h @@ -22,13 +22,13 @@ #include <boost/weak_ptr.hpp> class VideoWaveformPlot; -class ControlFilmViewer; +class FilmViewer; class Film; class VideoWaveformDialog : public wxDialog { public: - VideoWaveformDialog (wxWindow* parent, boost::weak_ptr<const Film> film, ControlFilmViewer* viewer); + VideoWaveformDialog (wxWindow* parent, boost::weak_ptr<const Film> film, boost::weak_ptr<FilmViewer> viewer); private: void shown (wxShowEvent &); @@ -36,7 +36,7 @@ private: void contrast_changed (); void mouse_moved (int x1, int x2, int y1, int y2); - ControlFilmViewer* _viewer; + boost::weak_ptr<FilmViewer> _viewer; VideoWaveformPlot* _plot; wxChoice* _component; wxSlider* _contrast; diff --git a/src/wx/video_waveform_plot.cc b/src/wx/video_waveform_plot.cc index 339689a2e..9f71140f3 100644 --- a/src/wx/video_waveform_plot.cc +++ b/src/wx/video_waveform_plot.cc @@ -19,7 +19,7 @@ */ #include "video_waveform_plot.h" -#include "control_film_viewer.h" +#include "film_viewer.h" #include "wx_util.h" #include "lib/image.h" #include "lib/film.h" @@ -43,7 +43,7 @@ int const VideoWaveformPlot::_vertical_margin = 8; int const VideoWaveformPlot::_pixel_values = 4096; int const VideoWaveformPlot::_x_axis_width = 52; -VideoWaveformPlot::VideoWaveformPlot (wxWindow* parent, weak_ptr<const Film> film, ControlFilmViewer* viewer) +VideoWaveformPlot::VideoWaveformPlot (wxWindow* parent, weak_ptr<const Film> film, weak_ptr<FilmViewer> viewer) : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) , _film (film) , _dirty (true) @@ -55,7 +55,10 @@ VideoWaveformPlot::VideoWaveformPlot (wxWindow* parent, weak_ptr<const Film> fil SetDoubleBuffered (true); #endif - _viewer_connection = viewer->ImageChanged.connect (boost::bind (&VideoWaveformPlot::set_image, this, _1)); + shared_ptr<FilmViewer> fv = viewer.lock (); + DCPOMATIC_ASSERT (fv); + + _viewer_connection = fv->ImageChanged.connect (boost::bind (&VideoWaveformPlot::set_image, this, _1)); Bind (wxEVT_PAINT, boost::bind (&VideoWaveformPlot::paint, this)); Bind (wxEVT_SIZE, boost::bind (&VideoWaveformPlot::sized, this, _1)); diff --git a/src/wx/video_waveform_plot.h b/src/wx/video_waveform_plot.h index d0bfc40ae..380186074 100644 --- a/src/wx/video_waveform_plot.h +++ b/src/wx/video_waveform_plot.h @@ -30,12 +30,12 @@ namespace dcp { class PlayerVideo; class Image; class Film; -class ControlFilmViewer; +class FilmViewer; class VideoWaveformPlot : public wxPanel { public: - VideoWaveformPlot (wxWindow* parent, boost::weak_ptr<const Film> film, ControlFilmViewer* viewer); + VideoWaveformPlot (wxWindow* parent, boost::weak_ptr<const Film> film, boost::weak_ptr<FilmViewer> viewer); void set_enabled (bool e); void set_component (int c); |
