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

View file

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