From 1c4bb4a0e2ca484ab824953a18e13c3f87eff166 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 1 May 2012 02:49:38 +0000 Subject: [PATCH] Split Lead In and Lead Out into separate passes in the TPP This makes it so that if there is a gap between two lines but not enough space for both the full lead-in and lead-out to be added, adding lead-in to the second line will be prioritized over adding lead-out to the first line, which is usually the desired result. Originally committed to SVN as r6731. --- aegisub/src/dialog_timing_processor.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/aegisub/src/dialog_timing_processor.cpp b/aegisub/src/dialog_timing_processor.cpp index d5c37ae45..e8ffae7ea 100644 --- a/aegisub/src/dialog_timing_processor.cpp +++ b/aegisub/src/dialog_timing_processor.cpp @@ -358,20 +358,19 @@ void DialogTimingProcessor::Process() { std::vector sorted = SortDialogues(); if (sorted.empty()) return; - // Options - bool addIn = hasLeadIn->IsChecked() && leadIn; - bool addOut = hasLeadOut->IsChecked() && leadOut; - // Add lead-in/out - if (addIn || addOut) { - for (size_t i = 0; i < sorted.size(); ++i) { - AssDialogue *cur = sorted[i]; - if (addIn) - cur->Start = safe_time(sorted.rend() - i, sorted.rend(), cur, cur->Start - leadIn, &AssDialogue::End, &std::max); + if (hasLeadIn->IsChecked() && leadIn) { + for (size_t i = 0; i < sorted.size(); ++i) + sorted[i]->Start = safe_time(sorted.rend() - i, sorted.rend(), + sorted[i], sorted[i]->Start - leadIn, + &AssDialogue::End, &std::max); + } - if (addOut) - cur->End = safe_time(sorted.begin() + i + 1, sorted.end(), cur, cur->End + leadOut, &AssDialogue::Start, &std::min); - } + if (hasLeadOut->IsChecked() && leadOut) { + for (size_t i = 0; i < sorted.size(); ++i) + sorted[i]->End = safe_time(sorted.begin() + i + 1, sorted.end(), + sorted[i], sorted[i]->End + leadOut, + &AssDialogue::Start, &std::min); } // Make adjacent