Fix build.
authorCarl Hetherington <cth@carlh.net>
Mon, 10 Sep 2018 21:57:33 +0000 (22:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 11 Sep 2018 10:58:15 +0000 (11:58 +0100)
src/wx/control_film_viewer.cc
src/wx/control_film_viewer.h
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/player_information.cc
src/wx/player_information.h
src/wx/timing_panel.cc
src/wx/timing_panel.h
src/wx/video_waveform_dialog.cc
src/wx/video_waveform_plot.cc
src/wx/video_waveform_plot.h

index 44f374f71a9380929a65fa2711ad32593a9a46b4..a374aec1bbd8c500385aca7d914086e5b7447f92 100644 (file)
@@ -1,15 +1,28 @@
 #include "control_film_viewer.h"
 #include "film_viewer.h"
 #include "wx_util.h"
+#include "playhead_to_timecode_dialog.h"
+#include "playhead_to_frame_dialog.h"
+#include "lib/job_manager.h"
 #include <wx/wx.h>
 #include <wx/tglbtn.h>
 
 using std::string;
 using boost::optional;
+using boost::shared_ptr;
+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)
        : wxPanel (parent)
-       , _viewer (new FilmViewer(this, outline_content, jump_to_selected))
+       , _viewer (new FilmViewer(this))
+       , _slider_being_moved (false)
+       , _was_running_before_slider (false)
+       , _outline_content (0)
+       , _eye (0)
+       , _jump_to_selected (0)
        , _slider (new wxSlider (this, wxID_ANY, 0, 0, 4096))
        , _rewind_button (new wxButton (this, wxID_ANY, wxT("|<")))
        , _back_button (new wxButton (this, wxID_ANY, wxT("<")))
@@ -61,7 +74,11 @@ 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 (&FilmViewer::slow_refresh, _viewer.get()));
+       _eye->Bind (wxEVT_CHOICE, boost::bind (&ControlFilmViewer::eye_changed, this));
+       if (_outline_content) {
+               _outline_content->Bind (wxEVT_CHECKBOX, boost::bind (&ControlFilmViewer::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));
@@ -76,6 +93,56 @@ ControlFilmViewer::ControlFilmViewer (wxWindow* parent, bool outline_content, bo
                _jump_to_selected->Bind (wxEVT_CHECKBOX, boost::bind (&ControlFilmViewer::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));
+
+       set_film (shared_ptr<Film> ());
+
+       setup_sensitivity ();
+
+       JobManager::instance()->ActiveJobsChanged.connect (
+               bind (&ControlFilmViewer::active_jobs_changed, this, _2)
+               );
+
+       _film->Change.connect (boost::bind (&ControlFilmViewer::film_change, this, _1, _2));
+}
+
+void
+ControlFilmViewer::position_changed ()
+{
+       update_position_label ();
+       update_position_slider ();
+}
+
+void
+ControlFilmViewer::eye_changed ()
+{
+       _viewer->set_eyes (_eye->GetSelection() == 0 ? EYES_LEFT : EYES_RIGHT);
+}
+
+void
+ControlFilmViewer::outline_content_changed ()
+{
+       _viewer->set_outline_content (_outline_content->GetValue());
+}
+
+void
+ControlFilmViewer::film_change (ChangeType type, Film::Property p)
+{
+       if (type != CHANGE_TYPE_DONE) {
+               return;
+       }
+
+       if (p == Film::CONTENT || p == Film::THREE_D) {
+               setup_sensitivity ();
+       }
+}
+
+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 */
@@ -280,6 +347,8 @@ ControlFilmViewer::set_film (shared_ptr<Film> film)
 
        _film = film;
 
+       setup_sensitivity ();
+
        update_position_slider ();
        update_position_label ();
 }
@@ -311,12 +380,14 @@ ControlFilmViewer::show_closed_captions ()
 void
 ControlFilmViewer::start ()
 {
+       _play_button->SetValue (true);
        _viewer->start ();
 }
 
 bool
 ControlFilmViewer::stop ()
 {
+       _play_button->SetValue (false);
        return _viewer->stop ();
 }
 
@@ -325,3 +396,39 @@ ControlFilmViewer::playing () const
 {
        return _viewer->playing ();
 }
+
+void
+ControlFilmViewer::slow_refresh ()
+{
+       _viewer->slow_refresh ();
+}
+
+int
+ControlFilmViewer::dropped () const
+{
+       return _viewer->dropped ();
+}
+
+shared_ptr<Film>
+ControlFilmViewer::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 3de316d65e4852a94276c18671657792c7034e4b..b3ad701d86996a952835406a8207da79ae2f99b6 100644 (file)
@@ -1,11 +1,15 @@
 #include "lib/dcpomatic_time.h"
