Ardour  9.0-pre0-350-gf17a656217
luawindow.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
3  *
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.
8  *
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.
13  *
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.
17  */
18 #pragma once
19 
20 #include <glibmm/thread.h>
21 
22 #include <gtkmm/box.h>
23 #include <gtkmm/scrolledwindow.h>
24 #include <gtkmm/label.h>
25 #include <gtkmm/textview.h>
26 #include <gtkmm/window.h>
27 
28 #include "pbd/signals.h"
29 #include "pbd/stateful.h"
30 
31 #include "ardour/ardour.h"
32 #include "ardour/luascripting.h"
33 #include "ardour/session_handle.h"
34 #include "ardour/types.h"
35 
37 
38 #include "lua/luastate.h"
39 
40 #include "widgets/ardour_button.h"
42 
43 #include "ardour_window.h"
44 
45 class LuaWindow :
46  public ArdourWindow,
48 {
49 public:
50  static LuaWindow* instance();
52 
53  void show_window ();
55  void edit_script (const std::string&, const std::string&);
56 
58 
59  typedef enum {
60  Buffer_NOFLAG = 0x00,
61  Buffer_Valid = 0x01,
64  Buffer_Dirty = 0x08,
66  } BufferFlags;
67 
69  {
70  public:
71  ScriptBuffer (const std::string&);
73  //ScriptBuffer (const ScriptBuffer& other);
75 
76  bool load ();
77 
78  std::string script;
79  std::string name;
80  std::string path;
83  };
84 
85 private:
88 
90  bool _visible;
91 
95 
96  sigc::connection _script_changed_connection;
97 
101 
108 
110 
111  typedef std::shared_ptr<ScriptBuffer> ScriptBufferPtr;
112  typedef std::vector<ScriptBufferPtr> ScriptBufferList;
113 
116 
118  void update_title ();
119  void reinit_lua ();
120 
121  void setup_buffers ();
123  void rebuild_menu ();
124  uint32_t count_scratch_buffers () const;
125 
126  void script_changed ();
127  void script_selection_changed (ScriptBufferPtr n, bool force = false);
129 
130  void append_text (std::string s);
132  void clear_output ();
133 
134  void run_script ();
135 
136  void new_script ();
137  void delete_script ();
138  void revert_script ();
139  void import_script ();
140  void save_script ();
141 };
142 
143 
ARDOUR::LuaScriptInfo::ScriptType type
Definition: luawindow.h:82
ScriptBuffer(const std::string &)
std::string script
Definition: luawindow.h:78
ScriptBuffer(ARDOUR::LuaScriptInfoPtr)
void clear_output()
void import_script()
LuaState * lua
Definition: luawindow.h:89
void setup_buffers()
ArdourWidgets::ArdourButton _btn_delete
Definition: luawindow.h:106
ArdourWidgets::ArdourButton _btn_revert
Definition: luawindow.h:107
sigc::connection _script_changed_connection
Definition: luawindow.h:96
void scroll_to_bottom()
bool _visible
Definition: luawindow.h:90
void run_script()
void refresh_scriptlist()
Gtk::Menu * _menu_snippet
Definition: luawindow.h:93
Gtk::Menu * _menu_scratch
Definition: luawindow.h:92
void update_gui_state()
void edit_script(const std::string &, const std::string &)
ArdourWidgets::ArdourButton _btn_save
Definition: luawindow.h:105
void reinit_lua()
bool hide_window(GdkEventAny *ev)
static LuaWindow * instance()
std::shared_ptr< ScriptBuffer > ScriptBufferPtr
Definition: luawindow.h:111
void delete_script()
void new_script()
static LuaWindow * _instance
Definition: luawindow.h:87
ArdourWidgets::ArdourButton _btn_open
Definition: luawindow.h:104
void revert_script()
ScriptBufferList script_buffers
Definition: luawindow.h:114
ArdourWidgets::ArdourButton _btn_clear
Definition: luawindow.h:103
Gtk::ScrolledWindow scrollout
Definition: luawindow.h:100
ArdourWidgets::ArdourButton _btn_run
Definition: luawindow.h:102
ScriptBufferPtr _current_buffer
Definition: luawindow.h:115
void script_changed()
Gtk::Menu * _menu_actions
Definition: luawindow.h:94
ArdourWidgets::ArdourDropdown script_select
Definition: luawindow.h:109
void show_window()
Gtk::TextView entry
Definition: luawindow.h:98
void save_script()
void set_session(ARDOUR::Session *s)
void rebuild_menu()
Gtk::TextView outtext
Definition: luawindow.h:99
void script_selection_changed(ScriptBufferPtr n, bool force=false)
void append_text(std::string s)
@ Buffer_Valid
script is loaded
Definition: luawindow.h:61
@ Buffer_HasFile
Definition: luawindow.h:62
@ Buffer_Dirty
Definition: luawindow.h:64
@ Buffer_Scratch
Definition: luawindow.h:65
@ Buffer_NOFLAG
Definition: luawindow.h:60
@ Buffer_ReadOnly
Definition: luawindow.h:63
void update_title()
void session_going_away()
std::vector< ScriptBufferPtr > ScriptBufferList
Definition: luawindow.h:112
uint32_t count_scratch_buffers() const
std::shared_ptr< LuaScriptInfo > LuaScriptInfoPtr
Definition: luascripting.h:103