From cff3c0a3df0e90183c79df22aceaaef8a2779185 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 18 Apr 2014 19:10:05 -0700 Subject: [PATCH] Don't repopulate the actor/effect fields when the active line changes Speeds up switching lines on a totally arbitrary test file that doesn't even use very many actors or effects by ~20%. --- src/subs_edit_box.cpp | 10 +++++++--- src/subs_edit_box.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/subs_edit_box.cpp b/src/subs_edit_box.cpp index 6204084c7..d73593712 100644 --- a/src/subs_edit_box.cpp +++ b/src/subs_edit_box.cpp @@ -302,6 +302,10 @@ void SubsEditBox::OnCommit(int type) { if (!(type ^ AssFile::COMMIT_ORDER)) return; SetControlsState(!!line); + UpdateFields(type, true); +} + +void SubsEditBox::UpdateFields(int type, bool repopulate_lists) { if (!line) return; if (type & AssFile::COMMIT_DIAG_TIME) { @@ -322,11 +326,11 @@ void SubsEditBox::OnCommit(int type) { comment_box->SetValue(line->Comment); style_box->Select(style_box->FindString(to_wx(line->Style))); - PopulateList(effect_box, &AssDialogue::Effect); + if (repopulate_lists) PopulateList(effect_box, &AssDialogue::Effect); effect_box->ChangeValue(to_wx(line->Effect)); effect_box->SetStringSelection(to_wx(line->Effect)); - PopulateList(actor_box, &AssDialogue::Actor); + if (repopulate_lists) PopulateList(actor_box, &AssDialogue::Actor); actor_box->ChangeValue(to_wx(line->Actor)); actor_box->SetStringSelection(to_wx(line->Actor)); edit_ctrl->SetTextTo(line->Text); @@ -366,7 +370,7 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) { line = new_line; commit_id = -1; - OnCommit(AssFile::COMMIT_DIAG_FULL); + UpdateFields(AssFile::COMMIT_DIAG_FULL, false); /// @todo VideoContext should be doing this if (c->videoController->IsLoaded()) { diff --git a/src/subs_edit_box.h b/src/subs_edit_box.h index afa38ebad..c660ff65a 100644 --- a/src/subs_edit_box.h +++ b/src/subs_edit_box.h @@ -182,6 +182,8 @@ class SubsEditBox final : public wxPanel { /// @param type AssFile::COMMITType void OnCommit(int type); + void UpdateFields(int type, bool repopulate_lists); + /// Regenerate a dropdown list with the unique values of a dialogue field void PopulateList(wxComboBox *combo, boost::flyweight AssDialogue::*field);