Virtual Testbed
Ship dynamics simulator for extreme conditions
TaskDialog.hh
1 #ifndef VTESTBED_GUI_TASKDIALOG_HH
2 #define VTESTBED_GUI_TASKDIALOG_HH
3 
4 #include <string>
5 
6 #include <vtestbed/gui/Task.hh>
7 
8 namespace vtb {
9 
10  namespace gui {
11 
12  class TaskDialog {
13 
14  private:
15  enum struct State {
16  Initial,
17  Running,
18  Error
19  };
20 
21  private:
22  Task _task;
23  std::string _title, _errorText;
24  State _state = State::Initial;
25  bool _visible = false;
26  bool _open = false;
27 
28  public:
29 
30  inline void
31  title(const std::string& rhs) {
32  this->_title = rhs;
33  }
34 
35  inline void
36  error(const std::string& message) {
37  this->_state = State::Error;
38  this->_errorText = message;
39  }
40 
41  inline void
42  visible(bool b) {
43  this->_visible = b;
44  }
45 
46  inline bool
47  visible() const {
48  return this->_visible;
49  }
50 
51  inline bool
52  invisible() const {
53  return !this->_visible;
54  }
55 
56  bool
57  draw();
58 
59  template <class Function>
60  void
61  run(Function func) {
62  this->_state = State::Running;
63  this->_visible = true;
64  this->_task.run(func);
65  }
66 
67  inline void open() { this->_open = true; }
68 
69  };
70 
71  }
72 
73 }
74 
75 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9