diff --git a/aegisub/src/command/tool.cpp b/aegisub/src/command/tool.cpp index 632120eb6..61e8c4c26 100644 --- a/aegisub/src/command/tool.cpp +++ b/aegisub/src/command/tool.cpp @@ -187,8 +187,14 @@ struct tool_style_manager : public Command { STR_HELP("Open styles manager") void operator()(agi::Context *c) { - c->videoController->Stop(); - DialogStyleManager(c).ShowModal(); + if (c->stylesManager) { + c->stylesManager->Show(); + c->stylesManager->SetFocus(); + } + else { + c->stylesManager = new DialogStyleManager(c); + c->stylesManager->Show(); + } } }; diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index cb561f2ef..1bc2f8ae9 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -275,10 +275,12 @@ DialogStyleManager::DialogStyleManager(agi::Context *context) CurrentList->Bind(wxEVT_COMMAND_LISTBOX_SELECTED, bind(&DialogStyleManager::UpdateButtons, this)); CurrentList->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, bind(&DialogStyleManager::OnCurrentEdit, this)); + + c->selectionController->AddSelectionListener(this); } DialogStyleManager::~DialogStyleManager() { - c->ass->SetScriptInfo("Last Style Storage", CatalogList->GetStringSelection()); + c->selectionController->RemoveSelectionListener(this); } void DialogStyleManager::LoadCurrentStyles(int commit_type) { @@ -296,6 +298,7 @@ void DialogStyleManager::LoadCurrentStyles(int commit_type) { if (commit_type & AssFile::COMMIT_DIAG_META) { AssDialogue *dia = c->selectionController->GetActiveLine(); + CurrentList->DeselectAll(); if (dia && commit_type != AssFile::COMMIT_NEW) CurrentList->SetStringSelection(dia->Style); else @@ -305,6 +308,14 @@ void DialogStyleManager::LoadCurrentStyles(int commit_type) { UpdateButtons(); } +void DialogStyleManager::OnActiveLineChanged(AssDialogue *new_line) { + if (new_line) { + CurrentList->DeselectAll(); + CurrentList->SetStringSelection(new_line->Style); + UpdateButtons(); + } +} + void DialogStyleManager::UpdateStorage() { Store.Save(); @@ -316,6 +327,7 @@ void DialogStyleManager::UpdateStorage() { } void DialogStyleManager::OnChangeCatalog() { + c->ass->SetScriptInfo("Last Style Storage", CatalogList->GetStringSelection()); Store.Load(CatalogList->GetStringSelection()); UpdateStorage(); } diff --git a/aegisub/src/dialog_style_manager.h b/aegisub/src/dialog_style_manager.h index 703ffaff6..6afe4e488 100644 --- a/aegisub/src/dialog_style_manager.h +++ b/aegisub/src/dialog_style_manager.h @@ -47,8 +47,10 @@ #include #include "ass_style_storage.h" +#include "selection_controller.h" namespace agi { struct Context; } +class AssDialogue; class AssFile; class AssStyle; class DialogStyleEditor; @@ -59,7 +61,7 @@ class PersistLocation; /// @brief DOCME /// /// DOCME -class DialogStyleManager : public wxDialog { +class DialogStyleManager : public wxDialog, private SelectionListener { agi::Context *c; ///< Project context agi::scoped_ptr persist; @@ -127,17 +129,21 @@ class DialogStyleManager : public wxDialog { void OnChangeCatalog(); void OnCatalogNew(); void OnCatalogDelete(); - void OnStorageEdit(); - void OnCurrentEdit(); - void OnCopyToStorage(); + void OnCopyToCurrent(); - void OnStorageCopy(); + void OnCopyToStorage(); + void OnCurrentCopy(); - void OnStorageNew(); - void OnCurrentNew(); - void OnStorageDelete(); void OnCurrentDelete(); + void OnCurrentEdit(); void OnCurrentImport(); + void OnCurrentNew(); + + void OnStorageCopy(); + void OnStorageDelete(); + void OnStorageEdit(); + void OnStorageNew(); + void OnKeyDown(wxKeyEvent &event); void PasteToCurrent(); void PasteToStorage(); @@ -145,6 +151,9 @@ class DialogStyleManager : public wxDialog { template void CopyToClipboard(wxListBox *list, T const& v); + void OnActiveLineChanged(AssDialogue *new_line); + void OnSelectedSetChanged(const Selection &, const Selection &) { } + public: DialogStyleManager(agi::Context *context); ~DialogStyleManager(); diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 558ad5e07..a4b898122 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -182,6 +182,7 @@ FrameMain::FrameMain (wxArrayString args) StartupLog("Create views and inner main window controls"); context->detachedVideo = 0; context->stylingAssistant = 0; + context->stylesManager = 0; InitContents(); OPT_SUB("Video/Detached/Enabled", &FrameMain::OnVideoDetach, this, agi::signal::_1); diff --git a/aegisub/src/include/aegisub/context.h b/aegisub/src/include/aegisub/context.h index 7c068892b..16a871b2f 100644 --- a/aegisub/src/include/aegisub/context.h +++ b/aegisub/src/include/aegisub/context.h @@ -5,6 +5,7 @@ class AssDialogue; class AudioKaraoke; class DialogDetachedVideo; class DialogStyling; +class DialogStyleManager; class DialogTranslation; template class SelectionController; class SubsTextEditCtrl; @@ -36,6 +37,7 @@ struct Context { AudioKaraoke *karaoke; DialogDetachedVideo *detachedVideo; DialogStyling *stylingAssistant; + DialogStyleManager *stylesManager; DialogTranslation *translationAssistant; SubsTextEditCtrl *editBox; SubtitlesGrid *subsGrid;