void AudioTimingControllerKaraoke::Revert() { active_line = c->selectionController->GetActiveLine(); cur_syl = 0; commit_id = -1; pending_changes = false; start_marker.Move(active_line->Start); end_marker.Move(active_line->End); markers.clear(); labels.clear(); markers.reserve(kara->size()); labels.reserve(kara->size()); for (auto it = kara->begin(); it != kara->end(); ++it) { if (it != kara->begin()) markers.emplace_back(it->start_time, &separator_pen, AudioMarker::Feet_None); labels.emplace_back(it->text, TimeRange(it->start_time, it->start_time + it->duration)); } AnnounceUpdatedPrimaryRange(); AnnounceUpdatedStyleRanges(); AnnounceMarkerMoved(); }
void AssKaraoke::SplitLines(std::set<AssDialogue*> const& lines, agi::Context *c) { if (lines.empty()) return; AssKaraoke kara; SubtitleSelection sel = c->selectionController->GetSelectedSet(); bool did_split = false; for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) { AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it); if (!diag || !lines.count(diag)) continue; kara.SetLine(diag); // If there aren't at least two tags there's nothing to split if (kara.size() < 2) continue; bool in_sel = sel.count(diag) > 0; for (auto const& syl : kara) { AssDialogue *new_line = new AssDialogue(*diag); new_line->Start = syl.start_time; new_line->End = syl.start_time + syl.duration; new_line->Text = syl.GetText(false); c->ass->Line.insert(it, *new_line); if (in_sel) sel.insert(new_line); } --it; // Move `it` to the last of the new lines sel.erase(diag); delete diag; did_split = true; } if (!did_split) return; c->ass->Commit(_("splitting"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL); AssDialogue *new_active = c->selectionController->GetActiveLine(); if (!sel.count(c->selectionController->GetActiveLine())) new_active = *sel.begin(); c->selectionController->SetSelectionAndActive(sel, new_active); }