From 2d680f30610623d32c7db1b16be6068d7f71a87a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 2 Sep 2019 15:42:34 +0200 Subject: Move LuaProgressDialog into "LuaDialog" namespace Define class in header file Match C++ and Lua binding namespaces (for documentation) --- gtk2_ardour/luadialog.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'gtk2_ardour/luadialog.h') diff --git a/gtk2_ardour/luadialog.h b/gtk2_ardour/luadialog.h index 68d332d0a5..a2acff6574 100644 --- a/gtk2_ardour/luadialog.h +++ b/gtk2_ardour/luadialog.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "LuaBridge/LuaBridge.h" @@ -98,6 +99,49 @@ private: std::string _title; }; +/** Synchronous GUI-thread Progress dialog + * + * This shows a modal progress dialog with an optional + * "Cancel" button. Since it runs in the UI thread + * the script needs to regularly call progress(), + * as well as close the dialog, as needed. + */ +class ProgressWindow : public ArdourDialog +{ +public: + /** Create a new progress window. + * @param title Window title + * @param allow_cancel include a "Cancel" option + */ + ProgressWindow (std::string const& title, bool allow_cancel); + + /** Report progress and update GUI. + * @param prog progress in range 0..1 show a bar, values outside this range show a pulsing dialog. + * @param text optional text to show on the progress-bar + * @return true if cancel was clicked, false otherwise + */ + bool progress (float prog, std::string const& text = ""); + + bool canceled () const { + return _canceled; + } + + /** Close and hide the dialog. + * + * This is required to be at the end, since the dialog + * is modal and prevents other UI operations while visible. + */ + void done (); + +private: + void cancel_clicked () { + _canceled = true; + } + + Gtk::ProgressBar _bar; + bool _canceled; +}; + }; // namespace #endif -- cgit v1.2.3