Remove some friends from FilmViewer.
authorCarl Hetherington <cth@carlh.net>
Thu, 21 Nov 2019 21:38:33 +0000 (22:38 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2020 20:56:47 +0000 (21:56 +0100)
src/wx/closed_captions_dialog.cc
src/wx/closed_captions_dialog.h
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/simple_video_view.cc
src/wx/video_view.cc
src/wx/video_view.h

index 061262cddcc96eff127cac8dfcf5b8661e587f77..afcf5fa876f97b35d0cf66bf9765cf379e0afa13 100644 (file)
@@ -53,6 +53,7 @@ ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer
         , _display (new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(640, (640 / 10) + 64)))
        , _track (new wxChoice(this, wxID_ANY))
        , _current_in_lines (false)
         , _display (new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(640, (640 / 10) + 64)))
        , _track (new wxChoice(this, wxID_ANY))
        , _current_in_lines (false)
+       , _timer (this)
 {
        _lines.resize (CLOSED_CAPTION_LINES);
 
 {
        _lines.resize (CLOSED_CAPTION_LINES);
 
@@ -65,18 +66,30 @@ ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer
        sizer->Add (track_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP);
        sizer->Add (_display, 1, wxEXPAND);
 
        sizer->Add (track_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP);
        sizer->Add (_display, 1, wxEXPAND);
 
+       Bind (wxEVT_SHOW, boost::bind(&ClosedCaptionsDialog::shown, this, _1));
+       Bind (wxEVT_TIMER, boost::bind(&ClosedCaptionsDialog::update, this));
        _display->Bind (wxEVT_PAINT, boost::bind(&ClosedCaptionsDialog::paint, this));
        _track->Bind (wxEVT_CHOICE, boost::bind(&ClosedCaptionsDialog::track_selected, this));
 
        SetSizerAndFit (sizer);
 }
 
        _display->Bind (wxEVT_PAINT, boost::bind(&ClosedCaptionsDialog::paint, this));
        _track->Bind (wxEVT_CHOICE, boost::bind(&ClosedCaptionsDialog::track_selected, this));
 
        SetSizerAndFit (sizer);
 }
 
+void
+ClosedCaptionsDialog::shown (wxShowEvent ev)
+{
+       if (ev.IsShown ()) {
+               _timer.Start (40);
+       } else {
+               _timer.Stop ();
+       }
+}
+
 void
 ClosedCaptionsDialog::track_selected ()
 {
        _current = optional<TextRingBuffers::Data> ();
        _viewer->slow_refresh ();
 void
 ClosedCaptionsDialog::track_selected ()
 {
        _current = optional<TextRingBuffers::Data> ();
        _viewer->slow_refresh ();
-       update (_last_update);
+       update ();
 }
 
 void
 }
 
 void
@@ -131,9 +144,9 @@ private:
 };
 
 void
 };
 
 void
-ClosedCaptionsDialog::update (DCPTime time)
+ClosedCaptionsDialog::update ()
 {
 {
-       _last_update = time;
+       DCPTime const time = _viewer->time ();
 
        if (_current_in_lines && _current && _current->period.to > time) {
                /* Current one is fine */
 
        if (_current_in_lines && _current && _current->period.to > time) {
                /* Current one is fine */
index fb4e9d59b40c5569e90a02c5013f28bd2a051531..5c366ca7b0dbe2cc9d9f61e8eba4002b5e71c6ff 100644 (file)
@@ -31,11 +31,12 @@ class ClosedCaptionsDialog : public wxDialog
 public:
        explicit ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer);
 
 public:
        explicit ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer);
 
-       void update (dcpomatic::DCPTime);
        void clear ();
        void set_film_and_butler (boost::shared_ptr<Film>, boost::weak_ptr<Butler>);
 
 private:
        void clear ();
        void set_film_and_butler (boost::shared_ptr<Film>, boost::weak_ptr<Butler>);
 
 private:
+       void shown (wxShowEvent);
+       void update ();
        void paint ();
        void track_selected ();
 
        void paint ();
        void track_selected ();
 
@@ -47,5 +48,5 @@ private:
        std::vector<wxString> _lines;
        std::vector<DCPTextTrack> _tracks;
        boost::weak_ptr<Butler> _butler;
        std::vector<wxString> _lines;
        std::vector<DCPTextTrack> _tracks;
        boost::weak_ptr<Butler> _butler;
-       dcpomatic::DCPTime _last_update;
+       wxTimer _timer;
 };
 };
