From 24ad14effd3fd53e29c70bef9d47ad434dd0bb4f Mon Sep 17 00:00:00 2001 From: Tomas Partl Date: Tue, 21 Sep 2021 11:58:51 +0200 Subject: [PATCH] Improved Set Start from Player, so that it moves the whole selection to the new start. --- plugins/actions/timingfromplayer/timingfromplayer.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/actions/timingfromplayer/timingfromplayer.cc b/plugins/actions/timingfromplayer/timingfromplayer.cc index 22992035..7fe8c547 100644 --- a/plugins/actions/timingfromplayer/timingfromplayer.cc +++ b/plugins/actions/timingfromplayer/timingfromplayer.cc @@ -269,15 +269,20 @@ class TimingFromPlayer : public Action { if (player->get_state() == Player::PLAYING) pos = pos - get_prefered_offset(); - SubtitleTime dur = sub.get_duration(); - // Start recording doc->start_command(get_command_name_from_option(op)); if (op & SET_SUBTITLE_START) { // Define the start of the subtitle from the // video position, we keep the duration - sub.set_start_and_end(pos, pos + dur); + std::vector selection = doc->subtitles().get_selection(); + std::vector::iterator it = selection.begin(); + std::vector::iterator eit = selection.end(); + SubtitleTime diff = pos - it->get_start(); + while( it != eit ) { + it->set_start_and_end(it->get_start()+diff, it->get_end()+diff); + ++it; + } } else if (op & SET_SUBTITLE_END) { sub.set_end(pos); }