More Controls API tweaks.
[dcpomatic.git] / src / tools / dcpomatic_player.cc
index ee6ec60af2ade48d9c0578f01b70a6ddc27b8c59..e0112764fed6c814666a80e4faf720002aa5537d 100644 (file)
@@ -115,6 +115,8 @@ public:
                , _history_items (0)
                , _history_position (0)
                , _history_separator (0)
+               , _view_full_screen (0)
+               , _view_dual_screen (0)
        {
 
 #if defined(DCPOMATIC_WINDOWS)
@@ -159,11 +161,12 @@ public:
                _overall_panel = new wxPanel (this, wxID_ANY);
 
                _viewer.reset (new FilmViewer (_overall_panel));
-               _controls = new Controls (_overall_panel, _viewer);
+               _controls = new Controls (_overall_panel, _viewer, false);
                _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ());
                _viewer->PlaybackPermitted.connect (bind(&DOMFrame::playback_permitted, this));
-               _viewer->Started.connect (bind(&DOMFrame::playback_started, this));
-               _viewer->Stopped.connect (bind(&DOMFrame::playback_stopped, this));
+               _viewer->Started.connect (bind(&DOMFrame::playback_started, this, _1));
+               _viewer->Seeked.connect (bind(&DOMFrame::playback_seeked, this, _1));
+               _viewer->Stopped.connect (bind(&DOMFrame::playback_stopped, this, _1));
                _info = new PlayerInformation (_overall_panel, _viewer);
                setup_main_sizer (true);
 #ifdef __WXOSX__
@@ -188,6 +191,8 @@ public:
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame);
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
+               _controls->DCPDirectorySelected.connect (boost::bind(&DOMFrame::load_dcp, this, _1));
+               _controls->DCPEjected.connect (boost::bind(&DOMFrame::eject_dcp, this));
 
                setup_screen ();
        }
@@ -225,7 +230,7 @@ public:
                return ok;
        }
 
-       void playback_started ()
+       void playback_started (DCPTime time)
        {
                optional<boost::filesystem::path> log = Config::instance()->player_log_file();
                if (!log) {
@@ -246,15 +251,16 @@ public:
                FILE* f = fopen_boost(*log, "a");
                fprintf (
                        f,
-                       "%s playback-started %s %s\n",
+                       "%s playback-started %s %s %s\n",
                        dcp::LocalTime().as_string().c_str(),
+                       time.timecode(_film->video_frame_rate()).c_str(),
                        dcp->directories().front().string().c_str(),
                        playing_cpl->annotation_text().c_str()
                        );
                fclose (f);
        }
 
-       void playback_stopped ()
+       void playback_seeked (DCPTime time)
        {
                optional<boost::filesystem::path> log = Config::instance()->player_log_file();
                if (!log) {
@@ -262,7 +268,19 @@ public:
                }
 
                FILE* f = fopen_boost(*log, "a");
-               fprintf (f, "%s playback-stopped\n", dcp::LocalTime().as_string().c_str());
+               fprintf (f, "%s playback-seeked %s\n", dcp::LocalTime().as_string().c_str(), time.timecode(_film->video_frame_rate()).c_str());
+               fclose (f);
+       }
+
+       void playback_stopped (DCPTime time)
+       {
+               optional<boost::filesystem::path> log = Config::instance()->player_log_file();
+               if (!log) {
+                       return;
+               }
+
+               FILE* f = fopen_boost(*log, "a");
+               fprintf (f, "%s playback-stopped %s\n", dcp::LocalTime().as_string().c_str(), time.timecode(_film->video_frame_rate()).c_str());
                fclose (f);
        }
 
@@ -273,6 +291,13 @@ public:
                Config::instance()->set_decode_reduction (reduction);
        }
 
+       void eject_dcp ()
+       {
+               _film.reset (new Film (optional<boost::filesystem::path>()));
+               _viewer->set_film (_film);
+               _info->triggered_update ();
+       }
+
        void load_dcp (boost::filesystem::path dir)
        {
                _film.reset (new Film (optional<boost::filesystem::path>()));
@@ -355,8 +380,10 @@ private:
                optional<int> c = Config::instance()->decode_reduction();
                _view_cpl = view->Append(ID_view_cpl, _("CPL"), _cpl_menu);
                view->AppendSeparator();
+#ifndef DCPOMATIC_VARIANT_SWAROOP
                _view_full_screen = view->AppendCheckItem(ID_view_full_screen, _("Full screen\tF11"));
                _view_dual_screen = view->AppendCheckItem(ID_view_dual_screen, _("Dual screen\tShift+F11"));
+#endif
                setup_menu ();
                view->AppendSeparator();
                view->Append(ID_view_closed_captions, _("Closed captions..."));
@@ -547,13 +574,18 @@ private:
 
        void setup_menu ()
        {
-               _view_full_screen->Check (_mode == Config::PLAYER_MODE_FULL);
-               _view_dual_screen->Check (_mode == Config::PLAYER_MODE_DUAL);
+               if (_view_full_screen) {
+                       _view_full_screen->Check (_mode == Config::PLAYER_MODE_FULL);
+               }
+               if (_view_dual_screen) {
+                       _view_dual_screen->Check (_mode == Config::PLAYER_MODE_DUAL);
+               }
        }
 
        void setup_screen ()
        {
                _controls->Show (_mode != Config::PLAYER_MODE_FULL);
+               _controls->show_extended_player_controls (_mode == Config::PLAYER_MODE_DUAL);
                _info->Show (_mode != Config::PLAYER_MODE_FULL);
                _overall_panel->SetBackgroundColour (_mode == Config::PLAYER_MODE_FULL ? wxColour(0, 0, 0) : wxNullColour);
                ShowFullScreen (_mode == Config::PLAYER_MODE_FULL);