Add button to move things to the start of reels (#798).
authorCarl Hetherington <cth@carlh.net>
Mon, 13 Jun 2016 09:54:02 +0000 (10:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 13 Jun 2016 09:54:02 +0000 (10:54 +0100)
ChangeLog
src/wx/move_to_dialog.cc [new file with mode: 0644]
src/wx/move_to_dialog.h [new file with mode: 0644]
src/wx/timing_panel.cc
src/wx/timing_panel.h
src/wx/wscript
test/srt_subtitle_test.cc
test/wscript

index b98c897c968f4456c68abee9f3495db173072375..44b857dfc552ca04826234fe61b2ab59f61adcef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-13  c.hetherington  <cth@carlh.net>
+
+       * Add button to move things to the start of reels (#798).
+
 2016-06-08  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.8.9 released.
diff --git a/src/wx/move_to_dialog.cc b/src/wx/move_to_dialog.cc
new file mode 100644 (file)
index 0000000..cb3db90
--- /dev/null
@@ -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 (file)
index 0000000..4d8d991
--- /dev/null
@@ -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;
+};
index 63606f46c734ab1d939497e03e7e185d4bf0ef1c..1e87f8e8debf5e0d360ab16a038103c15145278c 100644 (file)
@@ -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 ();
+}
index 2b92c6307cabcfc4af19c26999a23baf110bbb0b..0767daa09aaa82ecd9c849dbe7052c18e1ea48e8 100644 (file)
@@ -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;
index 8b75f056237705d33057d739c6333da714c70641..b5df3aca1010599728a8b81400058d5c0632bf56 100644 (file)
@@ -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
index f441faffdb1c298f24007751aeb091c481918a78..123d04d95778ed388b3c929be674500e56885973 100644 (file)
@@ -18,8 +18,8 @@
 
 */
 
-/** @file  test/subtitle_write_test.cc
- *  @brief Test writing DCPs with XML subtitles.
+/** @file  test/srt_subtitle_test.cc
+ *  @brief Test writing DCPs with subtitles from .srt.
  */
 
 #include "lib/film.h"
index 946aea4c5f80c28dfd0f8b99674eb6d6b14ad7d6..b7ac654cd5df8a9c44e8e7f7104c34650b1b21fe 100644 (file)
@@ -85,6 +85,7 @@ def build(bld):
                  silence_padding_test.cc
                  skip_frame_test.cc
                  srt_subtitle_test.cc
+                 ssa_subtitle_test.cc
                  stream_test.cc
                  test.cc
                  threed_test.cc