Add go-to-position dialogue when clicking on preview timecode.
authorCarl Hetherington <cth@carlh.net>
Fri, 1 Jul 2016 00:03:29 +0000 (01:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 1 Jul 2016 00:03:29 +0000 (01:03 +0100)
ChangeLog
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/playhead_to_timecode_dialog.cc [new file with mode: 0644]
src/wx/playhead_to_timecode_dialog.h [new file with mode: 0644]
src/wx/timecode.cc
src/wx/timecode.h
src/wx/wscript

index 93c68100bb120b0fad4295ccf53b708cad06822e..645884eb218ed76d597137189ce081fd2027785b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-07-01  Carl Hetherington  <cth@carlh.net>
+
+       * Add move-to-position dialog when clicking on the preview timecode.
+
 2016-06-29  Carl Hetherington  <cth@carlh.net>
 
        * Updated nl_NL translation from Rob van Nieuwkerk.
index da980dafccda4500d12ffae24bf87f6a804182c5..5389b5d21fd22c48290d314ef482bb774e56b2be 100644 (file)
@@ -37,6 +37,7 @@
 #include "lib/timer.h"
 #include "lib/log.h"
 #include "film_viewer.h"
+#include "playhead_to_timecode_dialog.h"
 #include "wx_util.h"
 extern "C" {
 #include <libavutil/pixfmt.h>
@@ -124,6 +125,7 @@ FilmViewer::FilmViewer (wxWindow* p)
        _timer.Bind           (wxEVT_TIMER,                        boost::bind (&FilmViewer::timer,           this));
        _back_button->Bind    (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::back_clicked,    this, _1));
        _forward_button->Bind (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::forward_clicked, this, _1));
+       _timecode->Bind       (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::timecode_clicked, this));
 
        set_film (shared_ptr<Film> ());
 
@@ -465,32 +467,32 @@ FilmViewer::nudge_amount (wxMouseEvent& ev)
 }
 
 void
-FilmViewer::back_clicked (wxMouseEvent& ev)
+FilmViewer::go_to (DCPTime t)
 {
-       DCPTime p = _position - nudge_amount (ev);
-       if (p < DCPTime ()) {
-               p = DCPTime ();
+       if (t < DCPTime ()) {
+               t = DCPTime ();
        }
 
-       get (p, true);
+       if (t >= _film->length ()) {
+               t = _film->length ();
+       }
+
+       get (t, true);
        update_position_label ();
        update_position_slider ();
+}
 
+void
+FilmViewer::back_clicked (wxMouseEvent& ev)
+{
+       go_to (_position - nudge_amount (ev));
        ev.Skip ();
 }
 
 void
 FilmViewer::forward_clicked (wxMouseEvent& ev)
 {
-       DCPTime p = _position + nudge_amount (ev);
-       if (p >= _film->length ()) {
-               p = _position;
-       }
-
-       get (p, true);
-       update_position_label ();
-       update_position_slider ();
-
+       go_to (_position + nudge_amount (ev));
        ev.Skip ();
 }
 
@@ -566,3 +568,13 @@ FilmViewer::set_coalesce_player_changes (bool c)
                }
        }
 }
+
+void
+FilmViewer::timecode_clicked ()
+{
+       PlayheadToTimecodeDialog* dialog = new PlayheadToTimecodeDialog (this, _film->video_frame_rate ());
+       if (dialog->ShowModal() == wxID_OK) {
+               go_to (dialog->get ());
+       }
+       dialog->Destroy ();
+}
index c9f25fa65dab2f67a397491fdf6072897376f955..bec32d814c67214892933f4897ee0fe977def750 100644 (file)
@@ -71,6 +71,8 @@ private:
        void setup_sensitivity ();
        void film_changed (Film::Property);
        DCPTime nudge_amount (wxMouseEvent &);
+       void timecode_clicked ();
+       void go_to (DCPTime t);
 
        boost::shared_ptr<Film> _film;
        boost::shared_ptr<Player> _player;