index 7437612af9f9fde9094737ee545a7f10c979190e..dcbfedc8194101fb2597dbf90c5adc7317a81edc 100644 (file)
@@ -88,12 +88,10 @@ FilmViewer::FilmViewer (wxWindow* p)
        , _latency_history_count (0)
        , _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
        , _outline_content (false)
        , _latency_history_count (0)
        , _closed_captions_dialog (new ClosedCaptionsDialog(p, this))
        , _outline_content (false)
-       , _eyes (EYES_LEFT)
        , _pad_black (false)
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        , _background_image (false)
 #endif
        , _pad_black (false)
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        , _background_image (false)
 #endif
-       , _gets (0)
        , _idle_get (false)
 {
        switch (Config::instance()->video_view_type()) {
        , _idle_get (false)
 {
        switch (Config::instance()->video_view_type()) {
@@ -234,7 +232,7 @@ FilmViewer::set_outline_content (bool o)
 void
 FilmViewer::set_eyes (Eyes e)
 {
 void
 FilmViewer::set_eyes (Eyes e)
 {
-       _eyes = e;
+       _video_view->set_eyes (e);
        slow_refresh ();
 }
 
        slow_refresh ();
 }
 
@@ -651,3 +649,10 @@ FilmViewer::dropped () const
        return _video_view->dropped ();
 }
 
        return _video_view->dropped ();
 }
 
+int
+FilmViewer::gets () const
+{
+       return _video_view->gets ();
+}
+
+
index 21195e74761cf1dd42305feaa833d855df57e8ae..ec481f34e7f10d46e1fd24b518335020ada0c590 100644 (file)
@@ -92,7 +92,11 @@ public:
 
        void slow_refresh ();
 
 
        void slow_refresh ();
 
+       dcpomatic::DCPTime time () const;
+       boost::optional<dcpomatic::DCPTime> audio_time () const;
+
        int dropped () const;
        int dropped () const;
+       int gets () const;
 
        int audio_callback (void* out, unsigned int frames);
 
 
        int audio_callback (void* out, unsigned int frames);
 
@@ -107,10 +111,6 @@ public:
        }
 #endif
 
        }
 #endif
 
-       int gets () const {
-               return _gets;
-       }
-
        StateTimer const & state_timer () const {
                return _video_view->state_timer ();
        }
        StateTimer const & state_timer () const {
                return _video_view->state_timer ();
        }
@@ -143,11 +143,6 @@ public:
 
 private:
 
 
 private:
 
-       /* XXX_b: to remove */
-       friend class SimpleVideoView;
-       friend class GLVideoView;
-       friend class VideoView;
-
        void video_view_sized ();
        void calculate_sizes ();
        void player_change (ChangeType type, int, bool);
        void video_view_sized ();
        void calculate_sizes ();
        void player_change (ChangeType type, int, bool);
@@ -158,8 +153,6 @@ private:
        void config_changed (Config::Property);
        void film_length_change ();
 
        void config_changed (Config::Property);
        void film_length_change ();
 
-       dcpomatic::DCPTime time () const;
-       boost::optional<dcpomatic::DCPTime> audio_time () const;
        dcpomatic::DCPTime uncorrected_time () const;
        Frame average_latency () const;
 
        dcpomatic::DCPTime uncorrected_time () const;
        Frame average_latency () const;
 
@@ -192,7 +185,6 @@ private:
        ClosedCaptionsDialog* _closed_captions_dialog;
 
        bool _outline_content;
        ClosedCaptionsDialog* _closed_captions_dialog;
 
        bool _outline_content;
-       Eyes _eyes;
        /** true to pad the viewer panel with black, false to use
            the normal window background colour.
        */
        /** true to pad the viewer panel with black, false to use
            the normal window background colour.
        */
