From 8daa6cfdc28752940ac6d4b9062c8a752a57f32b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 17 Oct 2011 17:52:31 +0000 Subject: [PATCH] When setting the start or end time of a subtitle line to the current video frame, if the resulting line duration would be less than one frame also update the other time Originally committed to SVN as r5742. --- aegisub/src/command/time.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/aegisub/src/command/time.cpp b/aegisub/src/command/time.cpp index 1e514782f..4070057af 100644 --- a/aegisub/src/command/time.cpp +++ b/aegisub/src/command/time.cpp @@ -160,21 +160,22 @@ struct time_shift : public Command { } }; -static void snap_subs_video(agi::Context *c, bool start) { +static void snap_subs_video(agi::Context *c, bool set_start) { std::set sel = c->selectionController->GetSelectedSet(); if (!c->videoController->IsLoaded() || sel.empty()) return; - int ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), start ? agi::vfr::START : agi::vfr::END); + int start = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START); + int end = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::END); for (std::set::iterator it = sel.begin(); it != sel.end(); ++it) { - if (start) - (*it)->Start.SetMS(ms); - else - (*it)->End.SetMS(ms); + if (set_start || (*it)->Start.GetMS() > start) + (*it)->Start.SetMS(start); + if (!set_start || (*it)->End.GetMS() < end) + (*it)->End.SetMS(end); } - c->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME); + c->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME); } /// Set end of selected subtitles to current video frame.