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/textview.h>
28 #include <gtkmm/window.h>
30 #include "pbd/signals.h"
31 #include "pbd/stateful.h"
33 #include "ardour/ardour.h"
34 #include "ardour/luascripting.h"
35 #include "ardour/session_handle.h"
36 #include "ardour/types.h"
38 #include "gtkmm2ext/visibility_tracker.h"
40 #include "lua/luastate.h"
42 #include "widgets/ardour_button.h"
43 #include "widgets/ardour_dropdown.h"
47 public PBD::ScopedConnectionList,
48 public ARDOUR::SessionHandlePtr,
49 public Gtkmm2ext::VisibilityTracker
52 static LuaWindow* instance();
56 bool hide_window (GdkEventAny *ev);
57 void edit_script (const std::string&, const std::string&);
59 void set_session (ARDOUR::Session* s);
63 Buffer_Valid = 0x01, ///< script is loaded
64 Buffer_HasFile = 0x02,
65 Buffer_ReadOnly = 0x04,
67 Buffer_Scratch = 0x10,
73 ScriptBuffer (const std::string&);
74 ScriptBuffer (ARDOUR::LuaScriptInfoPtr);
75 //ScriptBuffer (const ScriptBuffer& other);
84 ARDOUR::LuaScriptInfo::ScriptType type;
89 static LuaWindow* _instance;
94 Gtk::Menu* _menu_scratch;
95 Gtk::Menu* _menu_snippet;
96 Gtk::Menu* _menu_actions;
98 sigc::connection _script_changed_connection;
101 Gtk::TextView outtext;
102 Gtk::ScrolledWindow scrollout;
104 ArdourWidgets::ArdourButton _btn_run;
105 ArdourWidgets::ArdourButton _btn_clear;
106 ArdourWidgets::ArdourButton _btn_open;
107 ArdourWidgets::ArdourButton _btn_save;
108 ArdourWidgets::ArdourButton _btn_delete;
109 ArdourWidgets::ArdourButton _btn_revert;
111 ArdourWidgets::ArdourDropdown script_select;
113 typedef boost::shared_ptr<ScriptBuffer> ScriptBufferPtr;
114 typedef std::vector<ScriptBufferPtr> ScriptBufferList;
116 ScriptBufferList script_buffers;
117 ScriptBufferPtr _current_buffer;
119 void session_going_away ();
120 void update_title ();
123 void setup_buffers ();
124 void refresh_scriptlist ();
125 void rebuild_menu ();
126 uint32_t count_scratch_buffers () const;
128 void script_changed ();
129 void script_selection_changed (ScriptBufferPtr n, bool force = false);
130 void update_gui_state ();
132 void append_text (std::string s);
133 void scroll_to_bottom ();
134 void clear_output ();
139 void delete_script ();
140 void revert_script ();
141 void import_script ();