From 439953204388991b96fce215c62396a7b6d33acd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 13 Jun 2016 10:54:02 +0100 Subject: [PATCH] Add button to move things to the start of reels (#798). --- ChangeLog | 4 +++ src/wx/move_to_dialog.cc | 66 +++++++++++++++++++++++++++++++++++++++ src/wx/move_to_dialog.h | 39 +++++++++++++++++++++++ src/wx/timing_panel.cc | 32 +++++++++++++++++++ src/wx/timing_panel.h | 2 ++ src/wx/wscript | 1 + test/srt_subtitle_test.cc | 4 +-- test/wscript | 1 + 8 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 src/wx/move_to_dialog.cc create mode 100644 src/wx/move_to_dialog.h diff --git a/ChangeLog b/ChangeLog index b98c897c9..44b857dfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2016-06-13 c.hetherington + + * Add button to move things to the start of reels (#798). + 2016-06-08 Carl Hetherington * 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 index 000000000..cb3db90cc --- /dev/null +++ b/src/wx/move_to_dialog.cc @@ -0,0 +1,66 @@ +/* + 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 "move_to_dialog.h" +#include "lib/film.h" +#include +#include + +using std::list; +using boost::shared_ptr; +using boost::optional; + +MoveToDialog::MoveToDialog (wxWindow* parent, optional position, shared_ptr 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 film = _film.lock (); + DCPOMATIC_ASSERT (film); + list reels = film->reels (); + list::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 + + 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 "lib/dcpomatic_time.h" +#include +#include + +class Film; +class wxSpinCtrl; + +class MoveToDialog : public TableDialog +{ +public: + MoveToDialog (wxWindow* parent, boost::optional position, boost::shared_ptr film); + + DCPTime position () const; + +private: + boost::weak_ptr _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 (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 (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 position; + BOOST_FOREACH (shared_ptr 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 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* _position; + wxButton* _move_to_start_of_reel; Timecode* _full_length; Timecode* _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 diff --git a/test/srt_subtitle_test.cc b/test/srt_subtitle_test.cc index f441faffd..123d04d95 100644 --- a/test/srt_subtitle_test.cc +++ b/test/srt_subtitle_test.cc @@ -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" diff --git a/test/wscript b/test/wscript index 946aea4c5..b7ac654cd 100644 --- a/test/wscript +++ b/test/wscript @@ -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 -- 2.30.2