@@ -202,8 +194,6 @@ private:
        bool _background_image;
 #endif
 
        bool _background_image;
 #endif
 
-       int _gets;
-
        /** true if an get() is required next time we are idle */
        bool _idle_get;
 
        /** true if an get() is required next time we are idle */
        bool _idle_get;
 
index 63dc102001b06344e64d78a2162b2cd7621f5f43..22e4db887ef7cf11ecebfadba2f9e7a4cff2ffc5 100644 (file)
@@ -253,6 +253,4 @@ SimpleVideoView::display_player_video ()
        _inter_size = player_video().first->inter_size ();
 
        update ();
        _inter_size = player_video().first->inter_size ();
 
        update ();
-
-       _viewer->closed_captions_dialog()->update (_viewer->time());
 }
 }
index e6588865641670b388a2643c761d7d070547902a..5dd857fabc4a4089f8aa4ea08a98e09aeb55ba99 100644 (file)
@@ -30,7 +30,9 @@ VideoView::VideoView (FilmViewer* viewer)
 #endif
        , _state_timer ("viewer")
        , _video_frame_rate (0)
 #endif
        , _state_timer ("viewer")
        , _video_frame_rate (0)
+       , _eyes (EYES_LEFT)
        , _dropped (0)
        , _dropped (0)
+       , _gets (0)
 {
 
 }
 {
 
 }
@@ -54,7 +56,7 @@ VideoView::get_next_frame (bool non_blocking)
        }
 
        DCPOMATIC_ASSERT (_viewer->butler());
        }
 
        DCPOMATIC_ASSERT (_viewer->butler());
-       _viewer->_gets++;
+       add_get ();
 
        boost::mutex::scoped_lock lm (_mutex);
 
 
        boost::mutex::scoped_lock lm (_mutex);
 
@@ -67,7 +69,7 @@ VideoView::get_next_frame (bool non_blocking)
        } while (
                _player_video.first &&
                _viewer->film()->three_d() &&
        } while (
                _player_video.first &&
                _viewer->film()->three_d() &&
-               _viewer->_eyes != _player_video.first->eyes() &&
+               _eyes != _player_video.first->eyes() &&
                _player_video.first->eyes() != EYES_BOTH
                );
 
                _player_video.first->eyes() != EYES_BOTH
                );
 
index 4a94aa879bf4bc3beddf093b50c7ea8dc7eee3be..fd2684e4175a3d6a47e98f8dcc3d0affa2eca8d4 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "lib/dcpomatic_time.h"
 #include "lib/timer.h"
 
 #include "lib/dcpomatic_time.h"
 #include "lib/timer.h"
+#include "lib/types.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 #include <boost/thread.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 #include <boost/thread.hpp>
@@ -63,6 +64,11 @@ public:
                return _dropped;
        }
 
                return _dropped;
        }
 
+       int gets () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _gets;
+       }
+
        StateTimer const & state_timer () const {
                return _state_timer;
        }
        StateTimer const & state_timer () const {
                return _state_timer;
        }
@@ -82,6 +88,11 @@ public:
                _length = len;
        }
 
                _length = len;
        }
 
+       void set_eyes (Eyes eyes) {
+               boost::mutex::scoped_lock lm (_mutex);
+               _eyes = eyes;
+       }
+
 protected:
        /* XXX_b: to remove */
        friend class FilmViewer;
 protected:
        /* XXX_b: to remove */
        friend class FilmViewer;
@@ -110,6 +121,11 @@ protected:
                ++_dropped;
        }
 
                ++_dropped;
        }
 
+       void add_get () {
+               boost::mutex::scoped_lock lm (_mutex);
+               ++_gets;
+       }
+
        FilmViewer* _viewer;
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
        FilmViewer* _viewer;
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
@@ -128,8 +144,10 @@ private:
        int _video_frame_rate;
        /** length of the film we are playing, or 0 if there is none */
        dcpomatic::DCPTime _length;
        int _video_frame_rate;
        /** length of the film we are playing, or 0 if there is none */
        dcpomatic::DCPTime _length;
+       Eyes _eyes;
 
        int _dropped;
 
        int _dropped;
+       int _gets;
 };
 
 #endif
 };
 
 #endif