Allow CPL selection in player (#1239).
authorCarl Hetherington <cth@carlh.net>
Thu, 22 Mar 2018 23:11:06 +0000 (23:11 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 22 Mar 2018 23:11:06 +0000 (23:11 +0000)
ChangeLog
src/tools/dcpomatic_player.cc

index 9720cc00168acfd64711fdb58d76e289829945fd..73f38490180511197524c8aee8949472fc4bef2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2018-03-22  Carl Hetherington  <cth@carlh.net>
 
 2018-03-22  Carl Hetherington  <cth@carlh.net>
 
+       * Allow CPL selection in player (#1239).
+
        * Add hint about making a DCP with a very different frame rate
        to the content.
 
        * Add hint about making a DCP with a very different frame rate
        to the content.
 
index 89bff5caef2d0edb8b35c083afce03bc1eb85c5c..a765bd1d1416fda01783c9152a820e2517686455 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/subtitle_content.h"
 #include "lib/ratio.h"
 #include "lib/verify_dcp_job.h"
 #include "lib/subtitle_content.h"
 #include "lib/ratio.h"
 #include "lib/verify_dcp_job.h"
+#include "lib/dcp_examiner.h"
 #include "wx/wx_signal_manager.h"
 #include "wx/wx_util.h"
 #include "wx/about_dialog.h"
 #include "wx/wx_signal_manager.h"
 #include "wx/wx_util.h"
 #include "wx/about_dialog.h"
 #undef check
 #endif
 
 #undef check
 #endif
 
+#define MAX_CPLS 32
+
 using std::string;
 using std::cout;
 using std::string;
 using std::cout;
+using std::list;
 using std::exception;
 using std::vector;
 using boost::shared_ptr;
 using std::exception;
 using std::vector;
 using boost::shared_ptr;
@@ -70,7 +74,9 @@ enum {
        ID_file_history,
        /* Allow spare IDs after _history for the recent files list */
        ID_file_close = 100,
        ID_file_history,
        /* Allow spare IDs after _history for the recent files list */
        ID_file_close = 100,
-       ID_view_scale_appropriate,
+       ID_view_cpl,
+       /* Allow spare IDs for CPLs */
+       ID_view_scale_appropriate = 200,
        ID_view_scale_full,
        ID_view_scale_half,
        ID_view_scale_quarter,
        ID_view_scale_full,
        ID_view_scale_half,
        ID_view_scale_quarter,
@@ -118,7 +124,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::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::set_decode_reduction, this, optional<int>()), ID_view_scale_appropriate);
+               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);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(2)), ID_view_scale_quarter);
                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);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(2)), ID_view_scale_quarter);
@@ -206,6 +212,20 @@ public:
                Config::instance()->add_to_player_history (dir);
 
                set_menu_sensitivity ();
                Config::instance()->add_to_player_history (dir);
 
                set_menu_sensitivity ();
+
+               wxMenuItemList old = _cpl_menu->GetMenuItems();
+               for (wxMenuItemList::iterator i = old.begin(); i != old.end(); ++i) {
+                       _cpl_menu->Remove (*i);
+               }
+
+               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);
+                       }
+               }
        }
 
 private:
        }
 
 private:
@@ -236,8 +256,12 @@ private:
                edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
 #endif
 
                edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
 #endif
 
+               _cpl_menu = new wxMenu;
+
                wxMenu* view = new wxMenu;
                optional<int> c = Config::instance()->decode_reduction();
                wxMenu* view = new wxMenu;
                optional<int> c = Config::instance()->decode_reduction();
+               _view_cpl = view->Append(ID_view_cpl, _("CPL"), _cpl_menu);
+               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);
                view->AppendRadioItem(ID_view_scale_half, _("Decode at half resolution"))->Check(c && c.get() == 1);
                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);
                view->AppendRadioItem(ID_view_scale_half, _("Decode at half resolution"))->Check(c && c.get() == 1);
@@ -380,6 +404,25 @@ private:
                _config_dialog->Show (this);
        }
 
                _config_dialog->Show (this);
        }
 
+       void view_cpl (wxCommandEvent& ev)
+       {
+               shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+               DCPOMATIC_ASSERT (dcp);
+               DCPExaminer ex (dcp);
+               int id = ev.GetId() - ID_view_cpl;
+               DCPOMATIC_ASSERT (id >= 0);
+               DCPOMATIC_ASSERT (id < int(ex.cpls().size()));
+               list<shared_ptr<dcp::CPL> > cpls = ex.cpls();
+               list<shared_ptr<dcp::CPL> >::iterator i = cpls.begin();
+               while (id > 0) {
+                       ++i;
+                       --id;
+               }
+
+               dcp->set_cpl ((*i)->id());
+               dcp->examine (shared_ptr<Job>());
+       }
+
        void tools_verify ()
        {
                shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
        void tools_verify ()
        {
                shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
@@ -507,12 +550,15 @@ private:
                _tools_verify->Enable (static_cast<bool>(_film));
                _file_add_ov->Enable (static_cast<bool>(_film));
                _file_add_kdm->Enable (static_cast<bool>(_film));
                _tools_verify->Enable (static_cast<bool>(_film));
                _file_add_ov->Enable (static_cast<bool>(_film));
                _file_add_kdm->Enable (static_cast<bool>(_film));
+               _view_cpl->Enable (static_cast<bool>(_film));
        }
 
        bool _update_news_requested;
        PlayerInformation* _info;
        wxPreferencesEditor* _config_dialog;
        wxMenu* _file_menu;
        }
 
        bool _update_news_requested;
        PlayerInformation* _info;
        wxPreferencesEditor* _config_dialog;
        wxMenu* _file_menu;
+       wxMenuItem* _view_cpl;
+       wxMenu* _cpl_menu;
        int _history_items;
        int _history_position;
        wxMenuItem* _history_separator;
        int _history_items;
        int _history_position;
        wxMenuItem* _history_separator;