FilmViewer API tidying.
[dcpomatic.git] / src / tools / dcpomatic_player.cc
index 3f56f47529fd59b41397f73b0d023ecda58e22cb..a95476fc10bf06376821f900c028d89976ddcc62 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/controls.h"
 #include "lib/cross.h"
 #include "lib/config.h"
 #include "lib/util.h"
@@ -26,6 +37,7 @@
 #include "lib/dcp_content.h"
 #include "lib/job_manager.h"
 #include "lib/job.h"
+#include "lib/film.h"
 #include "lib/video_content.h"
 #include "lib/text_content.h"
 #include "lib/ratio.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/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>
@@ -82,7 +85,8 @@ enum {
        ID_file_close = 100,
        ID_view_cpl,
        /* Allow spare IDs for CPLs */
-       ID_view_scale_appropriate = 200,
+       ID_view_closed_captions = 200,
+       ID_view_scale_appropriate,
        ID_view_scale_full,
        ID_view_scale_half,
        ID_view_scale_quarter,
@@ -107,7 +111,6 @@ public:
                , _history_items (0)
                , _history_position (0)
                , _history_separator (0)
-               , _viewer (0)
        {
 
 #if defined(DCPOMATIC_WINDOWS)
@@ -134,6 +137,7 @@ public:
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_close, this), ID_file_close);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_closed_captions, this), ID_view_closed_captions);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_cpl, this, _1), ID_view_cpl, ID_view_cpl + MAX_CPLS);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(0)), ID_view_scale_full);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(1)), ID_view_scale_half);
@@ -148,11 +152,13 @@ public:
                */
                wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
 
-               _viewer = new FilmViewer (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);
 
@@ -211,7 +217,7 @@ public:
                }
 
                _viewer->set_film (_film);
-               _viewer->set_position (DCPTime ());
+               _viewer->seek (DCPTime(), true);
                _info->triggered_update ();
 
                Config::instance()->add_to_player_history (dir);
@@ -226,10 +232,11 @@ public:
                DCPExaminer ex (dcp);
                int id = ID_view_cpl;
                BOOST_FOREACH (shared_ptr<dcp::CPL> i, ex.cpls()) {
-                       wxMenuItem* j = _cpl_menu->AppendRadioItem(id, i->id());
-                       if (!dcp->cpl() || i->id() == *dcp->cpl()) {
-                               j->Check(true);
-                       }
+                       wxMenuItem* j = _cpl_menu->AppendRadioItem(
+                               id,
+                               wxString::Format("%s (%s)", std_to_wx(i->annotation_text()).data(), std_to_wx(i->id()).data())
+                               );
+                       j->Check(!dcp->cpl() || i->id() == *dcp->cpl());
                        ++id;
                }
        }
@@ -267,6 +274,7 @@ private:
                wxMenu* view = new wxMenu;
                optional<int> c = Config::instance()->decode_reduction();
                _view_cpl = view->Append(ID_view_cpl, _("CPL"), _cpl_menu);
+               view->Append(ID_view_closed_captions, _("Closed captions..."));
                view->AppendSeparator();
                view->AppendRadioItem(ID_view_scale_appropriate, _("Set decode resolution to match display"))->Check(!static_cast<bool>(c));
                view->AppendRadioItem(ID_view_scale_full, _("Decode at full resolution"))->Check(c && c.get() == 0);
@@ -430,6 +438,11 @@ private:
                dcp->examine (shared_ptr<Job>());
        }
 
+       void view_closed_captions ()
+       {
+               _viewer->show_closed_captions ();
+       }
+
        void tools_verify ()
        {
                shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
@@ -566,12 +579,12 @@ private:
 
        void back_frame ()
        {
-               _viewer->back_frame ();
+               _viewer->seek_by (-_viewer->one_video_frame(), true);
        }
 
        void forward_frame ()
        {
-               _viewer->forward_frame ();
+               _viewer->seek_by (_viewer->one_video_frame(), true);
        }
 
 private:
@@ -618,8 +631,8 @@ private:
 
        void setup_from_dcp (shared_ptr<DCPContent> dcp)
        {
-               if (dcp->subtitle) {
-                       dcp->subtitle->set_use (true);
+               BOOST_FOREACH (shared_ptr<TextContent> i, dcp->text) {
+                       i->set_use (true);
                }
 
                if (dcp->video) {
@@ -639,7 +652,8 @@ private:
        int _history_items;
        int _history_position;
        wxMenuItem* _history_separator;
-       FilmViewer* _viewer;
+       shared_ptr<FilmViewer> _viewer;
+       Controls* _controls;
        boost::shared_ptr<Film> _film;
        boost::signals2::scoped_connection _config_changed_connection;
        wxMenuItem* _file_add_ov;