Use labs() for long instead of abs()
[ardour.git] / gtk2_ardour / luainstance.h
index b81c0716aee8fd5348b3e7c9924ccd522aae1d3a..f32ee8ee5a84d03369f17e74de7592ea8f077e94 100644 (file)
@@ -1,8 +1,28 @@
+/*
+ * Copyright (C) 2016-2018 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 __gtkardour_luainstance_h__
 #define __gtkardour_luainstance_h__
 
 #include <bitset>
 
+#include <cairo.h>
+
 #include "pbd/id.h"
 #include "pbd/signals.h"
 #include "pbd/xml++.h"
@@ -68,6 +88,9 @@ private:
 
        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);
+
+       template <typename T, typename C1, typename C2, typename C3> void connect_3 (enum LuaSignal::LuaSignal, T, PBD::Signal3<void, C1, C2, C3>*);
+       template <typename T, typename C1, typename C2, typename C3> void proxy_3 (enum LuaSignal::LuaSignal, T, C1, C2, C3);
 };
 
 typedef boost::shared_ptr<LuaCallback> LuaCallbackPtr;
@@ -79,11 +102,15 @@ class LuaInstance : public PBD::ScopedConnectionList, public ARDOUR::SessionHand
 {
 public:
        static LuaInstance* instance();
+       static void destroy_instance();
        ~LuaInstance();
 
        static void register_classes (lua_State* L);
        static void register_hooks (lua_State* L);
        static void bind_cairo (lua_State* L);
+       static void bind_dialog (lua_State* L);
+
+       static void render_action_icon (cairo_t* cr, int w, int h, uint32_t c, void* i);
 
        void set_session (ARDOUR::Session* s);
 
@@ -91,16 +118,21 @@ public:
        XMLNode& get_action_state (void);
        XMLNode& get_hook_state (void);
 
+       int load_state ();
+       int save_state ();
+
        bool interactive_add (ARDOUR::LuaScriptInfo::ScriptType, int);
 
        /* actions */
        void call_action (const int);
+       void render_icon (int i, cairo_t*, int, int, uint32_t);
 
        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&);
+       bool lua_action_has_icon (const int);
        sigc::signal<void,int,std::string> ActionChanged;
 
        /* callbacks */
@@ -112,16 +144,22 @@ public:
        bool lua_slot (const PBD::ID&, std::string&, std::string&, ActionHook&, ARDOUR::LuaScriptParamList&);
        sigc::signal<void,PBD::ID,std::string,ActionHook> SlotChanged;
 
+       static PBD::Signal0<void> LuaTimerS; // deci-seconds (Timer every 1s)
+       static PBD::Signal0<void> LuaTimerDS; // deci-seconds (Timer every .1s)
+       static PBD::Signal0<void> SetSession; // emitted when a session is loaded
+
 private:
        LuaInstance();
        static LuaInstance* _instance;
 
        void init ();
+       void set_dirty ();
        void session_going_away ();
 
        LuaState lua;
 
        luabridge::LuaRef * _lua_call_action;
+       luabridge::LuaRef * _lua_render_icon;
        luabridge::LuaRef * _lua_add_action;
        luabridge::LuaRef * _lua_del_action;
        luabridge::LuaRef * _lua_get_action;
@@ -132,6 +170,12 @@ private:
 
        LuaCallbackMap _callbacks;
        PBD::ScopedConnectionList _slotcon;
+
+       void every_second ();
+       sigc::connection second_connection;
+
+       void every_point_one_seconds ();
+       sigc::connection point_one_second_connection;
 };
 
 #endif