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")
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();
}
}
};

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_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();
}

View File

@ -47,8 +47,10 @@
#include <libaegisub/signal.h>
#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<AssDialogue> {
agi::Context *c; ///< Project context
agi::scoped_ptr<PersistLocation> 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<class T>
void CopyToClipboard(wxListBox *list, T const& v);
void OnActiveLineChanged(AssDialogue *new_line);
void OnSelectedSetChanged(const Selection &, const Selection &) { }
public:
DialogStyleManager(agi::Context *context);
~DialogStyleManager();

View File

@ -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);

View File

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