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 b98c897..44b857d 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 63606f4..1e87f8e 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 2b92c63..0767daa 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 8b75f05..b5df3ac 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 f441faf..123d04d 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 946aea4..b7ac654 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