+#include "lib/types.h"
+#include "lib/film.h"
 #include <wx/wx.h>
 #include <boost/shared_ptr.hpp>
+#include <boost/signals2.hpp>
 
 class FilmViewer;
 class Film;
 class ClosedCaptionsDialog;
 class Content;
+class PlayerVideo;
 class wxToggleButton;
 
 class ControlFilmViewer : public wxPanel
@@ -14,6 +18,8 @@ public:
        ControlFilmViewer (wxWindow* parent, bool outline_content = true, bool jump_to_selected = true);
 
        void set_film (boost::shared_ptr<Film> film);
+       void back_frame ();
+       void forward_frame ();
 
        /* FilmViewer proxies */
        void set_position (DCPTime p);
@@ -23,8 +29,13 @@ public:
        void start ();
        bool stop ();
        bool playing () const;
-       void back_frame ();
-       void forward_frame ();
+       void slow_refresh ();
+       int dropped () const;
+       boost::shared_ptr<Film> film () 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 ();
@@ -41,6 +52,12 @@ private:
        void timecode_clicked ();
        void check_play_state ();
        void active_jobs_changed (boost::optional<std::string>);
+       DCPTime nudge_amount (wxKeyboardState& ev);
+       void image_changed (boost::weak_ptr<PlayerVideo>);
+       void film_change (ChangeType type, Film::Property p);
+       void outline_content_changed ();
+       void eye_changed ();
+       void position_changed ();
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<FilmViewer> _viewer;
index 3113a1e057f7a0848315a189e95b8056230b5dc9..b7e414444f1baa3b55fb274c47445ea2c3bb24e4 100644 (file)
@@ -73,21 +73,18 @@ rtaudio_callback (void* out, void *, unsigned int frames, double, RtAudioStreamS
        return reinterpret_cast<FilmViewer*>(data)->audio_callback (out, frames);
 }
 
-FilmViewer::FilmViewer (wxWindow* p, bool outline_content, bool jump_to_selected)
+FilmViewer::FilmViewer (wxWindow* p)
        : _panel (new wxPanel (p))
-       , _outline_content (0)
-       , _eye (0)
-       , _jump_to_selected (0)
        , _coalesce_player_changes (false)
-       , _slider_being_moved (false)
-       , _was_running_before_slider (false)
        , _audio (DCPOMATIC_RTAUDIO_API)
        , _audio_channels (0)
        , _audio_block_size (1024)
        , _playing (false)
        , _latency_history_count (0)
        , _dropped (0)
-       , _closed_captions_dialog (new ClosedCaptionsDialog(GetParent()))
+       , _closed_captions_dialog (new ClosedCaptionsDialog(p))
+       , _outline_content (false)
+       , _eyes (EYES_LEFT)
 {
 #ifndef __WXOSX__
        _panel->SetDoubleBuffered (true);
@@ -97,19 +94,10 @@ FilmViewer::FilmViewer (wxWindow* p, bool outline_content, bool jump_to_selected
 
        _panel->Bind            (wxEVT_PAINT,               boost::bind (&FilmViewer::paint_panel,     this));
        _panel->Bind            (wxEVT_SIZE,                boost::bind (&FilmViewer::panel_sized,     this, _1));
-       if (_outline_content) {
-               _outline_content->Bind  (wxEVT_CHECKBOX,    boost::bind (&FilmViewer::refresh_panel,   this));
-       }
        _timer.Bind             (wxEVT_TIMER,               boost::bind (&FilmViewer::timer,           this));
 
        set_film (shared_ptr<Film> ());
 
-       JobManager::instance()->ActiveJobsChanged.connect (
-               bind (&FilmViewer::active_jobs_changed, this, _2)
-               );
-
-       setup_sensitivity ();
-
        _config_changed_connection = Config::instance()->Changed.connect (bind (&FilmViewer::config_changed, this, _1));
        config_changed (Config::SOUND_OUTPUT);
 }
@@ -146,7 +134,7 @@ FilmViewer::set_film (shared_ptr<Film> film)
                        _player->set_dcp_decode_reduction (_dcp_decode_reduction);
                }
        } catch (bad_alloc) {
-               error_dialog (this, _("There is not enough free memory to do that."));
+               error_dialog (_panel, _("There is not enough free memory to do that."));
                _film.reset ();
                return;
        }
@@ -164,8 +152,6 @@ FilmViewer::set_film (shared_ptr<Film> film)
 
        calculate_sizes ();
        slow_refresh ();
-
-       setup_sensitivity ();
 }
 
 void
@@ -233,7 +219,7 @@ FilmViewer::get ()
        } while (
                _player_video.first &&
                _film->three_d() &&
-               ((_eye->GetSelection() == 0 && _player_video.first->eyes() == EYES_RIGHT) || (_eye->GetSelection() == 1 && _player_video.first->eyes() == EYES_LEFT))
+               (_eyes != _player_video.first->eyes())
                );
 
        _butler->rethrow ();
