2 Copyright (C) 2016 Robin Gareus <robin@gareus.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __ardour_luawindow_h__
20 #define __ardour_luawindow_h__
22 #include <glibmm/thread.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/scrolledwindow.h>
26 #include <gtkmm/label.h>
27 #include <gtkmm/window.h>
29 #include "pbd/signals.h"
30 #include "pbd/stateful.h"
32 #include "ardour/ardour.h"
33 #include "ardour/luascripting.h"
34 #include "ardour/session_handle.h"
35 #include "ardour/types.h"
37 #include "gtkmm2ext/visibility_tracker.h"
39 #include "lua/luastate.h"
41 #include "ardour_button.h"
42 #include "ardour_dropdown.h"
46 public PBD::ScopedConnectionList,
47 public ARDOUR::SessionHandlePtr,
48 public Gtkmm2ext::VisibilityTracker
51 static LuaWindow* instance();
55 bool hide_window (GdkEventAny *ev);
57 void set_session (ARDOUR::Session* s);
61 Buffer_Valid = 0x01, ///< script is loaded
62 Buffer_HasFile = 0x02,
63 Buffer_ReadOnly = 0x04,
65 Buffer_Scratch = 0x10,
70 ScriptBuffer (const std::string&);
71 ScriptBuffer (ARDOUR::LuaScriptInfoPtr);
72 //ScriptBuffer (const ScriptBuffer& other);
81 ARDOUR::LuaScriptInfo::ScriptType type;
86 static LuaWindow* _instance;
91 Gtk::Menu* _menu_scratch;
92 Gtk::Menu* _menu_snippet;
93 Gtk::Menu* _menu_actions;
95 sigc::connection _script_changed_connection;
98 Gtk::TextView outtext;
99 Gtk::ScrolledWindow scrollout;
101 ArdourButton _btn_run;
102 ArdourButton _btn_clear;
103 ArdourButton _btn_open;
104 ArdourButton _btn_save;
105 ArdourButton _btn_delete;
106 ArdourButton _btn_revert;
108 ArdourDropdown script_select;
110 typedef boost::shared_ptr<ScriptBuffer> ScriptBufferPtr;
111 typedef std::vector<ScriptBufferPtr> ScriptBufferList;
113 ScriptBufferList script_buffers;
114 ScriptBufferPtr _current_buffer;
116 void session_going_away ();
117 void update_title ();
120 void setup_buffers ();
121 void refresh_scriptlist ();
122 void rebuild_menu ();
123 uint32_t count_scratch_buffers () const;
125 void script_changed ();
126 void script_selection_changed (ScriptBufferPtr n, bool force = false);
127 void update_gui_state ();
129 void append_text (std::string s);
130 void scroll_to_bottom ();
131 void clear_output ();
136 void delete_script ();
137 void revert_script ();
138 void import_script ();