summaryrefslogtreecommitdiff
path: root/gtk2_ardour/luadialog.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-09-02 15:42:34 +0200
committerRobin Gareus <robin@gareus.org>2019-09-02 15:44:43 +0200
commit2d680f30610623d32c7db1b16be6068d7f71a87a (patch)
tree6647a8adafa52cf1d20b004a5ac3b8e64c64bbe7 /gtk2_ardour/luadialog.cc
parent487503cab89eea17b74199c35eac6364e05d2c2c (diff)
Move LuaProgressDialog into "LuaDialog" namespace
Define class in header file Match C++ and Lua binding namespaces (for documentation)
Diffstat (limited to 'gtk2_ardour/luadialog.cc')
-rw-r--r--gtk2_ardour/luadialog.cc51
1 files changed, 49 insertions, 2 deletions
diff --git a/gtk2_ardour/luadialog.cc b/gtk2_ardour/luadialog.cc
index 9ce1e4b03c..79ba81f700 100644
--- a/gtk2_ardour/luadialog.cc
+++ b/gtk2_ardour/luadialog.cc
@@ -37,7 +37,7 @@
using namespace LuaDialog;
-/*******************************************************************************
+/* *****************************************************************************
* Simple Message Dialog
*/
Message::Message (std::string const& title, std::string const& msg, Message::MessageType mt, Message::ButtonType bt)
@@ -589,9 +589,10 @@ protected:
Gtk::FileChooserWidget _fc;
};
-/*******************************************************************************
+/* *****************************************************************************
* Lua Parameter Dialog
*/
+
Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
:_ad (title, true, false)
, _title (title)
@@ -840,3 +841,49 @@ Dialog::table_size_alloc (Gtk::Allocation& allocation)
_ad.set_size_request (-1, 512);
}
}
+
+/* *****************************************************************************
+ * Lua Progress Dialog
+ */
+
+ProgressWindow::ProgressWindow (std::string const& title, bool allow_cancel)
+ : ArdourDialog (title, true)
+ , _canceled (false)
+{
+ _bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT);
+
+ set_border_width (12);
+ get_vbox()->set_spacing (6);
+ get_vbox()->pack_start (_bar, false, false);
+
+ if (allow_cancel) {
+ using namespace Gtk;
+ Button* b = add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ b->signal_clicked().connect (sigc::mem_fun (*this, &ProgressWindow::cancel_clicked));
+ }
+
+ set_default_size (200, -1);
+ show_all ();
+}
+
+bool
+ProgressWindow::progress (float prog, std::string const& text)
+{
+ if (!text.empty ()) {
+ _bar.set_text (text);
+ }
+ if (prog < 0 || prog > 1) {
+ std::cerr << "pulse\n";
+ _bar.set_pulse_step(.1);
+ _bar.pulse();
+ } else {
+ _bar.set_fraction (prog);
+ }
+ ARDOUR::GUIIdle ();
+ return _canceled;
+}
+
+void
+ProgressWindow::done () {
+ Gtk::Dialog::response(_canceled ? Gtk::RESPONSE_CANCEL : Gtk::RESPONSE_OK);
+}