From: Carl Hetherington Date: Fri, 1 Jul 2016 22:37:01 +0000 (+0100) Subject: Add frame number dialog on frame position click. X-Git-Tag: v2.8.15~4 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=ee37079f77166aaa309ffe7b3475b4f79f88eaa8 Add frame number dialog on frame position click. --- diff --git a/ChangeLog b/ChangeLog index 645884eb2..2e690ef14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2016-07-01 Carl Hetherington - * 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 diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 5389b5d21..8019e9214 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -22,6 +22,10 @@ * @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 } @@ -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 ()); @@ -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 (); +} diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index bec32d814..a67820a8c 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -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; diff --git a/src/wx/playhead_to_frame_dialog.cc b/src/wx/playhead_to_frame_dialog.cc new file mode 100644 index 000000000..bb3c5b5fb --- /dev/null +++ b/src/wx/playhead_to_frame_dialog.cc @@ -0,0 +1,38 @@ +/* + Copyright (C) 2016 Carl Hetherington + + 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 . + +*/ + +#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 (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 index 000000000..b6a902a55 --- /dev/null +++ b/src/wx/playhead_to_frame_dialog.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2016 Carl Hetherington + + 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 . + +*/ + +#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; +}; diff --git a/src/wx/wscript b/src/wx/wscript index 11241411b..bb56ee5b8 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -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