2 * Copyright (C) 2016-2017 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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 #ifndef __ardour_luawindow_h__
19 #define __ardour_luawindow_h__
21 #include <glibmm/thread.h>
23 #include <gtkmm/box.h>
24 #include <gtkmm/scrolledwindow.h>
25 #include <gtkmm/label.h>
26 #include <gtkmm/textview.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 "widgets/ardour_button.h"
42 #include "widgets/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);
56 void edit_script (const std::string&, const std::string&);
58 void set_session (ARDOUR::Session* s);
62 Buffer_Valid = 0x01, ///< script is loaded
63 Buffer_HasFile = 0x02,
64 Buffer_ReadOnly = 0x04,
66 Buffer_Scratch = 0x10,
72 ScriptBuffer (const std::string&);
73 ScriptBuffer (ARDOUR::LuaScriptInfoPtr);
74 //ScriptBuffer (const ScriptBuffer& other);
83 ARDOUR::LuaScriptInfo::ScriptType type;
88 static LuaWindow* _instance;
93 Gtk::Menu* _menu_scratch;
94 Gtk::Menu* _menu_snippet;
95 Gtk::Menu* _menu_actions;
97 sigc::connection _script_changed_connection;
100 Gtk::TextView outtext;
101 Gtk::ScrolledWindow scrollout;
103 ArdourWidgets::ArdourButton _btn_run;
104 ArdourWidgets::ArdourButton _btn_clear;
105 ArdourWidgets::ArdourButton _btn_open;
106 ArdourWidgets::ArdourButton _btn_save;
107 ArdourWidgets::ArdourButton _btn_delete;
108 ArdourWidgets::ArdourButton _btn_revert;
110 ArdourWidgets::ArdourDropdown script_select;
112 typedef boost::shared_ptr<ScriptBuffer> ScriptBufferPtr;
113 typedef std::vector<ScriptBufferPtr> ScriptBufferList;
115 ScriptBufferList script_buffers;
116 ScriptBufferPtr _current_buffer;
118 void session_going_away ();
119 void update_title ();
122 void setup_buffers ();
123 void refresh_scriptlist ();
124 void rebuild_menu ();
125 uint32_t count_scratch_buffers () const;
127 void script_changed ();
128 void script_selection_changed (ScriptBufferPtr n, bool force = false);
129 void update_gui_state ();
131 void append_text (std::string s);
132 void scroll_to_bottom ();
133 void clear_output ();
138 void delete_script ();
139 void revert_script ();
140 void import_script ();