Add frame number dialog on frame position click.
authorCarl Hetherington <cth@carlh.net>
Fri, 1 Jul 2016 22:37:01 +0000 (23:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 1 Jul 2016 22:37:01 +0000 (23:37 +0100)
ChangeLog
src/wx/film_viewer.cc
src/wx/film_viewer.h
src/wx/playhead_to_frame_dialog.cc [new file with mode: 0644]
src/wx/playhead_to_frame_dialog.h [new file with mode: 0644]
src/wx/wscript

index 645884eb218ed76d597137189ce081fd2027785b..2e690ef147be6b8ffd226d1473d32e1fc64ff239 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2016-07-01  Carl Hetherington  <cth@carlh.net>
 
-       * Add move-to-position dialog when clicking on the preview timecode.
+       * Add move-to-position dialogs when clicking on the preview timecode
+       or frame number.
 
 2016-06-29  Carl Hetherington  <cth@carlh.net>
 
index 5389b5d21fd22c48290d314ef482bb774e56b2be..8019e9214e4ad040c7715c8adc750d8b9820fc84 100644 (file)
  *  @brief A wx widget to view a preview of a Film.
  */
 
+#include "film_viewer.h"
+#include "playhead_to_timecode_dialog.h"
+#include "playhead_to_frame_dialog.h"
+#include "wx_util.h"
 #include "lib/film.h"
 #include "lib/ratio.h"
 #include "lib/util.h"
@@ -36,9 +40,6 @@
 #include "lib/video_decoder.h"
 #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>
 }
@@ -125,6 +126,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));
+       _frame_number->Bind   (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::frame_number_clicked, this));
        _timecode->Bind       (wxEVT_LEFT_DOWN,                    boost::bind (&FilmViewer::timecode_clicked, this));
 
        set_film (shared_ptr<Film> ());
@@ -578,3 +580,13 @@ FilmViewer::timecode_clicked ()
        }
        dialog->Destroy ();
 }
+
+void
+FilmViewer::frame_number_clicked ()
+{
+       PlayheadToFrameDialog* dialog = new PlayheadToFrameDialog (this, _film->video_frame_rate ());
+       if (dialog->ShowModal() == wxID_OK) {
+               go_to (dialog->get ());
+       }
+       dialog->Destroy ();
+}
index bec32d814c67214892933f4897ee0fe977def750..a67820a8ca21229e2b7ef8f40dfaaba7cf617596 100644 (file)
@@ -72,6 +72,7 @@ private:
        void film_changed (Film::Property);
        DCPTime nudge_amount (wxMouseEvent &);
        void timecode_clicked ();
+       void frame_number_clicked ();
        void go_to (DCPTime t);
 
        boost::shared_ptr<Film> _film;
diff --git a/src/wx/playhead_to_frame_dialog.cc b/src/wx/playhead_to_frame_dialog.cc
new file mode 100644 (file)
index 0000000..bb3c5b5
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+    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_frame_dialog.h"
+#include "lib/raw_convert.h"
+
+PlayheadToFrameDialog::PlayheadToFrameDialog (wxWindow* parent, int fps)
+       : TableDialog (parent, _("Move to frame"), 2, 1, true)
+       , _fps (fps)
+{
+       add (_("Go to"), true);
+       _frame = add (new wxTextCtrl (this, wxID_ANY, wxT ("")));
+
+       layout ();
+}
+
+DCPTime
+PlayheadToFrameDialog::get () const
+{
+       return DCPTime::from_frames (raw_convert<Frame> (wx_to_std (_frame->GetValue ())) - 1, _fps);
+}
diff --git a/src/wx/playhead_to_frame_dialog.h b/src/wx/playhead_to_frame_dialog.h
new file mode 100644 (file)
index 0000000..b6a902a
--- /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 PlayheadToFrameDialog : public TableDialog
+{
+public:
+       PlayheadToFrameDialog (wxWindow* parent, int fps);
+
+       DCPTime get () const;
+
+private:
+       wxTextCtrl* _frame;
+       int _fps;
+};
index 11241411be3b5cb8f0cd317362bf38f365760e5c..bb56ee5b85fc3cf23f0be81bf106c192085eca72 100644 (file)
@@ -70,6 +70,7 @@ sources = """
           move_to_dialog.cc
           new_film_dialog.cc
           playhead_to_timecode_dialog.cc
+          playhead_to_frame_dialog.cc
           repeat_dialog.cc
           report_problem_dialog.cc
           rgba_colour_picker.cc