Insert new lines before/after the active line rather than the first selected line

This commit is contained in:
Thomas Goyne 2012-10-14 08:21:41 -07:00
parent 610b2a9494
commit a40b76ea59
1 changed files with 10 additions and 10 deletions

View File

@ -124,21 +124,21 @@ struct subtitle_find_next : public Command {
};
static void insert_subtitle_at_video(agi::Context *c, bool after) {
int n = c->subsGrid->GetFirstSelRow();
// Create line to add
AssDialogue *def = new AssDialogue;
int video_ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), agi::vfr::START);
def->Start = video_ms;
def->End = video_ms + OPT_GET("Timing/Default Duration")->GetInt();
def->Style = c->subsGrid->GetDialogue(n)->Style;
def->Style = c->selectionController->GetActiveLine()->Style;
// Insert it
c->subsGrid->BeginBatch();
c->subsGrid->InsertLine(def, n, after);
c->subsGrid->SelectRow(n + (int)after);
c->subsGrid->SetActiveLine(def);
c->subsGrid->EndBatch();
entryIter pos = find(c->ass->Line.begin(), c->ass->Line.end(), c->selectionController->GetActiveLine());
if (after) ++pos;
c->ass->Line.insert(pos, def);
c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM);
SubtitleSelection sel;
sel.insert(def);
c->selectionController->SetSelectionAndActive(sel, def);
}
/// Inserts a line after current.