2016-02-23 09:42:13 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2016-02-23 09:42:13 -05:00
|
|
|
#ifndef __ardour_luawindow_h__
|
|
|
|
#define __ardour_luawindow_h__
|
|
|
|
|
|
|
|
#include <glibmm/thread.h>
|
|
|
|
|
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/scrolledwindow.h>
|
|
|
|
#include <gtkmm/label.h>
|
2017-07-16 22:55:52 -04:00
|
|
|
#include <gtkmm/textview.h>
|
2016-02-23 09:42:13 -05:00
|
|
|
#include <gtkmm/window.h>
|
|
|
|
|
2016-03-23 18:44:35 -04:00
|
|
|
#include "pbd/signals.h"
|
|
|
|
#include "pbd/stateful.h"
|
|
|
|
|
2016-02-23 09:42:13 -05:00
|
|
|
#include "ardour/ardour.h"
|
2016-03-23 18:44:35 -04:00
|
|
|
#include "ardour/luascripting.h"
|
2016-02-23 09:42:13 -05:00
|
|
|
#include "ardour/session_handle.h"
|
2016-03-23 18:44:35 -04:00
|
|
|
#include "ardour/types.h"
|
2016-02-23 09:42:13 -05:00
|
|
|
|
|
|
|
#include "gtkmm2ext/visibility_tracker.h"
|
|
|
|
|
|
|
|
#include "lua/luastate.h"
|
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
#include "widgets/ardour_button.h"
|
|
|
|
#include "widgets/ardour_dropdown.h"
|
2016-03-23 18:44:35 -04:00
|
|
|
|
2016-02-23 09:42:13 -05:00
|
|
|
class LuaWindow :
|
2021-09-19 22:26:24 -04:00
|
|
|
public ArdourWindow,
|
|
|
|
public PBD::ScopedConnectionList
|
2016-02-23 09:42:13 -05:00
|
|
|
{
|
2017-07-01 15:11:14 -04:00
|
|
|
public:
|
2016-02-23 09:42:13 -05:00
|
|
|
static LuaWindow* instance();
|
|
|
|
~LuaWindow();
|
|
|
|
|
|
|
|
void show_window ();
|
|
|
|
bool hide_window (GdkEventAny *ev);
|
2017-02-18 19:27:16 -05:00
|
|
|
void edit_script (const std::string&, const std::string&);
|
2016-02-23 09:42:13 -05:00
|
|
|
|
|
|
|
void set_session (ARDOUR::Session* s);
|
|
|
|
|
2016-03-23 18:44:35 -04:00
|
|
|
typedef enum {
|
|
|
|
Buffer_NOFLAG = 0x00,
|
|
|
|
Buffer_Valid = 0x01, ///< script is loaded
|
|
|
|
Buffer_HasFile = 0x02,
|
|
|
|
Buffer_ReadOnly = 0x04,
|
|
|
|
Buffer_Dirty = 0x08,
|
|
|
|
Buffer_Scratch = 0x10,
|
|
|
|
} BufferFlags;
|
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
class ScriptBuffer
|
|
|
|
{
|
2016-03-23 18:44:35 -04:00
|
|
|
public:
|
|
|
|
ScriptBuffer (const std::string&);
|
|
|
|
ScriptBuffer (ARDOUR::LuaScriptInfoPtr);
|
|
|
|
//ScriptBuffer (const ScriptBuffer& other);
|
|
|
|
~ScriptBuffer ();
|
|
|
|
|
|
|
|
bool load ();
|
|
|
|
|
|
|
|
std::string script;
|
|
|
|
std::string name;
|
|
|
|
std::string path;
|
|
|
|
BufferFlags flags;
|
|
|
|
ARDOUR::LuaScriptInfo::ScriptType type;
|
|
|
|
};
|
|
|
|
|
2017-07-01 15:11:14 -04:00
|
|
|
private:
|
2016-02-23 09:42:13 -05:00
|
|
|
LuaWindow ();
|
|
|
|
static LuaWindow* _instance;
|
|
|
|
|
2016-03-23 20:52:24 -04:00
|
|
|
LuaState *lua;
|
2016-02-23 09:42:13 -05:00
|
|
|
bool _visible;
|
2016-03-23 18:44:35 -04:00
|
|
|
|
|
|
|
Gtk::Menu* _menu_scratch;
|
|
|
|
Gtk::Menu* _menu_snippet;
|
|
|
|
Gtk::Menu* _menu_actions;
|
|
|
|
|
|
|
|
sigc::connection _script_changed_connection;
|
|
|
|
|
|
|
|
Gtk::TextView entry;
|
|
|
|
Gtk::TextView outtext;
|
|
|
|
Gtk::ScrolledWindow scrollout;
|
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
ArdourWidgets::ArdourButton _btn_run;
|
|
|
|
ArdourWidgets::ArdourButton _btn_clear;
|
|
|
|
ArdourWidgets::ArdourButton _btn_open;
|
|
|
|
ArdourWidgets::ArdourButton _btn_save;
|
|
|
|
ArdourWidgets::ArdourButton _btn_delete;
|
|
|
|
ArdourWidgets::ArdourButton _btn_revert;
|
2016-03-23 18:44:35 -04:00
|
|
|
|
2017-07-15 11:38:28 -04:00
|
|
|
ArdourWidgets::ArdourDropdown script_select;
|
2016-03-23 18:44:35 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
typedef std::shared_ptr<ScriptBuffer> ScriptBufferPtr;
|
2016-03-23 18:44:35 -04:00
|
|
|
typedef std::vector<ScriptBufferPtr> ScriptBufferList;
|
|
|
|
|
|
|
|
ScriptBufferList script_buffers;
|
|
|
|
ScriptBufferPtr _current_buffer;
|
2016-02-23 09:42:13 -05:00
|
|
|
|
|
|
|
void session_going_away ();
|
|
|
|
void update_title ();
|
2016-03-23 20:52:24 -04:00
|
|
|
void reinit_lua ();
|
2016-02-23 09:42:13 -05:00
|
|
|
|
2016-03-23 18:44:35 -04:00
|
|
|
void setup_buffers ();
|
|
|
|
void refresh_scriptlist ();
|
|
|
|
void rebuild_menu ();
|
|
|
|
uint32_t count_scratch_buffers () const;
|
|
|
|
|
|
|
|
void script_changed ();
|
2016-03-26 09:54:10 -04:00
|
|
|
void script_selection_changed (ScriptBufferPtr n, bool force = false);
|
2016-03-23 18:44:35 -04:00
|
|
|
void update_gui_state ();
|
2016-02-23 09:42:13 -05:00
|
|
|
|
|
|
|
void append_text (std::string s);
|
|
|
|
void scroll_to_bottom ();
|
|
|
|
void clear_output ();
|
|
|
|
|
2016-03-23 18:44:35 -04:00
|
|
|
void run_script ();
|
2016-02-23 09:42:13 -05:00
|
|
|
|
2016-03-23 18:44:35 -04:00
|
|
|
void new_script ();
|
|
|
|
void delete_script ();
|
2016-03-26 09:54:10 -04:00
|
|
|
void revert_script ();
|
2016-03-23 18:44:35 -04:00
|
|
|
void import_script ();
|
|
|
|
void save_script ();
|
2016-02-23 09:42:13 -05:00
|
|
|
};
|
|
|
|
|
2016-03-23 18:44:35 -04:00
|
|
|
|
2016-02-23 09:42:13 -05:00
|
|
|
#endif
|