Separate out management of controls.
authorCarl Hetherington <cth@carlh.net>
Tue, 11 Sep 2018 00:25:16 +0000 (01:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 11 Sep 2018 10:58:15 +0000 (11:58 +0100)
20 files changed:
src/tools/dcpomatic.cc
src/tools/dcpomatic_player.cc
src/wx/content_panel.cc
src/wx/content_panel.h
src/wx/control_film_viewer.cc
src/wx/control_film_viewer.h
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/player_information.cc
src/wx/player_information.h
src/wx/text_view.cc
src/wx/text_view.h
src/wx/timing_panel.cc
src/wx/timing_panel.h
src/wx/video_waveform_dialog.cc
src/wx/video_waveform_dialog.h
src/wx/video_waveform_plot.cc
src/wx/video_waveform_plot.h

index 7392c830c7be939d8560201ad8597c2e40cbf036..d7862a803221278f864d1efb5ff49fefd0174593 100644 (file)
@@ -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;
index 03ace74c98c632dcadb937949360253069cd59d8..a8895e8e8ff451500625ee4ccb2eb3fce9acfab9 100644 (file)
 
 */
 
+
+#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"
 #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;
index e5990a564b1d1068f8841a996f223ae820398a91..04e35c7582ac7051c793ee643d2c8a593bac3bda 100644 (file)
@@ -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) {
index e9f942d094e4e322eafa593745717cc94030fd84..4a41ad1894ea6db435e99efc8dc2fe2dfc3f5ed3 100644 (file)
@@ -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;
 };
index 739b02765d67ed7438485d2d550e52db15f72de5..c0dc53d896777665cda4fa6d0d38cbb4329d22c6 100644 (file)
@@ -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);
-}
index 9200cad32721587927129f5b28570eff5512be73..1795612af694587e181b27c595a0711132208f17 100644 (file)
@@ -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;
index 965497234aa4ff202da50ca1b82528cf589bd048..34aad9078d5474071970ab1ce006f2633d365974 100644 (file)
@@ -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);
index 48e944fc6a7c020643d568bc76f8745f11dbe435..b8d862f8112ea03ebddf64d8976e22a0f9240850 100644 (file)
@@ -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>);
 
index 85b0effbee8c223483f9d6bfbcc84ae1552b755a..2d53db9ef5ec8e162f7a7b61e91979ad4e0caed3 100644 (file)
@@ -116,6 +116,8 @@ FilmViewer::set_film (shared_ptr<Film> film)
 
        _film = film;
 
+       FilmChanged ();
+
        _frame.reset ();
        _closed_captions_dialog->clear ();
 
index d080c79a5957dd08b8639f81ef6c34736d264db9..0da656fa9615f61de1e8d5130a603530a9c42320 100644 (file)
@@ -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 ();
index c66c6c1e937fc19c8a29f72184ab7c46eb016d59..c0821510ceb54d56b2be333f2e3f77e8c70eb0be 100644 (file)
@@ -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"
 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);
index f82cd7aa4b1d2198afc531ff11dee20a96b32361..b932281746b0fe37c2e00c4860f3ce8d58935404 100644 (file)
 
 #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;
index 442335b92c08c6881d9bbc95f340586bc2feef86..16ec2213f47f6f2d62f260320377b357027baade 100644 (file)
@@ -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"
 #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()]);
 }
index 12cbb6d088a58e54777c2f2611c313ed119d92a7..1fe07a99919f14b588edcc37ffe69351d02aad85 100644 (file)
 */
 
 #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;
 };
index 25ea179f6c21c22b0bbce2007cd5cc1a947da8d4..4a221c650c82e97a97be9a43f80ba04c489e3e68 100644 (file)
@@ -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()) {
index 7e38d86b8c6cbf463ba6db38e757d993ee841ed3..65d8aabc94e124ce8cceeccdf8f885fc95f0d6d3 100644 (file)
 #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;
index 28efe5125f072386e7c4a6b4c00cf8ec348d214d..6b0ed44104b655366ecc260f3395c5423f2583c1 100644 (file)
@@ -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 ();
        }
 }
 
index 1cfbb73b725c31c3044e9a0bfdd262b7dfb49d0a..ac3a72dde524a331b4d427ff58c876df2c6b6a2c 100644 (file)
 #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;
index 339689a2ebdbdaeea28ef45ab4482ec7520c93b3..9f71140f308345526e5964f9fb96657de120d7fb 100644 (file)
@@ -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));
index d0bfc40ae4462ff25ee4ce8a499c56df81555172..3801860740008cf82550a5431f4d50de46893100 100644 (file)
@@ -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);