diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index 69396a513..21c1f2cb4 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -58,7 +58,6 @@ #include #include -#include #include #include #include @@ -140,7 +139,7 @@ static wxTextCtrl *num_text_ctrl(wxWindow *parent, double value, bool allow_nega return new wxTextCtrl(parent, -1, "", wxDefaultPosition, size, 0, NumValidator(value, allow_negative)); } -DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store, std::string const& new_name) +DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store, std::string const& new_name, wxArrayString const& font_list) : wxDialog (parent, -1, _("Style Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , c(c) , is_new(false) @@ -164,8 +163,6 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con // Prepare control values wxString EncodingValue = std::to_wstring(style->encoding); wxString alignValues[9] = { "7", "8", "9", "4", "5", "6", "1", "2", "3" }; - wxArrayString fontList = wxFontEnumerator::GetFacenames(); - fontList.Sort(); // Encoding options wxArrayString encodingStrings; @@ -236,7 +233,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con Alignment->SetSelection(AlignToControl(style->alignment)); // Fill font face list box FontName->Freeze(); - FontName->Append(fontList); + FontName->Append(font_list); FontName->SetValue(to_wx(style->font)); FontName->Thaw(); diff --git a/aegisub/src/dialog_style_editor.h b/aegisub/src/dialog_style_editor.h index 9fc6d3df3..1ed545869 100644 --- a/aegisub/src/dialog_style_editor.h +++ b/aegisub/src/dialog_style_editor.h @@ -105,7 +105,7 @@ class DialogStyleEditor : public wxDialog { void OnSetColor(wxThreadEvent& evt); public: - DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store = 0, std::string const& new_name = ""); + DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store, std::string const& new_name, wxArrayString const& font_list); ~DialogStyleEditor(); std::string GetStyleName() const; diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 4a9493fe8..e2e39ac80 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -64,6 +64,7 @@ #include #include +#include #include #include #include @@ -159,6 +160,11 @@ DialogStyleManager::DialogStyleManager(agi::Context *context) , c(context) , commit_connection(c->ass->AddCommitListener(&DialogStyleManager::LoadCurrentStyles, this)) , active_line_connection(c->selectionController->AddActiveLineListener(&DialogStyleManager::OnActiveLineChanged, this)) +, font_list(std::async(std::launch::async, []() -> wxArrayString { + wxArrayString fontList = wxFontEnumerator::GetFacenames(); + fontList.Sort(); + return fontList; +})) { using std::bind; SetIcon(GETICON(style_toolbutton_16)); @@ -486,7 +492,7 @@ void DialogStyleManager::PasteToStorage() { } void DialogStyleManager::ShowStorageEditor(AssStyle *style, std::string const& new_name) { - DialogStyleEditor editor(this, style, c, &Store, new_name); + DialogStyleEditor editor(this, style, c, &Store, new_name, font_list.get()); if (editor.ShowModal()) { UpdateStorage(); StorageList->SetStringSelection(to_wx(editor.GetStyleName())); @@ -495,7 +501,7 @@ void DialogStyleManager::ShowStorageEditor(AssStyle *style, std::string const& n } void DialogStyleManager::OnStorageNew() { - ShowStorageEditor(0); + ShowStorageEditor(nullptr); } void DialogStyleManager::OnStorageEdit() { @@ -524,7 +530,7 @@ void DialogStyleManager::OnStorageDelete() { } void DialogStyleManager::ShowCurrentEditor(AssStyle *style, std::string const& new_name) { - DialogStyleEditor editor(this, style, c, 0, new_name); + DialogStyleEditor editor(this, style, c, nullptr, new_name, font_list.get()); if (editor.ShowModal()) { CurrentList->DeselectAll(); CurrentList->SetStringSelection(to_wx(editor.GetStyleName())); @@ -533,7 +539,7 @@ void DialogStyleManager::ShowCurrentEditor(AssStyle *style, std::string const& n } void DialogStyleManager::OnCurrentNew() { - ShowCurrentEditor(0); + ShowCurrentEditor(nullptr); } void DialogStyleManager::OnCurrentEdit() { diff --git a/aegisub/src/dialog_style_manager.h b/aegisub/src/dialog_style_manager.h index 7a3e407e5..6a848d852 100644 --- a/aegisub/src/dialog_style_manager.h +++ b/aegisub/src/dialog_style_manager.h @@ -32,6 +32,7 @@ /// @ingroup style_editor /// +#include #include #include @@ -58,6 +59,8 @@ class DialogStyleManager : public wxDialog { agi::signal::Connection commit_connection; agi::signal::Connection active_line_connection; + std::shared_future font_list; + /// Styles in the current subtitle file std::vector styleMap;