Make the style manager dialog modeless

Originally committed to SVN as r6547.
This commit is contained in:
Thomas Goyne 2012-03-08 04:17:42 +00:00
parent 83faddfdb6
commit 59447a942d
5 changed files with 41 additions and 11 deletions

View file

@ -187,8 +187,14 @@ struct tool_style_manager : public Command {
STR_HELP("Open styles manager") STR_HELP("Open styles manager")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoController->Stop(); if (c->stylesManager) {
DialogStyleManager(c).ShowModal(); c->stylesManager->Show();
c->stylesManager->SetFocus();
}
else {
c->stylesManager = new DialogStyleManager(c);
c->stylesManager->Show();
}
} }
}; };

View file

@ -275,10 +275,12 @@ DialogStyleManager::DialogStyleManager(agi::Context *context)
CurrentList->Bind(wxEVT_COMMAND_LISTBOX_SELECTED, bind(&DialogStyleManager::UpdateButtons, this)); CurrentList->Bind(wxEVT_COMMAND_LISTBOX_SELECTED, bind(&DialogStyleManager::UpdateButtons, this));
CurrentList->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, bind(&DialogStyleManager::OnCurrentEdit, this)); CurrentList->Bind(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, bind(&DialogStyleManager::OnCurrentEdit, this));
c->selectionController->AddSelectionListener(this);
} }
DialogStyleManager::~DialogStyleManager() { DialogStyleManager::~DialogStyleManager() {
c->ass->SetScriptInfo("Last Style Storage", CatalogList->GetStringSelection()); c->selectionController->RemoveSelectionListener(this);
} }
void DialogStyleManager::LoadCurrentStyles(int commit_type) { void DialogStyleManager::LoadCurrentStyles(int commit_type) {
@ -296,6 +298,7 @@ void DialogStyleManager::LoadCurrentStyles(int commit_type) {
if (commit_type & AssFile::COMMIT_DIAG_META) { if (commit_type & AssFile::COMMIT_DIAG_META) {
AssDialogue *dia = c->selectionController->GetActiveLine(); AssDialogue *dia = c->selectionController->GetActiveLine();
CurrentList->DeselectAll();
if (dia && commit_type != AssFile::COMMIT_NEW) if (dia && commit_type != AssFile::COMMIT_NEW)
CurrentList->SetStringSelection(dia->Style); CurrentList->SetStringSelection(dia->Style);
else else
@ -305,6 +308,14 @@ void DialogStyleManager::LoadCurrentStyles(int commit_type) {
UpdateButtons(); UpdateButtons();
} }
void DialogStyleManager::OnActiveLineChanged(AssDialogue *new_line) {
if (new_line) {
CurrentList->DeselectAll();
CurrentList->SetStringSelection(new_line->Style);
UpdateButtons();
}
}
void DialogStyleManager::UpdateStorage() { void DialogStyleManager::UpdateStorage() {
Store.Save(); Store.Save();
@ -316,6 +327,7 @@ void DialogStyleManager::UpdateStorage() {
} }
void DialogStyleManager::OnChangeCatalog() { void DialogStyleManager::OnChangeCatalog() {
c->ass->SetScriptInfo("Last Style Storage", CatalogList->GetStringSelection());
Store.Load(CatalogList->GetStringSelection()); Store.Load(CatalogList->GetStringSelection());
UpdateStorage(); UpdateStorage();
} }

View file

@ -47,8 +47,10 @@
#include <libaegisub/signal.h> #include <libaegisub/signal.h>
#include "ass_style_storage.h" #include "ass_style_storage.h"
#include "selection_controller.h"
namespace agi { struct Context; } namespace agi { struct Context; }
class AssDialogue;
class AssFile; class AssFile;
class AssStyle; class AssStyle;
class DialogStyleEditor; class DialogStyleEditor;
@ -59,7 +61,7 @@ class PersistLocation;
/// @brief DOCME /// @brief DOCME
/// ///
/// DOCME /// DOCME
class DialogStyleManager : public wxDialog { class DialogStyleManager : public wxDialog, private SelectionListener<AssDialogue> {
agi::Context *c; ///< Project context agi::Context *c; ///< Project context
agi::scoped_ptr<PersistLocation> persist; agi::scoped_ptr<PersistLocation> persist;
@ -127,17 +129,21 @@ class DialogStyleManager : public wxDialog {
void OnChangeCatalog(); void OnChangeCatalog();
void OnCatalogNew(); void OnCatalogNew();
void OnCatalogDelete(); void OnCatalogDelete();
void OnStorageEdit();
void OnCurrentEdit();
void OnCopyToStorage();
void OnCopyToCurrent(); void OnCopyToCurrent();
void OnStorageCopy(); void OnCopyToStorage();
void OnCurrentCopy(); void OnCurrentCopy();
void OnStorageNew();
void OnCurrentNew();
void OnStorageDelete();
void OnCurrentDelete(); void OnCurrentDelete();
void OnCurrentEdit();
void OnCurrentImport(); void OnCurrentImport();
void OnCurrentNew();
void OnStorageCopy();
void OnStorageDelete();
void OnStorageEdit();
void OnStorageNew();
void OnKeyDown(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event);
void PasteToCurrent(); void PasteToCurrent();
void PasteToStorage(); void PasteToStorage();
@ -145,6 +151,9 @@ class DialogStyleManager : public wxDialog {
template<class T> template<class T>
void CopyToClipboard(wxListBox *list, T const& v); void CopyToClipboard(wxListBox *list, T const& v);
void OnActiveLineChanged(AssDialogue *new_line);
void OnSelectedSetChanged(const Selection &, const Selection &) { }
public: public:
DialogStyleManager(agi::Context *context); DialogStyleManager(agi::Context *context);
~DialogStyleManager(); ~DialogStyleManager();

View file

@ -182,6 +182,7 @@ FrameMain::FrameMain (wxArrayString args)
StartupLog("Create views and inner main window controls"); StartupLog("Create views and inner main window controls");
context->detachedVideo = 0; context->detachedVideo = 0;
context->stylingAssistant = 0; context->stylingAssistant = 0;
context->stylesManager = 0;
InitContents(); InitContents();
OPT_SUB("Video/Detached/Enabled", &FrameMain::OnVideoDetach, this, agi::signal::_1); OPT_SUB("Video/Detached/Enabled", &FrameMain::OnVideoDetach, this, agi::signal::_1);

View file

@ -5,6 +5,7 @@ class AssDialogue;
class AudioKaraoke; class AudioKaraoke;
class DialogDetachedVideo; class DialogDetachedVideo;
class DialogStyling; class DialogStyling;
class DialogStyleManager;
class DialogTranslation; class DialogTranslation;
template<class T> class SelectionController; template<class T> class SelectionController;
class SubsTextEditCtrl; class SubsTextEditCtrl;
@ -36,6 +37,7 @@ struct Context {
AudioKaraoke *karaoke; AudioKaraoke *karaoke;
DialogDetachedVideo *detachedVideo; DialogDetachedVideo *detachedVideo;
DialogStyling *stylingAssistant; DialogStyling *stylingAssistant;
DialogStyleManager *stylesManager;
DialogTranslation *translationAssistant; DialogTranslation *translationAssistant;
SubsTextEditCtrl *editBox; SubsTextEditCtrl *editBox;
SubtitlesGrid *subsGrid; SubtitlesGrid *subsGrid;