add a static function to access processor selection from a Lua script
authorRobin Gareus <robin@gareus.org>
Fri, 26 Aug 2016 01:24:06 +0000 (03:24 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 26 Aug 2016 01:24:06 +0000 (03:24 +0200)
  local ps = ArdourUI.processor_selection()
  for p in ps:iter() do print (p:name ()) end

gtk2_ardour/luainstance.cc
gtk2_ardour/processor_box.h

index c813eeea63dafca66b860c9d1d6da6f9e255fe8f..0f02f943ea4281a79184af037c8a39381075c349 100644 (file)
@@ -37,6 +37,7 @@
 #include "luainstance.h"
 #include "luasignal.h"
 #include "marker.h"
+#include "processor_box.h"
 #include "time_axis_view.h"
 #include "selection.h"
 #include "script_selector.h"
@@ -349,6 +350,16 @@ const char *luasignalstr[] = {
 }; // namespace
 
 
+/** special cases for Ardour's Mixer UI */
+namespace LuaMixer {
+
+       ProcessorBox::ProcSelection
+       processor_selection (lua_State* L) {
+               return ProcessorBox::current_processor_selection ();
+       }
+
+};
+
 ////////////////////////////////////////////////////////////////////////////////
 
 #define xstr(s) stringify(s)
@@ -545,6 +556,8 @@ LuaInstance::register_classes (lua_State* L)
 
                .addFunction ("http_get", (std::string (*)(const std::string&))&ArdourCurl::http_get)
 
+               .addFunction ("processor_selection", &LuaMixer::processor_selection)
+
                .beginStdList <ArdourMarker*> ("ArdourMarkerList")
                .endClass ()
 
index 5dd7483be4b3dae84867f1eb440875496828ef71..5f0115529cfb1f7b0944976d7dc87f64652e8071 100644 (file)
@@ -454,6 +454,16 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
        static Gtkmm2ext::Bindings* bindings;
        static void register_actions();
 
+       typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
+
+       static ProcSelection current_processor_selection () {
+               ProcSelection ps;
+               if (_current_processor_box) {
+                       _current_processor_box->get_selected_processors (ps);
+               }
+               return ps;
+       }
+
 #ifndef NDEBUG
        static bool show_all_processors;
 #endif
@@ -535,8 +545,6 @@ class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARD
 
        void ab_plugins ();
 
-       typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
-
        void cut_processors (const ProcSelection&);
        void copy_processors (const ProcSelection&);
        void delete_processors (const ProcSelection&);