summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-01 01:03:29 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-01 01:03:29 +0100
commitb8693a3bf32380733604aa6e80c9774de575ebe7 (patch)
treeca0c060984727ac6e3f8a76bdb06d5f3c668489d /src
parent3846dd867d5d155f08c7448c9d2b911f547ac41c (diff)
Add go-to-position dialogue when clicking on preview timecode.
Diffstat (limited to 'src')
-rw-r--r--src/wx/film_viewer.cc40
-rw-r--r--src/wx/film_viewer.h2
-rw-r--r--src/wx/playhead_to_timecode_dialog.cc37
-rw-r--r--src/wx/playhead_to_timecode_dialog.h34
-rw-r--r--src/wx/timecode.cc26
-rw-r--r--src/wx/timecode.h8
-rw-r--r--src/wx/wscript1
7 files changed, 121 insertions, 27 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index da980dafc..5389b5d21 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -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 ();
+}
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index c9f25fa65..bec32d814 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -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
index 000000000..f436df96e
--- /dev/null
+++ b/src/wx/playhead_to_timecode_dialog.cc
@@ -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
index 000000000..adce87434
--- /dev/null
+++ b/src/wx/playhead_to_timecode_dialog.h
@@ -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;
+};
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc
index 5890f30b5..8db605094 100644
--- a/src/wx/timecode.cc
+++ b/src/wx/timecode.cc
@@ -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
diff --git a/src/wx/timecode.h b/src/wx/timecode.h
index 18eddfdb4..d9fe4ee4c 100644
--- a/src/wx/timecode.h
+++ b/src/wx/timecode.h
@@ -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)
{
}
diff --git a/src/wx/wscript b/src/wx/wscript
index 57de1b0c3..11241411b 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -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