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.
This commit is contained in:
Thomas Goyne 2012-05-01 02:49:38 +00:00
parent 742cbf16aa
commit 1c4bb4a0e2

View file

@ -358,20 +358,19 @@ void DialogTimingProcessor::Process() {
std::vector<AssDialogue*> 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<int>);
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<int>);
}
if (addOut)
cur->End = safe_time(sorted.begin() + i + 1, sorted.end(), cur, cur->End + leadOut, &AssDialogue::Start, &std::min<int>);
}
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<int>);
}
// Make adjacent