diff --git a/src/wx/playhead_to_timecode_dialog.cc b/src/wx/playhead_to_timecode_dialog.cc
new file mode 100644 (file)
index 0000000..f436df9
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "playhead_to_timecode_dialog.h"
+
+PlayheadToTimecodeDialog::PlayheadToTimecodeDialog (wxWindow* parent, int fps)
+       : TableDialog (parent, _("Move to timecode"), 2, 1, true)
+       , _fps (fps)
+{
+       add (_("Go to"), true);
+       _timecode = add (new Timecode<DCPTime> (this, false));
+
+       layout ();
+}
+
+DCPTime
+PlayheadToTimecodeDialog::get () const
+{
+       return _timecode->get (_fps);
+}
diff --git a/src/wx/playhead_to_timecode_dialog.h b/src/wx/playhead_to_timecode_dialog.h
new file mode 100644 (file)
index 0000000..adce874
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "table_dialog.h"
+#include "timecode.h"
+
+class PlayheadToTimecodeDialog : public TableDialog
+{
+public:
+       PlayheadToTimecodeDialog (wxWindow* parent, int fps);
+
+       DCPTime get () const;
+
+private:
+       Timecode<DCPTime>* _timecode;
+       int _fps;
+};
index 5890f30b58b33e143f81c90cd6f3bdfa2aa1144e..8db6050943caff69504ff09324650251a2fa4282 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -26,8 +26,9 @@
 using std::string;
 using std::cout;
 
-TimecodeBase::TimecodeBase (wxWindow* parent)
+TimecodeBase::TimecodeBase (wxWindow* parent, bool set_button)
        : wxPanel (parent)
+       , _set_button (0)
 {
        wxSize const s = TimecodeBase::size (parent);
 
@@ -60,8 +61,10 @@ TimecodeBase::TimecodeBase (wxWindow* parent)
        _frames = new wxTextCtrl (_editable, wxID_ANY, wxT(""), wxDefaultPosition, s, 0, validator);
        _frames->SetMaxLength (2);
        editable_sizer->Add (_frames);
-       _set_button = new wxButton (_editable, wxID_ANY, _("Set"));
-       editable_sizer->Add (_set_button, 0, wxLEFT | wxRIGHT, 8);
+       if (set_button) {
+               _set_button = new wxButton (_editable, wxID_ANY, _("Set"));
+               editable_sizer->Add (_set_button, 0, wxLEFT | wxRIGHT, 8);
+       }
        _editable->SetSizerAndFit (editable_sizer);
        _sizer->Add (_editable);
 
@@ -71,9 +74,10 @@ TimecodeBase::TimecodeBase (wxWindow* parent)
        _minutes->Bind    (wxEVT_COMMAND_TEXT_UPDATED,   boost::bind (&TimecodeBase::changed, this));
        _seconds->Bind    (wxEVT_COMMAND_TEXT_UPDATED,   boost::bind (&TimecodeBase::changed, this));
        _frames->Bind     (wxEVT_COMMAND_TEXT_UPDATED,   boost::bind (&TimecodeBase::changed, this));
-       _set_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimecodeBase::set_clicked, this));
-
-       _set_button->Enable (false);
+       if (_set_button) {
+               _set_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimecodeBase::set_clicked, this));
+               _set_button->Enable (false);
+       }
 
        set_editable (true);
 
@@ -93,14 +97,18 @@ TimecodeBase::clear ()
 void
 TimecodeBase::changed ()
 {
-       _set_button->Enable (true);
+       if (_set_button) {
+               _set_button->Enable (true);
+       }
 }
 
 void
 TimecodeBase::set_clicked ()
 {
        Changed ();
-       _set_button->Enable (false);
+       if (_set_button) {
+               _set_button->Enable (false);
+       }
 }
 
 void
index 18eddfdb4a19b72fa2eb854e46b53f01e0d453fc..d9fe4ee4c96af761b0adc5238a82d4a2cd9fa8a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -30,7 +30,7 @@
 class TimecodeBase : public wxPanel
 {
 public:
-       TimecodeBase (wxWindow *);
+       TimecodeBase (wxWindow *, bool set_button);
 
        void clear ();
 
@@ -58,8 +58,8 @@ template <class T>
 class Timecode : public TimecodeBase
 {
 public:
-       Timecode (wxWindow* parent)
-               : TimecodeBase (parent)
+       Timecode (wxWindow* parent, bool set_button = true)
+               : TimecodeBase (parent, set_button)
        {
 
        }
index 57de1b0c3890cd5dddd885ea692afa1df2274099..11241411be3b5cb8f0cd317362bf38f365760e5c 100644 (file)
@@ -69,6 +69,7 @@ sources = """
           make_chain_dialog.cc
           move_to_dialog.cc
           new_film_dialog.cc
+          playhead_to_timecode_dialog.cc
           repeat_dialog.cc
           report_problem_dialog.cc
           rgba_colour_picker.cc