Add hinting to the seek dialogue; may be a nice fix for #1736.
authorCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2020 20:03:37 +0000 (22:03 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2020 20:14:25 +0000 (22:14 +0200)
src/wx/controls.cc
src/wx/playhead_to_timecode_dialog.cc
src/wx/playhead_to_timecode_dialog.h
src/wx/timecode.h

index ec6d4ff4c523435b68ba9df23678a9fc8f4b313c..022ebfe29552df64e2c4d28296ee1e590296c5ae 100644 (file)
@@ -345,7 +345,7 @@ Controls::setup_sensitivity ()
 void
 Controls::timecode_clicked ()
 {
-       PlayheadToTimecodeDialog* dialog = new PlayheadToTimecodeDialog (this, _film->video_frame_rate ());
+       PlayheadToTimecodeDialog* dialog = new PlayheadToTimecodeDialog (this, _viewer->position(), _film->video_frame_rate());
        if (dialog->ShowModal() == wxID_OK) {
                _viewer->seek (dialog->get(), true);
        }
index c622111db52893f225b2fba264165a3e02455b8c..dda742fbc50d3e17934d3025d65f44d7912845b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 using namespace dcpomatic;
 
-PlayheadToTimecodeDialog::PlayheadToTimecodeDialog (wxWindow* parent, int fps)
+PlayheadToTimecodeDialog::PlayheadToTimecodeDialog (wxWindow* parent, dcpomatic::DCPTime time, int fps)
        : TableDialog (parent, _("Go to timecode"), 2, 1, true)
        , _fps (fps)
 {
        add (_("Go to"), true);
        _timecode = add (new Timecode<DCPTime> (this, false));
        _timecode->set_focus ();
+       _timecode->set_hint (time, fps);
 
        layout ();
 }
index 22697858263ffe366f85930a988fe9f090fe869a..15578cdbe84578f10274fdecdb26df14bcbdb291 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -24,7 +24,7 @@
 class PlayheadToTimecodeDialog : public TableDialog
 {
 public:
-       PlayheadToTimecodeDialog (wxWindow* parent, int fps);
+       PlayheadToTimecodeDialog (wxWindow* parent, dcpomatic::DCPTime time, int fps);
 
        dcpomatic::DCPTime get () const;
 
index bf658ba83172b2e6e4b53973be7976d689d09c96..0c99d536187cfeb61586cd9a28c1d91a62bebe08 100644 (file)
@@ -81,20 +81,44 @@ public:
                checked_set (_fixed, t.timecode (fps));
        }
 
+       void set_hint (T t, float fps)
+       {
+               int h;
+               int m;
+               int s;
+               int f;
+               t.split (fps, h, m, s, f);
+
+               _hours->SetHint (std_to_wx(dcp::raw_convert<std::string>(h)));
+               _minutes->SetHint (std_to_wx(dcp::raw_convert<std::string>(m)));
+               _seconds->SetHint (std_to_wx(dcp::raw_convert<std::string>(s)));
+               _frames->SetHint (std_to_wx(dcp::raw_convert<std::string>(f)));
+       }
+
        T get (float fps) const
        {
                T t;
-               std::string const h = wx_to_std (_hours->GetValue ());
+               std::string const h = value_or_hint (_hours);
                t += T::from_seconds (dcp::raw_convert<int>(h.empty() ? "0" : h) * 3600);
-               std::string const m = wx_to_std (_minutes->GetValue());
+               std::string const m = value_or_hint (_minutes);
                t += T::from_seconds (dcp::raw_convert<int>(m.empty() ? "0" : m) * 60);
-               std::string const s = wx_to_std (_seconds->GetValue());
+               std::string const s = value_or_hint (_seconds);
                t += T::from_seconds (dcp::raw_convert<int>(s.empty() ? "0" : s));
-               std::string const f = wx_to_std (_frames->GetValue());
+               std::string const f = value_or_hint (_frames);
                t += T::from_seconds (dcp::raw_convert<double>(f.empty() ? "0" : f) / fps);
 
                return t;
        }
+
+private:
+       std::string value_or_hint (wxTextCtrl const * t) const
+       {
+               if (!t->GetValue().IsEmpty()) {
+                       return wx_to_std (t->GetValue());
+               } else {
+                       return wx_to_std (t->GetHint());
+               }
+       }
 };
 
 #endif