Add Editor/UI Lua Scripting and Action/Callback Script
This commit is contained in:
parent
292eac7f48
commit
e54c77e642
1124
gtk2_ardour/luainstance.cc
Normal file
1124
gtk2_ardour/luainstance.cc
Normal file
File diff suppressed because it is too large
Load Diff
132
gtk2_ardour/luainstance.h
Normal file
132
gtk2_ardour/luainstance.h
Normal file
@ -0,0 +1,132 @@
|
||||
#ifndef __gtkardour_luainstance_h__
|
||||
#define __gtkardour_luainstance_h__
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include "pbd/id.h"
|
||||
#include "pbd/signals.h"
|
||||
#include "pbd/xml++.h"
|
||||
|
||||
#include "ardour/luascripting.h"
|
||||
#include "ardour/luabindings.h"
|
||||
#include "ardour/session_handle.h"
|
||||
|
||||
#include "lua/luastate.h"
|
||||
#include "LuaBridge/LuaBridge.h"
|
||||
|
||||
#include "luasignal.h"
|
||||
|
||||
typedef std::bitset<LuaSignal::LAST_SIGNAL> ActionHook;
|
||||
|
||||
class LuaCallback : public ARDOUR::SessionHandlePtr, public sigc::trackable
|
||||
{
|
||||
public:
|
||||
LuaCallback (ARDOUR::Session*, const std::string&, const std::string&, const ActionHook&, const ARDOUR::LuaScriptParamList&);
|
||||
LuaCallback (ARDOUR::Session*, XMLNode & node);
|
||||
~LuaCallback ();
|
||||
|
||||
XMLNode& get_state (void);
|
||||
void set_session (ARDOUR::Session *);
|
||||
|
||||
const PBD::ID& id () const { return _id; }
|
||||
const std::string& name () const { return _name; }
|
||||
ActionHook signals () const { return _signals; }
|
||||
bool lua_slot (std::string&, std::string&, ActionHook&, ARDOUR::LuaScriptParamList&);
|
||||
PBD::Signal0<void> drop_callback;
|
||||
|
||||
protected:
|
||||
void session_going_away ();
|
||||
|
||||
private:
|
||||
LuaState lua;
|
||||
|
||||
PBD::ID _id;
|
||||
std::string _name;
|
||||
ActionHook _signals;
|
||||
|
||||
void reconnect ();
|
||||
template <class T> void reconnect_object (T);
|
||||
void init ();
|
||||
|
||||
luabridge::LuaRef * _lua_add;
|
||||
luabridge::LuaRef * _lua_get;
|
||||
luabridge::LuaRef * _lua_call;
|
||||
luabridge::LuaRef * _lua_save;
|
||||
luabridge::LuaRef * _lua_load;
|
||||
|
||||
PBD::ScopedConnectionList _connections;
|
||||
|
||||
template <typename T, typename S> void connect_0 (enum LuaSignal::LuaSignal, T, S*);
|
||||
template <typename T> void proxy_0 (enum LuaSignal::LuaSignal, T);
|
||||
|
||||
template <typename T, typename C1> void connect_1 (enum LuaSignal::LuaSignal, T, PBD::Signal1<void, C1>*);
|
||||
template <typename T, typename C1> void proxy_1 (enum LuaSignal::LuaSignal, T, C1);
|
||||
|
||||
template <typename T, typename C1, typename C2> void connect_2 (enum LuaSignal::LuaSignal, T, PBD::Signal2<void, C1, C2>*);
|
||||
template <typename T, typename C1, typename C2> void proxy_2 (enum LuaSignal::LuaSignal, T, C1, C2);
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<LuaCallback> LuaCallbackPtr;
|
||||
typedef std::map<PBD::ID, LuaCallbackPtr> LuaCallbackMap;
|
||||
|
||||
|
||||
|
||||
class LuaInstance : public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
|
||||
{
|
||||
public:
|
||||
static LuaInstance* instance();
|
||||
~LuaInstance();
|
||||
|
||||
static void register_classes (lua_State* L);
|
||||
static void register_hooks (lua_State* L);
|
||||
|
||||
void set_session (ARDOUR::Session* s);
|
||||
|
||||
int set_state (const XMLNode&);
|
||||
XMLNode& get_action_state (void);
|
||||
XMLNode& get_hook_state (void);
|
||||
|
||||
bool interactive_add (ARDOUR::LuaScriptInfo::ScriptType, int);
|
||||
|
||||
/* actions */
|
||||
void call_action (const int);
|
||||
|
||||
bool set_lua_action (const int, const std::string&, const std::string&, const ARDOUR::LuaScriptParamList&);
|
||||
bool remove_lua_action (const int);
|
||||
bool lua_action_name (const int, std::string&);
|
||||
std::vector<std::string> lua_action_names ();
|
||||
bool lua_action (const int, std::string&, std::string&, ARDOUR::LuaScriptParamList&);
|
||||
sigc::signal<void,int,std::string> ActionChanged;
|
||||
|
||||
/* callbacks */
|
||||
bool register_lua_slot (const std::string&, const std::string&, const ARDOUR::LuaScriptParamList&);
|
||||
bool unregister_lua_slot (const PBD::ID&);
|
||||
std::vector<PBD::ID> lua_slots () const;
|
||||
bool lua_slot_name (const PBD::ID&, std::string&) const;
|
||||
std::vector<std::string> lua_slot_names () const;
|
||||
bool lua_slot (const PBD::ID&, std::string&, std::string&, ActionHook&, ARDOUR::LuaScriptParamList&);
|
||||
sigc::signal<void,PBD::ID,std::string,ActionHook> SlotChanged;
|
||||
|
||||
private:
|
||||
LuaInstance();
|
||||
static LuaInstance* _instance;
|
||||
|
||||
void init ();
|
||||
void session_going_away ();
|
||||
|
||||
LuaState lua;
|
||||
|
||||
luabridge::LuaRef * _lua_call_action;
|
||||
luabridge::LuaRef * _lua_add_action;
|
||||
luabridge::LuaRef * _lua_del_action;
|
||||
luabridge::LuaRef * _lua_get_action;
|
||||
|
||||
luabridge::LuaRef * _lua_load;
|
||||
luabridge::LuaRef * _lua_save;
|
||||
luabridge::LuaRef * _lua_clear;
|
||||
|
||||
LuaCallbackMap _callbacks;
|
||||
PBD::ScopedConnectionList _slotcon;
|
||||
};
|
||||
|
||||
#endif
|
40
gtk2_ardour/luasignal.h
Normal file
40
gtk2_ardour/luasignal.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef _luasignal_h_
|
||||
#define _luasignal_h_
|
||||
namespace LuaSignal {
|
||||
|
||||
#define ENGINE(name,c,p) name,
|
||||
#define STATIC(name,c,p) name,
|
||||
#define SESSION(name,c,p) name,
|
||||
|
||||
enum LuaSignal {
|
||||
# include "luasignal_syms.h"
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
#undef ENGINE
|
||||
#undef SESSION
|
||||
#undef STATIC
|
||||
|
||||
extern const char *luasignalstr[];
|
||||
inline const char* enum2str (LuaSignal i) { return luasignalstr[i]; }
|
||||
LuaSignal str2luasignal (const std::string &);
|
||||
|
||||
} // namespace
|
||||
#endif
|
92
gtk2_ardour/luasignal_syms.h
Normal file
92
gtk2_ardour/luasignal_syms.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Robin Gareus <robin@gareus.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
// editor
|
||||
#if 0
|
||||
STATIC(SessionLoad, &, 0)
|
||||
STATIC(SessionClose, &, 0)
|
||||
#endif
|
||||
//STATIC(EverySecond, get_timers().second, 0) // XXX
|
||||
STATIC(ConfigChanged, &ARDOUR::Config->ParameterChanged, 1)
|
||||
|
||||
// engine instance
|
||||
ENGINE(EngineRunning, Running, 0)
|
||||
ENGINE(EngineStopped, Stopped, 0)
|
||||
ENGINE(EngineHalted, Halted, 1)
|
||||
ENGINE(EngineDeviceListChanged, DeviceListChanged, 0)
|
||||
ENGINE(BufferSizeChanged, BufferSizeChanged, 1)
|
||||
ENGINE(SampleRateChanged, SampleRateChanged, 1)
|
||||
|
||||
// session static
|
||||
STATIC(FeedbackDetected, &ARDOUR::Session::FeedbackDetected, 0)
|
||||
STATIC(SuccessfulGraphSort, &ARDOUR::Session::SuccessfulGraphSort, 0)
|
||||
STATIC(StartTimeChanged, &ARDOUR::Session::StartTimeChanged, 1)
|
||||
STATIC(EndTimeChanged, &ARDOUR::Session::EndTimeChanged, 1)
|
||||
STATIC(Exported, &ARDOUR::Session::Exported, 2)
|
||||
|
||||
// session specific (re-subscribe when session changes)
|
||||
SESSION(SessionConfigChanged, config.ParameterChanged, 1)
|
||||
SESSION(TransportStateChange, TransportStateChange, 0)
|
||||
SESSION(DirtyChanged, DirtyChanged, 0)
|
||||
SESSION(StateSaved, StateSaved, 1)
|
||||
SESSION(Xrun, Xrun, 1)
|
||||
SESSION(TransportLooped, TransportLooped, 0)
|
||||
SESSION(SoloActive, SoloActive, 1)
|
||||
SESSION(SoloChanged, SoloChanged, 0)
|
||||
SESSION(IsolatedChanged, IsolatedChanged, 0)
|
||||
SESSION(MonitorChanged, MonitorChanged, 0)
|
||||
SESSION(RecordStateChanged, RecordStateChanged, 0)
|
||||
SESSION(RecordArmStateChanged, RecordArmStateChanged, 0)
|
||||
SESSION(AudioLoopLocationChanged, auto_loop_location_changed, 1)
|
||||
SESSION(AudioPunchLocationChanged, auto_punch_location_changed, 1)
|
||||
SESSION(LocationsModified, locations_modified, 0)
|
||||
SESSION(AuditionActive, AuditionActive, 1)
|
||||
SESSION(BundleAddedOrRemoved, BundleAddedOrRemoved, 0)
|
||||
SESSION(PositionChanged, PositionChanged, 1)
|
||||
SESSION(Located, Located, 0)
|
||||
SESSION(RoutesReconnected, session_routes_reconnected, 0)
|
||||
SESSION(RouteAdded, RouteAdded, 1)
|
||||
SESSION(RouteAddedOrRemoved, RouteAddedOrRemoved, 1)
|
||||
SESSION(RouteGroupPropertyChanged, RouteGroupPropertyChanged, 1)
|
||||
SESSION(RouteAddedToRouteGroup, RouteAddedToRouteGroup, 2)
|
||||
SESSION(RouteRemovedFromRouteGroup, RouteRemovedFromRouteGroup, 2)
|
||||
SESSION(StepEditStatusChange, StepEditStatusChange, 1)
|
||||
SESSION(RouteGroupAdded, route_group_added, 1)
|
||||
SESSION(RouteGroupRemoved, route_group_removed, 0)
|
||||
SESSION(RouteGroupsReordered, route_groups_reordered, 0)
|
||||
|
||||
// route static globals
|
||||
STATIC(SyncOrderKeys, &Route::SyncOrderKeys, 0)
|
||||
|
||||
// plugin manager instance
|
||||
STATIC(PluginListChanged, &(PluginManager::instance().PluginListChanged), 0)
|
||||
STATIC(PluginStatusesChanged, &(PluginManager::instance().PluginStatusesChanged), 0)
|
||||
|
||||
// Diskstream static global
|
||||
STATIC(DiskOverrun, &ARDOUR::Diskstream::DiskOverrun, 0)
|
||||
STATIC(DiskUnderrun, &ARDOUR::Diskstream::DiskUnderrun, 0)
|
||||
|
||||
// Region static
|
||||
STATIC(RegionPropertyChanged, &ARDOUR::Region::RegionPropertyChanged, 2)
|
||||
|
||||
// TODO per track/route signals,
|
||||
// TODO per plugin actions / controllables
|
||||
// TODO per region actions
|
||||
//SESSIONOBJECT(PropertyChanged, &ARDOUR::Stateful::PropertyChanged, 1)
|
||||
|
||||
// TODO any location action
|
@ -122,6 +122,7 @@ gtk2_ardour_sources = [
|
||||
'led.cc',
|
||||
'level_meter.cc',
|
||||
'location_ui.cc',
|
||||
'luainstance.cc',
|
||||
'main.cc',
|
||||
'main_clock.cc',
|
||||
'marker.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user