@@ -302,8 +288,7 @@ FilmViewer::timer ()
        }
 
        get ();
-       update_position_label ();
-       update_position_slider ();
+       PositionChanged ();
        DCPTime const next = _video_position + one_video_frame();
 
        if (next >= _film->length()) {
@@ -332,22 +317,22 @@ FilmViewer::paint_panel ()
        dc.DrawBitmap (frame_bitmap, 0, 0);
 
        if (_out_size.width < _panel_size.width) {
-               wxPen p (GetBackgroundColour ());
-               wxBrush b (GetBackgroundColour ());
+               wxPen p (_panel->GetParent()->GetBackgroundColour());
+               wxBrush b (_panel->GetParent()->GetBackgroundColour());
                dc.SetPen (p);
                dc.SetBrush (b);
                dc.DrawRectangle (_out_size.width, 0, _panel_size.width - _out_size.width, _panel_size.height);
        }
 
        if (_out_size.height < _panel_size.height) {
-               wxPen p (GetBackgroundColour ());
-               wxBrush b (GetBackgroundColour ());
+               wxPen p (_panel->GetParent()->GetBackgroundColour());
+               wxBrush b (_panel->GetParent()->GetBackgroundColour());
                dc.SetPen (p);
                dc.SetBrush (b);
                dc.DrawRectangle (0, _out_size.height, _panel_size.width, _panel_size.height - _out_size.height);
        }
 
-       if (_outline_content && _outline_content->GetValue ()) {
+       if (_outline_content) {
                wxPen p (wxColour (255, 0, 0), 2);
                dc.SetPen (p);
                dc.SetBrush (*wxTRANSPARENT_BRUSH);
@@ -355,6 +340,20 @@ FilmViewer::paint_panel ()
        }
 }
 
+void
+FilmViewer::set_outline_content (bool o)
+{
+       _outline_content = o;
+       refresh_panel ();
+}
+
+void
+FilmViewer::set_eyes (Eyes e)
+{
+       _eyes = e;
+       slow_refresh ();
+}
+
 void
 FilmViewer::panel_sized (wxSizeEvent& ev)
 {
@@ -365,8 +364,7 @@ FilmViewer::panel_sized (wxSizeEvent& ev)
        if (!quick_refresh()) {
                slow_refresh ();
        }
-       update_position_label ();
-       update_position_slider ();
+       PositionChanged ();
 }
 
 void
@@ -413,7 +411,6 @@ FilmViewer::start ()
        _playing = true;
        _dropped = 0;
        timer ();
-       _play_button->SetValue (true);
 }
 
 bool
@@ -429,7 +426,6 @@ FilmViewer::stop ()
        }
 
        _playing = false;
-       _play_button->SetValue (false);
        return true;
 }
 
@@ -445,8 +441,7 @@ FilmViewer::go_to (DCPTime t)
        }
 
        seek (t, true);
-       update_position_label ();
-       update_position_slider ();
+       PositionChanged ();
 }
 
 void
@@ -478,20 +473,13 @@ FilmViewer::player_change (ChangeType type, int property, bool frequent)
        if (!refreshed) {
                slow_refresh ();
        }
-       update_position_label ();
-       update_position_slider ();
+       PositionChanged ();
 }
 
 void
 FilmViewer::film_change (ChangeType type, Film::Property p)
 {
-       if (type != CHANGE_TYPE_DONE) {
-               return;
-       }
-
-       if (p == Film::CONTENT || p == Film::THREE_D) {
-               setup_sensitivity ();
-       } else if (p == Film::AUDIO_CHANNELS) {
+       if (type == CHANGE_TYPE_DONE && p == Film::AUDIO_CHANNELS) {
                recreate_butler ();
        }
 }
@@ -527,8 +515,7 @@ FilmViewer::set_position (DCPTime p)
 {
        _video_position = p;
        seek (p, true);
-       update_position_label ();
-       update_position_slider ();
+       PositionChanged ();
 }
 
 void
@@ -612,7 +599,7 @@ FilmViewer::config_changed (Config::Property p)
                } catch (RtAudioError& e) {
 #endif
                        error_dialog (
-                               this,
+                               _panel,
                                _("Could not set up audio output.  There will be no audio during the preview."), std_to_wx(e.what())
                                );
                }
@@ -712,7 +699,7 @@ FilmViewer::show_closed_captions ()
 }
 
 void
