From 1155da84dd85867a1835ade51d1302e7e5ca4b6f Mon Sep 17 00:00:00 2001 From: Zabooma Date: Fri, 1 Nov 2024 13:53:58 -0400 Subject: [PATCH] Add text control type for LuaDialog, based on Gtk::TextView --- gtk2_ardour/luadialog.cc | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gtk2_ardour/luadialog.cc b/gtk2_ardour/luadialog.cc index 3ff8a65338..27a7d7db92 100644 --- a/gtk2_ardour/luadialog.cc +++ b/gtk2_ardour/luadialog.cc @@ -591,6 +591,35 @@ protected: Gtk::FileChooserWidget _fc; }; +class LuaDialogText : public LuaDialogWidget +{ +public: + LuaDialogText (std::string const& key, std::string const& title, std::string const& dflt) + : LuaDialogWidget (key, title) + { + _text_view.set_wrap_mode (Gtk::WRAP_WORD); + _text_view.get_buffer()->set_text (dflt); + + _scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + + _scrolled_window.add(_text_view); + } + + Gtk::Widget* widget () + { + return &_scrolled_window; + } + + void assign (luabridge::LuaRef* rv) const + { + (*rv)[_key] = std::string (_text_view.get_buffer()->get_text()); + } + +protected: + Gtk::TextView _text_view; + Gtk::ScrolledWindow _scrolled_window; +}; + /* ***************************************************************************** * Lua Parameter Dialog */ @@ -659,6 +688,12 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr) dflt = i.value ()["default"].cast (); } w = new LuaDialogEntry (key, title, dflt); + } else if (type == "textarea") { + std::string dflt; + if (i.value ()["default"].isString ()) { + dflt = i.value ()["default"].cast (); + } + w = new LuaDialogText (key, title, dflt); } else if (type == "radio") { std::string dflt; if (!i.value ()["values"].isTable ()) {