Ardour  9.0-pre0-582-g084a23a80d
luadialog.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017-2018 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 
19 #ifndef _gtk2ardour_luadialog_h_
20 #define _gtk2ardour_luadialog_h_
21 
22 #include <cassert>
23 #include <gtkmm/scrolledwindow.h>
24 #include <gtkmm/table.h>
25 #include <gtkmm/progressbar.h>
26 
27 #include "LuaBridge/LuaBridge.h"
28 
29 #include "ardour_dialog.h"
30 #include "ardour_message.h"
31 
32 namespace LuaDialog {
33 
34 class Message {
35 public:
36 
37  enum MessageType {
39  };
40 
41  enum ButtonType {
43  };
44 
45  Message (std::string const&, std::string const&, Message::MessageType, Message::ButtonType);
46 
47  int run ();
48 
49 private:
50  Message (Message const&); // prevent copy construction
51 
54 
56 };
57 
59 public:
60  LuaDialogWidget (std::string const& key, std::string const& label, int col = 0, int colspan = -1)
61  : _key (key), _label (label), _col (col), _colspan (colspan)
62  {
63  if (_colspan < 0) {
64  _colspan = label.empty () ? 1 : 2;
65  }
66  }
67 
68  virtual ~LuaDialogWidget () {}
69 
70  virtual Gtk::Widget* widget () = 0;
71  virtual void assign (luabridge::LuaRef* rv) const = 0;
72  std::string const& label () const { return _label; }
73  std::string const& key () const { return _key; }
74  int col () const { return _col; }
75  int span () const { return _colspan; }
76 
77  void set_col (int col) { _col = col; }
78  void set_span (int span) { _colspan = span; }
79 
80 protected:
81  std::string _key;
82  std::string _label;
83  int _col;
84  int _colspan;
85 };
86 
87 
88 class Dialog {
89 public:
90  Dialog (std::string const&, luabridge::LuaRef);
91  ~Dialog ();
92  int run (lua_State *L);
93 
94 private:
95  Dialog (Dialog const&); // prevent copy construction
97 
100  typedef std::vector<LuaDialogWidget*> DialogWidgets;
102  std::string _title;
103 };
104 
113 {
114 public:
119  ProgressWindow (std::string const& title, bool allow_cancel);
120 
126  bool progress (float prog, std::string const& text = "");
127 
128  bool canceled () const {
129  return _canceled;
130  }
131 
137  void done ();
138 
139 private:
140  void cancel_clicked () {
141  _canceled = true;
142  }
143 
145  bool _canceled;
146 };
147 
148 }; // namespace
149 
150 #endif
DialogWidgets _widgets
Definition: luadialog.h:101
Dialog(Dialog const &)
Dialog(std::string const &, luabridge::LuaRef)
Gtk::ScrolledWindow _scroller
Definition: luadialog.h:99
void table_size_request(Gtk::Requisition *)
int run(lua_State *L)
std::vector< LuaDialogWidget * > DialogWidgets
Definition: luadialog.h:100
ArdourDialog _ad
Definition: luadialog.h:98
std::string _title
Definition: luadialog.h:102
void set_span(int span)
Definition: luadialog.h:78
LuaDialogWidget(std::string const &key, std::string const &label, int col=0, int colspan=-1)
Definition: luadialog.h:60
virtual Gtk::Widget * widget()=0
std::string const & label() const
Definition: luadialog.h:72
std::string const & key() const
Definition: luadialog.h:73
void set_col(int col)
Definition: luadialog.h:77
virtual void assign(luabridge::LuaRef *rv) const =0
Message(Message const &)
ArdourMessageDialog _message_dialog
Definition: luadialog.h:55
static Gtk::ButtonsType to_gtk_bt(ButtonType bt)
Message(std::string const &, std::string const &, Message::MessageType, Message::ButtonType)
static Gtk::MessageType to_gtk_mt(MessageType mt)
ProgressWindow(std::string const &title, bool allow_cancel)
Gtk::ProgressBar _bar
Definition: luadialog.h:144
bool progress(float prog, std::string const &text="")
ButtonsType
Definition: messagedialog.h:54