-FilmViewer::back_frame (DCPTime by)
+FilmViewer::move (DCPTime by)
 {
        if (!_film) {
                return;
index ea203d052d0e441da07b12bf43aea1cebe1147ec..c68b6ade0b5b0bb63b28b0dcc333875ddd4f6917 100644 (file)
@@ -43,7 +43,7 @@ class ClosedCaptionsDialog;
 class FilmViewer
 {
 public:
-       FilmViewer (wxWindow *, bool outline_content = true, bool jump_to_selected = true);
+       FilmViewer (wxWindow *);
        ~FilmViewer ();
 
        wxPanel* panel () const {
@@ -85,12 +85,16 @@ public:
        DCPTime video_position () const {
                return _video_position;
        }
+       void go_to (DCPTime t);
+       void set_outline_content (bool o);
+       void set_eyes (Eyes e);
 
        int audio_callback (void* out, unsigned int frames);
 
        void show_closed_captions ();
 
        boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
+       boost::signals2::signal<void ()> PositionChanged;
 
 private:
        void paint_panel ();
@@ -101,16 +105,14 @@ private:
        void player_change (ChangeType type, int, bool);
        void get ();
        void display_player_video ();
-       void refresh_panel ();
        void film_change (ChangeType, Film::Property);
-       DCPTime nudge_amount (wxKeyboardState &);
        void timecode_clicked ();
-       void go_to (DCPTime t);
        void recreate_butler ();
        void config_changed (Config::Property);
        DCPTime time () const;
        DCPTime uncorrected_time () const;
        Frame average_latency () const;
+       void refresh_panel ();
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<Player> _player;
@@ -148,5 +150,8 @@ private:
 
        ClosedCaptionsDialog* _closed_captions_dialog;
 
+       bool _outline_content;
+       Eyes _eyes;
+
        boost::signals2::scoped_connection _config_changed_connection;
 };
index 36fb0e0ca4bfe8fbb76a9a98e1438dabd62d6d14..c66c6c1e937fc19c8a29f72184ab7c46eb016d59 100644 (file)
 
 #include "player_information.h"
 #include "wx_util.h"
-#include "film_viewer.h"
+#include "control_film_viewer.h"
 #include "lib/playlist.h"
 #include "lib/compose.hpp"
 #include "lib/video_content.h"
 #include "lib/audio_content.h"
 #include "lib/dcp_content.h"
+#include "lib/film.h"
 
 using std::cout;
 using std::string;
index 84daf020dd01e9a9fccb9a613b069901d656b1e9..f82cd7aa4b1d2198afc531ff11dee20a96b32361 100644 (file)
@@ -21,7 +21,7 @@
 #include <wx/wx.h>
 #include <boost/scoped_ptr.hpp>
 
-class FilmViewer;
+class ControlFilmViewer;
 
 class PlayerInformation : public wxPanel
 {
index f64a84f7a15231e891871e5d71d7e86223bd6ed9..25ea179f6c21c22b0bbce2007cd5cc1a947da8d4 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "timing_panel.h"
 #include "wx_util.h"
-#include "film_viewer.h"
+#include "control_film_viewer.h"
 #include "timecode.h"
 #include "content_panel.h"
 #include "move_to_dialog.h"
index 1a9f5d3fd7c5713cd4244e749205e0ac6e9728b2..7e38d86b8c6cbf463ba6db38e757d993ee841ed3 100644 (file)
@@ -21,7 +21,7 @@
 #include "content_sub_panel.h"
 #include "timecode.h"
 
-class FilmViewer;
+class ControlFilmViewer;
 
 class TimingPanel : public ContentSubPanel
 {
index 5e3b95008ed18cd81084cfa49f78b44c2a66b86d..28efe5125f072386e7c4a6b4c00cf8ec348d214d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -20,7 +20,7 @@
 
 #include "video_waveform_dialog.h"
 #include "video_waveform_plot.h"
-#include "film_viewer.h"
+#include "control_film_viewer.h"
 #include "wx_util.h"
 #include <boost/bind.hpp>
 #include <iostream>
index c3d44a0cd265afa9c1324c396d9d8e4800132640..339689a2ebdbdaeea28ef45ab4482ec7520c93b3 100644 (file)
@@ -22,6 +22,7 @@
 #include "control_film_viewer.h"
 #include "wx_util.h"
 #include "lib/image.h"
+#include "lib/film.h"
 #include "lib/dcp_video.h"
 #include <dcp/locale_convert.h>
 #include <dcp/openjpeg_image.h>
index 023a698a8172576be15c3170aa3c4dffe8687367..d0bfc40ae4462ff25ee4ce8a499c56df81555172 100644 (file)
@@ -30,7 +30,7 @@ namespace dcp {
 class PlayerVideo;
 class Image;
 class Film;
-class FilmViewer;
+class ControlFilmViewer;
 
 class VideoWaveformPlot : public wxPanel
 {