forked from mia/Aegisub
Make the automation manager dialog modeless
Originally committed to SVN as r6552.
This commit is contained in:
parent
931de846ae
commit
41f2f67042
7 changed files with 28 additions and 39 deletions
|
@ -456,7 +456,10 @@ namespace Automation4 {
|
||||||
delete_clear(scripts);
|
delete_clear(scripts);
|
||||||
|
|
||||||
wxString local_scripts = context->ass->GetScriptInfo("Automation Scripts");
|
wxString local_scripts = context->ass->GetScriptInfo("Automation Scripts");
|
||||||
if (local_scripts.empty()) return;
|
if (local_scripts.empty()) {
|
||||||
|
ScriptsChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wxStringTokenizer tok(local_scripts, "|", wxTOKEN_STRTOK);
|
wxStringTokenizer tok(local_scripts, "|", wxTOKEN_STRTOK);
|
||||||
wxFileName assfn(context->ass->filename);
|
wxFileName assfn(context->ass->filename);
|
||||||
|
|
|
@ -219,7 +219,7 @@ namespace Automation4 {
|
||||||
void Remove(Script *script);
|
void Remove(Script *script);
|
||||||
/// Deletes all scripts managed
|
/// Deletes all scripts managed
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
/// Reload all scripts mananaged
|
/// Reload all scripts managed
|
||||||
virtual void Reload() = 0;
|
virtual void Reload() = 0;
|
||||||
/// Reload a single managed script
|
/// Reload a single managed script
|
||||||
virtual void Reload(Script *script);
|
virtual void Reload(Script *script);
|
||||||
|
|
|
@ -87,20 +87,13 @@ struct open_manager : public Command {
|
||||||
STR_HELP("Open automation manager")
|
STR_HELP("Open automation manager")
|
||||||
|
|
||||||
void operator()(agi::Context *c) {
|
void operator()(agi::Context *c) {
|
||||||
if (wxGetMouseState().CmdDown()) {
|
if (c->automationManager) {
|
||||||
wxGetApp().global_scripts->Reload();
|
c->automationManager->Show();
|
||||||
|
c->automationManager->SetFocus();
|
||||||
if (wxGetMouseState().ShiftDown()) {
|
|
||||||
c->local_scripts->Reload();
|
|
||||||
wxGetApp().frame->StatusTimeout(_("Reloaded all Automation scripts"));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxGetApp().frame->StatusTimeout(_("Reloaded autoload Automation scripts"));
|
c->automationManager = new DialogAutomation(c);
|
||||||
}
|
c->automationManager->Show();
|
||||||
}
|
|
||||||
else {
|
|
||||||
c->videoController->Stop();
|
|
||||||
DialogAutomation(c).ShowModal();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,7 +64,9 @@ DialogAutomation::DialogAutomation(agi::Context *c)
|
||||||
: wxDialog(c->parent, -1, _("Automation Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
: wxDialog(c->parent, -1, _("Automation Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||||
, context(c)
|
, context(c)
|
||||||
, local_manager(c->local_scripts)
|
, local_manager(c->local_scripts)
|
||||||
|
, local_scripts_changed(local_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this))
|
||||||
, global_manager(wxGetApp().global_scripts)
|
, global_manager(wxGetApp().global_scripts)
|
||||||
|
, global_scripts_changed(global_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this))
|
||||||
{
|
{
|
||||||
SetIcon(BitmapToIcon(GETIMAGE(automation_toolbutton_24)));
|
SetIcon(BitmapToIcon(GETIMAGE(automation_toolbutton_24)));
|
||||||
|
|
||||||
|
@ -77,8 +79,8 @@ DialogAutomation::DialogAutomation(agi::Context *c)
|
||||||
wxButton *reload_autoload_button = new wxButton(this, -1, _("Re&scan Autoload Dir"));
|
wxButton *reload_autoload_button = new wxButton(this, -1, _("Re&scan Autoload Dir"));
|
||||||
wxButton *close_button = new wxButton(this, wxID_CANCEL, _("&Close"));
|
wxButton *close_button = new wxButton(this, wxID_CANCEL, _("&Close"));
|
||||||
|
|
||||||
list->Bind(wxEVT_COMMAND_LIST_ITEM_SELECTED, &DialogAutomation::OnSelectionChange, this);
|
list->Bind(wxEVT_COMMAND_LIST_ITEM_SELECTED, std::tr1::bind(&DialogAutomation::UpdateDisplay, this));
|
||||||
list->Bind(wxEVT_COMMAND_LIST_ITEM_DESELECTED, &DialogAutomation::OnSelectionChange, this);
|
list->Bind(wxEVT_COMMAND_LIST_ITEM_DESELECTED, std::tr1::bind(&DialogAutomation::UpdateDisplay, this));
|
||||||
add_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnAdd, this);
|
add_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnAdd, this);
|
||||||
remove_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnRemove, this);
|
remove_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnRemove, this);
|
||||||
reload_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnReload, this);
|
reload_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnReload, this);
|
||||||
|
@ -120,7 +122,6 @@ DialogAutomation::DialogAutomation(agi::Context *c)
|
||||||
close_button->SetDefault();
|
close_button->SetDefault();
|
||||||
|
|
||||||
RebuildList();
|
RebuildList();
|
||||||
UpdateDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Container, class Pred>
|
template<class Container, class Pred>
|
||||||
|
@ -142,6 +143,8 @@ void DialogAutomation::RebuildList()
|
||||||
|
|
||||||
for_each(local_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, false));
|
for_each(local_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, false));
|
||||||
for_each(global_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, true));
|
for_each(global_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, true));
|
||||||
|
|
||||||
|
UpdateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogAutomation::SetScriptInfo(int i, Automation4::Script *script)
|
void DialogAutomation::SetScriptInfo(int i, Automation4::Script *script)
|
||||||
|
@ -206,9 +209,7 @@ void DialogAutomation::OnAdd(wxCommandEvent &)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Automation4::Script *script = Automation4::ScriptFactory::CreateFromFile(fnames[i], true);
|
local_manager->Add(Automation4::ScriptFactory::CreateFromFile(fnames[i], true));
|
||||||
local_manager->Add(script);
|
|
||||||
AddScript(script, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +219,8 @@ void DialogAutomation::OnRemove(wxCommandEvent &)
|
||||||
if (i < 0) return;
|
if (i < 0) return;
|
||||||
const ExtraScriptInfo &ei = script_info[list->GetItemData(i)];
|
const ExtraScriptInfo &ei = script_info[list->GetItemData(i)];
|
||||||
if (ei.is_global) return;
|
if (ei.is_global) return;
|
||||||
list->DeleteItem(i);
|
|
||||||
local_manager->Remove(ei.script);
|
local_manager->Remove(ei.script);
|
||||||
// don't bother doing anything in script_info, it's relatively short-lived, and having any indexes change would break stuff
|
|
||||||
list->Select(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogAutomation::OnReload(wxCommandEvent &)
|
void DialogAutomation::OnReload(wxCommandEvent &)
|
||||||
|
@ -234,8 +233,6 @@ void DialogAutomation::OnReload(wxCommandEvent &)
|
||||||
global_manager->Reload(ei.script);
|
global_manager->Reload(ei.script);
|
||||||
else
|
else
|
||||||
local_manager->Reload(ei.script);
|
local_manager->Reload(ei.script);
|
||||||
|
|
||||||
SetScriptInfo(i, ei.script);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static wxString fac_to_str(const Automation4::ScriptFactory* f) {
|
static wxString fac_to_str(const Automation4::ScriptFactory* f) {
|
||||||
|
@ -291,11 +288,4 @@ void DialogAutomation::OnInfo(wxCommandEvent &)
|
||||||
void DialogAutomation::OnReloadAutoload(wxCommandEvent &)
|
void DialogAutomation::OnReloadAutoload(wxCommandEvent &)
|
||||||
{
|
{
|
||||||
global_manager->Reload();
|
global_manager->Reload();
|
||||||
RebuildList();
|
|
||||||
UpdateDisplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DialogAutomation::OnSelectionChange(wxListEvent &)
|
|
||||||
{
|
|
||||||
UpdateDisplay();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,13 @@
|
||||||
/// @ingroup secondary_ui
|
/// @ingroup secondary_ui
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <libaegisub/signal.h>
|
||||||
|
|
||||||
namespace Automation4 {
|
namespace Automation4 {
|
||||||
class ScriptManager;
|
class ScriptManager;
|
||||||
|
@ -76,9 +74,15 @@ class DialogAutomation : public wxDialog {
|
||||||
/// File-local script manager
|
/// File-local script manager
|
||||||
Automation4::ScriptManager *local_manager;
|
Automation4::ScriptManager *local_manager;
|
||||||
|
|
||||||
|
/// Listener for external changes to the local scripts
|
||||||
|
agi::signal::Connection local_scripts_changed;
|
||||||
|
|
||||||
/// Global script manager
|
/// Global script manager
|
||||||
Automation4::ScriptManager *global_manager;
|
Automation4::ScriptManager *global_manager;
|
||||||
|
|
||||||
|
/// Listener for external changes to the global scripts
|
||||||
|
agi::signal::Connection global_scripts_changed;
|
||||||
|
|
||||||
|
|
||||||
/// List of loaded scripts
|
/// List of loaded scripts
|
||||||
wxListView *list;
|
wxListView *list;
|
||||||
|
@ -100,7 +104,6 @@ class DialogAutomation : public wxDialog {
|
||||||
|
|
||||||
void OnInfo(wxCommandEvent &);
|
void OnInfo(wxCommandEvent &);
|
||||||
void OnReloadAutoload(wxCommandEvent &);
|
void OnReloadAutoload(wxCommandEvent &);
|
||||||
void OnSelectionChange(wxListEvent &);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogAutomation(agi::Context *context);
|
DialogAutomation(agi::Context *context);
|
||||||
|
|
|
@ -125,6 +125,7 @@ FrameMain::FrameMain (wxArrayString args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StartupLog("Initializing context models");
|
StartupLog("Initializing context models");
|
||||||
|
memset(context.get(), 0, sizeof(*context));
|
||||||
AssFile::top = context->ass = new AssFile;
|
AssFile::top = context->ass = new AssFile;
|
||||||
context->ass->AddCommitListener(&FrameMain::UpdateTitle, this);
|
context->ass->AddCommitListener(&FrameMain::UpdateTitle, this);
|
||||||
context->ass->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this);
|
context->ass->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this);
|
||||||
|
@ -180,9 +181,6 @@ FrameMain::FrameMain (wxArrayString args)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StartupLog("Create views and inner main window controls");
|
StartupLog("Create views and inner main window controls");
|
||||||
context->detachedVideo = 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);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ class AudioBox;
|
||||||
class AudioController;
|
class AudioController;
|
||||||
class AssDialogue;
|
class AssDialogue;
|
||||||
class AudioKaraoke;
|
class AudioKaraoke;
|
||||||
|
class DialogAutomation;
|
||||||
class DialogDetachedVideo;
|
class DialogDetachedVideo;
|
||||||
class DialogStyling;
|
class DialogStyling;
|
||||||
class DialogStyleManager;
|
class DialogStyleManager;
|
||||||
|
@ -35,6 +36,7 @@ struct Context {
|
||||||
// Views (i.e. things that should eventually not be here at all)
|
// Views (i.e. things that should eventually not be here at all)
|
||||||
AudioBox *audioBox;
|
AudioBox *audioBox;
|
||||||
AudioKaraoke *karaoke;
|
AudioKaraoke *karaoke;
|
||||||
|
DialogAutomation *automationManager;
|
||||||
DialogDetachedVideo *detachedVideo;
|
DialogDetachedVideo *detachedVideo;
|
||||||
DialogStyling *stylingAssistant;
|
DialogStyling *stylingAssistant;
|
||||||
DialogStyleManager *stylesManager;
|
DialogStyleManager *stylesManager;
|
||||||
|
|
Loading…
Reference in a new issue