Remove duplicated tempo curve colour change when dragging
[ardour.git] / gtk2_ardour / lua_script_manager.cc
index 934c65bc102bb8db33611a5471232010dbbe0ba5..8f3ec8ba1722b138148cb3784f586a3e6db450ff 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include <gtkmm/box.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/messagedialog.h>
+
 #include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/utils.h"
 
@@ -24,6 +28,7 @@
 #include "LuaBridge/LuaBridge.h"
 
 #include "lua_script_manager.h"
+#include "luawindow.h"
 #include "script_selector.h"
 #include "pbd/i18n.h"
 
@@ -52,6 +57,9 @@ LuaScriptManager::LuaScriptManager ()
        _a_view.get_column(1)->set_resizable (true);
        _a_view.get_column(1)->set_expand (true);
 
+       Frame* f;
+       Gtk::Label* doc;
+
        Gtk::HBox* edit_box = manage (new Gtk::HBox);
        edit_box->set_spacing(3);
 
@@ -69,9 +77,18 @@ LuaScriptManager::LuaScriptManager ()
        LuaInstance::instance()->ActionChanged.connect (sigc::mem_fun (*this, &LuaScriptManager::set_action_script_name));
        LuaInstance::instance()->SlotChanged.connect (sigc::mem_fun (*this, &LuaScriptManager::set_callback_script_name));
 
+       f = manage (new Frame (_("Description")));
+       doc = manage (new Label (
+                               _("Action Scripts are user initiated actions (menu, shortcuts, toolbar-button) for batch processing or customized tasks.")
+                               ));
+       doc->set_padding (5, 5);
+       doc->set_line_wrap();
+       f->add (*doc);
+
        Gtk::VBox *vbox = manage (new VBox());
        vbox->pack_start (_a_view, false, false);
        vbox->pack_end (*edit_box, false, false);
+       vbox->pack_end (*f, false, false);
        vbox->show_all ();
 
        pages.pages ().push_back (Notebook_Helpers::TabElem (*vbox, "Action Scripts"));
@@ -98,9 +115,18 @@ LuaScriptManager::LuaScriptManager ()
        _c_del_button.signal_clicked().connect (sigc::mem_fun(*this, &LuaScriptManager::del_callback_btn_clicked));
        _c_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &LuaScriptManager::callback_selection_changed));
 
+       f = manage (new Frame (_("Description")));
+       doc = manage (new Label (
+                               _("Lua action hooks are event-triggered callbacks for the Editor/Mixer GUI. Once a script is registered it is automatically triggered by events to perform some task.")
+                               ));
+       doc->set_padding (5, 5);
+       doc->set_line_wrap();
+       f->add (*doc);
+
        vbox = manage (new VBox());
        vbox->pack_start (_c_view, false, false);
        vbox->pack_end (*edit_box, false, false);
+       vbox->pack_end (*f, false, false);
        vbox->show_all ();
 
        pages.pages ().push_back (Notebook_Helpers::TabElem (*vbox, "Action Hooks"));
@@ -122,9 +148,18 @@ LuaScriptManager::LuaScriptManager ()
        _s_del_button.signal_clicked().connect (sigc::mem_fun(*this, &LuaScriptManager::del_sess_btn_clicked));
        _s_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &LuaScriptManager::session_script_selection_changed));
 
+       f = manage (new Frame (_("Description")));
+       doc = manage (new Label (
+                               _("Lua session scripts are loaded into processing engine and run in realtime. They are called periodically at the start of every audio cycle in the realtime process context before any processing takes place.")
+                               ));
+       doc->set_padding (5, 5);
+       doc->set_line_wrap();
+       f->add (*doc);
+
        vbox = manage (new VBox());
        vbox->pack_start (_s_view, false, false);
        vbox->pack_end (*edit_box, false, false);
+       vbox->pack_end (*f, false, false);
        vbox->show_all ();
 
        pages.pages ().push_back (Notebook_Helpers::TabElem (*vbox, "Session Scripts"));
@@ -196,7 +231,7 @@ LuaScriptManager::action_selection_changed ()
 
        if (row && row[_a_model.enabled]) {
                _a_del_button.set_sensitive (true);
-               _a_edit_button.set_sensitive (false); // TODO
+               _a_edit_button.set_sensitive (true);
                _a_call_button.set_sensitive (true);
        } else {
                _a_del_button.set_sensitive (false);
@@ -246,20 +281,7 @@ LuaScriptManager::edit_action_btn_clicked ()
        if (!li->lua_action (id, name, script, args)) {
                return;
        }
-
-       // TODO text-editor window, update script directly
-
-       if (!LuaScripting::try_compile (script, args)) {
-               // compilation failed, keep editing
-               return;
-       }
-
-       if (li->set_lua_action (id, name, script, args)) {
-               // OK
-       } else {
-               // load failed,  keep editing..
-       }
-       action_selection_changed ();
+       LuaWindow::instance()->edit_script (name, script);
 }
 
 void