mirror of https://github.com/odrling/Aegisub
Make the automation manager dialog modeless
Originally committed to SVN as r6552.
This commit is contained in:
parent
931de846ae
commit
41f2f67042
|
@ -456,7 +456,10 @@ namespace Automation4 {
|
|||
delete_clear(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);
|
||||
wxFileName assfn(context->ass->filename);
|
||||
|
|
|
@ -219,7 +219,7 @@ namespace Automation4 {
|
|||
void Remove(Script *script);
|
||||
/// Deletes all scripts managed
|
||||
void RemoveAll();
|
||||
/// Reload all scripts mananaged
|
||||
/// Reload all scripts managed
|
||||
virtual void Reload() = 0;
|
||||
/// Reload a single managed script
|
||||
virtual void Reload(Script *script);
|
||||
|
|
|
@ -87,20 +87,13 @@ struct open_manager : public Command {
|
|||
STR_HELP("Open automation manager")
|
||||
|
||||
void operator()(agi::Context *c) {
|
||||
if (wxGetMouseState().CmdDown()) {
|
||||
wxGetApp().global_scripts->Reload();
|
||||
|
||||
if (wxGetMouseState().ShiftDown()) {
|
||||
c->local_scripts->Reload();
|
||||
wxGetApp().frame->StatusTimeout(_("Reloaded all Automation scripts"));
|
||||
}
|
||||
else {
|
||||
wxGetApp().frame->StatusTimeout(_("Reloaded autoload Automation scripts"));
|
||||
}
|
||||
if (c->automationManager) {
|
||||
c->automationManager->Show();
|
||||
c->automationManager->SetFocus();
|
||||
}
|
||||
else {
|
||||
c->videoController->Stop();
|
||||
DialogAutomation(c).ShowModal();
|
||||
c->automationManager = new DialogAutomation(c);
|
||||
c->automationManager->Show();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -64,7 +64,9 @@ DialogAutomation::DialogAutomation(agi::Context *c)
|
|||
: wxDialog(c->parent, -1, _("Automation Manager"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, context(c)
|
||||
, local_manager(c->local_scripts)
|
||||
, local_scripts_changed(local_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this))
|
||||
, global_manager(wxGetApp().global_scripts)
|
||||
, global_scripts_changed(global_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this))
|
||||
{
|
||||
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 *close_button = new wxButton(this, wxID_CANCEL, _("&Close"));
|
||||
|
||||
list->Bind(wxEVT_COMMAND_LIST_ITEM_SELECTED, &DialogAutomation::OnSelectionChange, this);
|
||||
list->Bind(wxEVT_COMMAND_LIST_ITEM_DESELECTED, &DialogAutomation::OnSelectionChange, this);
|
||||
list->Bind(wxEVT_COMMAND_LIST_ITEM_SELECTED, std::tr1::bind(&DialogAutomation::UpdateDisplay, this));
|
||||
list->Bind(wxEVT_COMMAND_LIST_ITEM_DESELECTED, std::tr1::bind(&DialogAutomation::UpdateDisplay, this));
|
||||
add_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnAdd, this);
|
||||
remove_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnRemove, this);
|
||||
reload_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &DialogAutomation::OnReload, this);
|
||||
|
@ -120,7 +122,6 @@ DialogAutomation::DialogAutomation(agi::Context *c)
|
|||
close_button->SetDefault();
|
||||
|
||||
RebuildList();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
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(global_manager->GetScripts(), bind(&DialogAutomation::AddScript, this, _1, true));
|
||||
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void DialogAutomation::SetScriptInfo(int i, Automation4::Script *script)
|
||||
|
@ -206,9 +209,7 @@ void DialogAutomation::OnAdd(wxCommandEvent &)
|
|||
continue;
|
||||
}
|
||||
|
||||
Automation4::Script *script = Automation4::ScriptFactory::CreateFromFile(fnames[i], true);
|
||||
local_manager->Add(script);
|
||||
AddScript(script, false);
|
||||
local_manager->Add(Automation4::ScriptFactory::CreateFromFile(fnames[i], true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,10 +219,8 @@ void DialogAutomation::OnRemove(wxCommandEvent &)
|
|||
if (i < 0) return;
|
||||
const ExtraScriptInfo &ei = script_info[list->GetItemData(i)];
|
||||
if (ei.is_global) return;
|
||||
list->DeleteItem(i);
|
||||
|
||||
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 &)
|
||||
|
@ -234,8 +233,6 @@ void DialogAutomation::OnReload(wxCommandEvent &)
|
|||
global_manager->Reload(ei.script);
|
||||
else
|
||||
local_manager->Reload(ei.script);
|
||||
|
||||
SetScriptInfo(i, ei.script);
|
||||
}
|
||||
|
||||
static wxString fac_to_str(const Automation4::ScriptFactory* f) {
|
||||
|
@ -291,11 +288,4 @@ void DialogAutomation::OnInfo(wxCommandEvent &)
|
|||
void DialogAutomation::OnReloadAutoload(wxCommandEvent &)
|
||||
{
|
||||
global_manager->Reload();
|
||||
RebuildList();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
void DialogAutomation::OnSelectionChange(wxListEvent &)
|
||||
{
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
|
|
@ -34,15 +34,13 @@
|
|||
/// @ingroup secondary_ui
|
||||
///
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <vector>
|
||||
|
||||
#include <wx/dialog.h>
|
||||
#endif
|
||||
|
||||
#include <libaegisub/signal.h>
|
||||
|
||||
namespace Automation4 {
|
||||
class ScriptManager;
|
||||
|
@ -76,9 +74,15 @@ class DialogAutomation : public wxDialog {
|
|||
/// File-local script manager
|
||||
Automation4::ScriptManager *local_manager;
|
||||
|
||||
/// Listener for external changes to the local scripts
|
||||
agi::signal::Connection local_scripts_changed;
|
||||
|
||||
/// Global script manager
|
||||
Automation4::ScriptManager *global_manager;
|
||||
|
||||
/// Listener for external changes to the global scripts
|
||||
agi::signal::Connection global_scripts_changed;
|
||||
|
||||
|
||||
/// List of loaded scripts
|
||||
wxListView *list;
|
||||
|
@ -100,7 +104,6 @@ class DialogAutomation : public wxDialog {
|
|||
|
||||
void OnInfo(wxCommandEvent &);
|
||||
void OnReloadAutoload(wxCommandEvent &);
|
||||
void OnSelectionChange(wxListEvent &);
|
||||
|
||||
public:
|
||||
DialogAutomation(agi::Context *context);
|
||||
|
|
|
@ -125,6 +125,7 @@ FrameMain::FrameMain (wxArrayString args)
|
|||
#endif
|
||||
|
||||
StartupLog("Initializing context models");
|
||||
memset(context.get(), 0, sizeof(*context));
|
||||
AssFile::top = context->ass = new AssFile;
|
||||
context->ass->AddCommitListener(&FrameMain::UpdateTitle, this);
|
||||
context->ass->AddFileOpenListener(&FrameMain::OnSubtitlesOpen, this);
|
||||
|
@ -180,9 +181,6 @@ FrameMain::FrameMain (wxArrayString args)
|
|||
#endif
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ class AudioBox;
|
|||
class AudioController;
|
||||
class AssDialogue;
|
||||
class AudioKaraoke;
|
||||
class DialogAutomation;
|
||||
class DialogDetachedVideo;
|
||||
class DialogStyling;
|
||||
class DialogStyleManager;
|
||||
|
@ -35,6 +36,7 @@ struct Context {
|
|||
// Views (i.e. things that should eventually not be here at all)
|
||||
AudioBox *audioBox;
|
||||
AudioKaraoke *karaoke;
|
||||
DialogAutomation *automationManager;
|
||||
DialogDetachedVideo *detachedVideo;
|
||||
DialogStyling *stylingAssistant;
|
||||
DialogStyleManager *stylesManager;
|
||||
|
|
Loading…
Reference in New Issue