summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-06-13 10:54:02 +0100
committerCarl Hetherington <cth@carlh.net>2016-06-13 10:54:02 +0100
commit439953204388991b96fce215c62396a7b6d33acd (patch)
tree6a21758ac7d22d52909af18753dfd7391fc742ef /src
parent38e73a895fb6145391c2c43cc97783a3eaf50cc5 (diff)
Add button to move things to the start of reels (#798).
Diffstat (limited to 'src')
-rw-r--r--src/wx/move_to_dialog.cc66
-rw-r--r--src/wx/move_to_dialog.h39
-rw-r--r--src/wx/timing_panel.cc32
-rw-r--r--src/wx/timing_panel.h2
-rw-r--r--src/wx/wscript1
5 files changed, 140 insertions, 0 deletions
diff --git a/src/wx/move_to_dialog.cc b/src/wx/move_to_dialog.cc
new file mode 100644
index 000000000..cb3db90cc
--- /dev/null
+++ b/src/wx/move_to_dialog.cc
@@ -0,0 +1,66 @@
+/*
+ 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 "move_to_dialog.h"
+#include "lib/film.h"
+#include <wx/spinctrl.h>
+#include <boost/foreach.hpp>
+
+using std::list;
+using boost::shared_ptr;
+using boost::optional;
+
+MoveToDialog::MoveToDialog (wxWindow* parent, optional<DCPTime> position, shared_ptr<const Film> film)
+ : TableDialog (parent, _("Move content"), 2, 0, true)
+ , _film (film)
+{
+ add (_("Start of reel"), true);
+ _reel = new wxSpinCtrl (this, wxID_ANY);
+ _reel->SetRange (1, film->reels().size());
+ add (_reel);
+
+ layout ();
+
+ if (position) {
+ int j = 0;
+ BOOST_FOREACH (DCPTimePeriod i, film->reels()) {
+ if (i.from == position.get()) {
+ _reel->SetValue (j + 1);
+ }
+ ++j;
+ }
+ }
+}
+
+DCPTime
+MoveToDialog::position () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ DCPOMATIC_ASSERT (film);
+ list<DCPTimePeriod> reels = film->reels ();
+ list<DCPTimePeriod>::const_iterator i = reels.begin ();
+ for (int j = 0; j < _reel->GetValue() - 1; ++j) {
+ DCPOMATIC_ASSERT (i != reels.end());
+ ++i;
+ }
+
+ DCPOMATIC_ASSERT (i != reels.end());
+ return i->from;
+}
diff --git a/src/wx/move_to_dialog.h b/src/wx/move_to_dialog.h
new file mode 100644
index 000000000..4d8d991f5
--- /dev/null
+++ b/src/wx/move_to_dialog.h
@@ -0,0 +1,39 @@
+/*
+ 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 "lib/dcpomatic_time.h"
+#include <boost/weak_ptr.hpp>
+#include <boost/optional.hpp>
+
+class Film;
+class wxSpinCtrl;
+
+class MoveToDialog : public TableDialog
+{
+public:
+ MoveToDialog (wxWindow* parent, boost::optional<DCPTime> position, boost::shared_ptr<const Film> film);
+
+ DCPTime position () const;
+
+private:
+ boost::weak_ptr<const Film> _film;
+ wxSpinCtrl* _reel;
+};
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 63606f46c..1e87f8e8d 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -23,6 +23,7 @@
#include "film_viewer.h"
#include "timecode.h"
#include "content_panel.h"
+#include "move_to_dialog.h"
#include "lib/content.h"
#include "lib/image_content.h"
#include "lib/raw_convert.h"
@@ -88,6 +89,9 @@ TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer)
add_label_to_sizer (grid, this, _("Position"), true);
_position = new Timecode<DCPTime> (this);
grid->Add (_position);
+ _move_to_start_of_reel = new wxButton (this, wxID_ANY, _("Move to start of reel"));
+ grid->AddSpacer (0);
+ grid->Add (_move_to_start_of_reel);
add_label_to_sizer (grid, this, _("Full length"), true);
_full_length = new Timecode<DCPTime> (this);
grid->Add (_full_length);
@@ -143,6 +147,7 @@ TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer)
grid->Add (t, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 6);
_position->Changed.connect (boost::bind (&TimingPanel::position_changed, this));
+ _move_to_start_of_reel->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::move_to_start_of_reel_clicked, this));
_full_length->Changed.connect (boost::bind (&TimingPanel::full_length_changed, this));
_trim_start->Changed.connect (boost::bind (&TimingPanel::trim_start_changed, this));
_trim_start_to_playhead->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::trim_start_to_playhead_clicked, this));
@@ -477,3 +482,30 @@ TimingPanel::setup_sensitivity ()
_trim_start_to_playhead->Enable (any_over_ph);
_trim_end_to_playhead->Enable (any_over_ph);
}
+
+void
+TimingPanel::move_to_start_of_reel_clicked ()
+{
+ /* Find common position of all selected content, if it exists */
+
+ optional<DCPTime> position;
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ if (!position) {
+ position = i->position();
+ } else {
+ if (position.get() != i->position()) {
+ position.reset ();
+ break;
+ }
+ }
+ }
+
+ MoveToDialog* d = new MoveToDialog (this, position, _parent->film());
+
+ if (d->ShowModal() == wxID_OK) {
+ BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+ i->set_position (d->position ());
+ }
+ }
+ d->Destroy ();
+}
diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h
index 2b92c6307..0767daa09 100644
--- a/src/wx/timing_panel.h
+++ b/src/wx/timing_panel.h
@@ -34,6 +34,7 @@ public:
private:
void position_changed ();
+ void move_to_start_of_reel_clicked ();
void full_length_changed ();
void trim_start_changed ();
void trim_start_to_playhead_clicked ();
@@ -49,6 +50,7 @@ private:
FilmViewer* _viewer;
Timecode<DCPTime>* _position;
+ wxButton* _move_to_start_of_reel;
Timecode<DCPTime>* _full_length;
Timecode<ContentTime>* _trim_start;
wxButton* _trim_start_to_playhead;
diff --git a/src/wx/wscript b/src/wx/wscript
index 8b75f0562..b5df3aca1 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -67,6 +67,7 @@ sources = """
kdm_timing_panel.cc
key_dialog.cc
make_chain_dialog.cc
+ move_to_dialog.cc
new_film_dialog.cc
repeat_dialog.cc
report_problem_dialog.cc