Mostly detangle the edit box from the subtitles grid

Originally committed to SVN as r5598.
This commit is contained in:
Thomas Goyne 2011-09-15 05:17:29 +00:00
parent 3c4191e649
commit 05da23b22f

View file

@ -328,12 +328,12 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
wxSizeEvent evt; wxSizeEvent evt;
OnSize(evt); OnSize(evt);
c->subsGrid->AddSelectionListener(this); c->selectionController->AddSelectionListener(this);
file_changed_slot = c->ass->AddCommitListener(&SubsEditBox::Update, this); file_changed_slot = c->ass->AddCommitListener(&SubsEditBox::Update, this);
context->videoController->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this); context->videoController->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this);
} }
SubsEditBox::~SubsEditBox() { SubsEditBox::~SubsEditBox() {
c->subsGrid->RemoveSelectionListener(this); c->selectionController->RemoveSelectionListener(this);
} }
void SubsEditBox::Update(int type) { void SubsEditBox::Update(int type) {
@ -348,13 +348,14 @@ void SubsEditBox::Update(int type) {
/// @todo maybe preserve selection over undo? /// @todo maybe preserve selection over undo?
ActorBox->Freeze(); ActorBox->Freeze();
ActorBox->Clear(); ActorBox->Clear();
int nrows = c->subsGrid->GetRows(); for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
for (int i=0;i<nrows;i++) { if (AssDialogue *diag = dynamic_cast<AssDialogue*>(*it)) {
wxString actor = c->subsGrid->GetDialogue(i)->Actor; wxString actor = diag->Actor;
// OSX doesn't like combo boxes that are empty. // OSX doesn't like combo boxes that are empty.
if (actor.empty()) actor = "Actor"; if (actor.empty()) actor = "Actor";
if (ActorBox->FindString(actor) == wxNOT_FOUND) { if (ActorBox->FindString(actor) == wxNOT_FOUND) {
ActorBox->Append(actor); ActorBox->Append(actor);
}
} }
} }
ActorBox->Thaw(); ActorBox->Thaw();
@ -416,7 +417,7 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
SetEvtHandlerEnabled(true); SetEvtHandlerEnabled(true);
} }
void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) { void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) {
sel = c->subsGrid->GetSelectedSet(); sel = c->selectionController->GetSelectedSet();
} }
void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) { void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
@ -451,16 +452,18 @@ void SubsEditBox::OnCommitButton(wxCommandEvent &) {
} }
void SubsEditBox::NextLine() { void SubsEditBox::NextLine() {
int next = c->subsGrid->GetLastSelRow() + 1; AssDialogue *cur = line;
if (next >= c->subsGrid->GetRows()) { c->selectionController->NextLine();
AssDialogue *cur = c->subsGrid->GetDialogue(next-1); if (line == cur) {
AssDialogue *newline = new AssDialogue; AssDialogue *newline = new AssDialogue;
newline->Start = cur->End; newline->Start = cur->End;
newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt(); newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt();
newline->Style = cur->Style; newline->Style = cur->Style;
c->subsGrid->InsertLine(newline,next-1,true,true);
entryIter pos = find(c->ass->Line.begin(), c->ass->Line.end(), line);
c->ass->Line.insert(++pos, newline);
c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM);
} }
c->subsGrid->NextLine();
} }
void SubsEditBox::OnChange(wxStyledTextEvent &event) { void SubsEditBox::OnChange(wxStyledTextEvent &event) {