Ardour  9.0-pre0-1051-g8dd89616e1
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 <ytkmm/box.h>
23 #include <ytkmm/scrolledwindow.h>
24 #include <ytkmm/label.h>
25 #include <ytkmm/textview.h>
26 #include <ytkmm/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 edit_script (const std::string&, const std::string&);
54 
56 
57  typedef enum {
58  Buffer_NOFLAG = 0x00,
59  Buffer_Valid = 0x01,
62  Buffer_Dirty = 0x08,
64  } BufferFlags;
65 
67  {
68  public:
69  ScriptBuffer (const std::string&);
71  //ScriptBuffer (const ScriptBuffer& other);
73 
74  bool load ();
75 
76  std::string script;
77  std::string name;
78  std::string path;
81  };
82 
83 private:
86 
88 
92 
93  sigc::connection _script_changed_connection;
94 
98 
105 
107 
108  typedef std::shared_ptr<ScriptBuffer> ScriptBufferPtr;
109  typedef std::vector<ScriptBufferPtr> ScriptBufferList;
110 
113 
115  void update_title ();
116  void reinit_lua ();
117 
118  void setup_buffers ();
120  void rebuild_menu ();
121  uint32_t count_scratch_buffers () const;
122 
123  void script_changed ();
124  void script_selection_changed (ScriptBufferPtr n, bool force = false);
126 
127  void append_text (std::string s);
129  void clear_output ();
130 
131  void run_script ();
132 
133  void new_script ();
134  void delete_script ();
135  void revert_script ();
136  void import_script ();
137  void save_script ();
138 };
139 
140 
ARDOUR::LuaScriptInfo::ScriptType type
Definition: luawindow.h:80
ScriptBuffer(const std::string &)
std::string script
Definition: luawindow.h:76
ScriptBuffer(ARDOUR::LuaScriptInfoPtr)
void clear_output()
void import_script()
LuaState * lua
Definition: luawindow.h:87
void setup_buffers()
ArdourWidgets::ArdourButton _btn_delete
Definition: luawindow.h:103
ArdourWidgets::ArdourButton _btn_revert
Definition: luawindow.h:104
sigc::connection _script_changed_connection
Definition: luawindow.h:93
void scroll_to_bottom()
void run_script()
void refresh_scriptlist()
Gtk::Menu * _menu_snippet
Definition: luawindow.h:90
Gtk::Menu * _menu_scratch
Definition: luawindow.h:89
void update_gui_state()
void edit_script(const std::string &, const std::string &)
ArdourWidgets::ArdourButton _btn_save
Definition: luawindow.h:102
void reinit_lua()
static LuaWindow * instance()
std::shared_ptr< ScriptBuffer > ScriptBufferPtr
Definition: luawindow.h:108
void delete_script()
void new_script()
static LuaWindow * _instance
Definition: luawindow.h:85
ArdourWidgets::ArdourButton _btn_open
Definition: luawindow.h:101
void revert_script()
ScriptBufferList script_buffers
Definition: luawindow.h:111
ArdourWidgets::ArdourButton _btn_clear
Definition: luawindow.h:100
Gtk::ScrolledWindow scrollout
Definition: luawindow.h:97
ArdourWidgets::ArdourButton _btn_run
Definition: luawindow.h:99
ScriptBufferPtr _current_buffer
Definition: luawindow.h:112
void script_changed()
Gtk::Menu * _menu_actions
Definition: luawindow.h:91
ArdourWidgets::ArdourDropdown script_select
Definition: luawindow.h:106
Gtk::TextView entry
Definition: luawindow.h:95
void save_script()
void set_session(ARDOUR::Session *s)
void rebuild_menu()
Gtk::TextView outtext
Definition: luawindow.h:96
void script_selection_changed(ScriptBufferPtr n, bool force=false)
void append_text(std::string s)
@ Buffer_Valid
script is loaded
Definition: luawindow.h:59
@ Buffer_HasFile
Definition: luawindow.h:60
@ Buffer_Dirty
Definition: luawindow.h:62
@ Buffer_Scratch
Definition: luawindow.h:63
@ Buffer_NOFLAG
Definition: luawindow.h:58
@ Buffer_ReadOnly
Definition: luawindow.h:61
void update_title()
void session_going_away()
std::vector< ScriptBufferPtr > ScriptBufferList
Definition: luawindow.h:109
uint32_t count_scratch_buffers() const
std::shared_ptr< LuaScriptInfo > LuaScriptInfoPtr
Definition: luascripting.h:103