Widgets.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 #include <vector>
6 
8 {
9 
10  /*
11  * This is a RemoteGui client library which avoids including unnecessary headers.
12  * The RemoteGui Ice interface now includes a bunch of C++ header files which
13  * slow down compilation dramatically. To avoid this, this client library uses
14  * private implementation to prevent the inclusion of the header file.
15  * Please do not include any boost, Eigen, Simox or other headers in this file
16  * since this would destroy the whole purpose why this library exists.
17  */
18 
19  struct WidgetImpl;
20 
21  struct Widget
22  {
23  Widget(void* iceWidget);
24 
25  void setName(std::string const& name);
26  std::string const& getName() const;
27 
28  std::shared_ptr<WidgetImpl> impl;
29  };
30 
31  struct Label : Widget
32  {
33  Label();
34 
35  Label(std::string const& text);
36 
37  void setText(std::string const& text);
38  };
39 
40  struct LineEdit : Widget
41  {
42  LineEdit();
43 
44  std::string getValue();
45  void setValue(std::string const& text);
46 
47  bool hasValueChanged() const;
48  };
49 
50  struct ComboBox : Widget
51  {
52  ComboBox();
53 
54  void addOption(std::string const& option);
55 
56  void addOptions(std::initializer_list<std::string> options);
57 
58  void setOptions(std::vector<std::string> const& options);
59 
60  void setValue(std::string const& newValue);
61  std::string getValue() const;
62 
63  bool hasValueChanged() const;
64 
65  void setIndex(int index);
66  int getIndex() const;
67  };
68 
69  struct IntSpinBox : Widget
70  {
71  IntSpinBox();
72 
73  void setRange(int min, int max);
74 
75  int getValue() const;
76  void setValue(int newValue);
77 
78  bool hasValueChanged() const;
79  };
80 
81  struct IntSlider : Widget
82  {
83  IntSlider();
84 
85  void setRange(int min, int max);
86 
87  int getValue() const;
88  void setValue(int newValue);
89 
90  bool hasValueChanged() const;
91  };
92 
94  {
95  FloatSpinBox();
96 
97  void setRange(float min, float max);
98  void setSteps(int steps);
99  void setDecimals(int decimals);
100 
101  float getValue() const;
102  void setValue(float newValue);
103 
104  bool hasValueChanged() const;
105  };
106 
108  {
109  FloatSlider();
110 
111  void setRange(float min, float max);
112  void setSteps(int steps);
113 
114  float getValue() const;
115  void setValue(float newValue);
116 
117  bool hasValueChanged() const;
118  };
119 
120  struct Button : Widget
121  {
122  Button();
123 
124  void setLabel(std::string const& label);
125 
126  bool wasClicked() const;
127  };
128 
129  struct CheckBox : Widget
130  {
131  CheckBox();
132 
133  bool getValue() const;
134  void setValue(bool newValue);
135 
136  bool hasValueChanged() const;
137  };
138 
140  {
141  ToggleButton();
142 
143  void setLabel(std::string const& label);
144 
145  bool getValue() const;
146  void setValue(bool newValue);
147 
148  bool hasValueChanged() const;
149  };
150 
152  {
153  using Widget::Widget;
154 
155  void addChild(Widget const& child);
156 
157  void addChildren(std::initializer_list<Widget> children);
158  };
159 
161  {
162  HBoxLayout();
163 
164  HBoxLayout(std::initializer_list<Widget> children);
165  };
166 
168  {
169  VBoxLayout();
170 
171  VBoxLayout(std::initializer_list<Widget> children);
172  };
173 
174  struct Pos
175  {
176  int row;
177  int column;
178  };
179 
180  struct Span
181  {
182  int rows;
183  int columns;
184  };
185 
187  {
188  GridLayout();
189 
190  GridLayout& add(Widget const& child, Pos pos, Span span = Span{1, 1});
191  };
192 
194  {
195  GroupBox();
196 
197  GroupBox(std::initializer_list<Widget> children);
198 
199  void setLabel(std::string const& text);
200 
201  void setCollapsed(bool collapsed);
202  };
203 
204  struct VSpacer : Widget
205  {
206  VSpacer();
207  };
208 
209  struct HSpacer : Widget
210  {
211  HSpacer();
212  };
213 
214 
215 }
armarx::RemoteGui::Client::ComboBox::setIndex
void setIndex(int index)
Definition: Widgets.cpp:202
armarx::RemoteGui::Client::IntSpinBox::setValue
void setValue(int newValue)
Definition: Widgets.cpp:58
armarx::RemoteGui::Client::FloatSpinBox::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:342
armarx::RemoteGui::Client::FloatSpinBox::getValue
float getValue() const
Definition: Widgets.cpp:332
armarx::RemoteGui::Client::ComboBox::getIndex
int getIndex() const
Definition: Widgets.cpp:212
armarx::RemoteGui::Client::ContainerWidget::addChild
void addChild(Widget const &child)
Definition: Widgets.cpp:95
armarx::RemoteGui::Client::GridLayout::GridLayout
GridLayout()
Definition: Widgets.cpp:407
armarx::RemoteGui::Client::ToggleButton
Definition: Widgets.h:139
armarx::RemoteGui::Client::LineEdit::getValue
std::string getValue()
Definition: Widgets.cpp:141
armarx::RemoteGui::Client::Span::columns
int columns
Definition: Widgets.h:183
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::RemoteGui::Client::ToggleButton::ToggleButton
ToggleButton()
Definition: Widgets.cpp:252
armarx::RemoteGui::Client::VBoxLayout
Definition: Widgets.h:167
armarx::RemoteGui::Client::CheckBox::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:247
armarx::RemoteGui::Client::IntSlider::IntSlider
IntSlider()
Definition: Widgets.cpp:279
armarx::RemoteGui::Client::ToggleButton::setLabel
void setLabel(std::string const &label)
Definition: Widgets.cpp:258
armarx::RemoteGui::Client::Label
Definition: Widgets.h:31
armarx::RemoteGui::Client::HSpacer
Definition: Widgets.h:209
armarx::RemoteGui::Client::GridLayout::add
GridLayout & add(Widget const &child, Pos pos, Span span=Span{1, 1})
Definition: Widgets.cpp:412
armarx::RemoteGui::Client::FloatSlider::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:376
armarx::RemoteGui::Client::FloatSpinBox::setValue
void setValue(float newValue)
Definition: Widgets.cpp:337
armarx::RemoteGui::Client::Button::wasClicked
bool wasClicked() const
Definition: Widgets.cpp:130
armarx::RemoteGui::Client::Widget::setName
void setName(std::string const &name)
Definition: Widgets.cpp:19
armarx::RemoteGui::Client::Pos::row
int row
Definition: Widgets.h:176
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:267
armarx::RemoteGui::Client::VBoxLayout::VBoxLayout
VBoxLayout()
Definition: Widgets.cpp:84
armarx::RemoteGui::Client::FloatSpinBox::setRange
void setRange(float min, float max)
Definition: Widgets.cpp:313
armarx::RemoteGui::Client::ContainerWidget
Definition: Widgets.h:151
armarx::RemoteGui::Client::GroupBox::GroupBox
GroupBox()
Definition: Widgets.cpp:381
armarx::RemoteGui::Client::FloatSlider::setValue
void setValue(float newValue)
Definition: Widgets.cpp:371
armarx::RemoteGui::Client::IntSpinBox::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:63
armarx::RemoteGui::Client::VSpacer
Definition: Widgets.h:204
armarx::RemoteGui::Client::Widget::impl
std::shared_ptr< WidgetImpl > impl
Definition: Widgets.h:28
armarx::RemoteGui::Client::IntSlider::setValue
void setValue(int newValue)
Definition: Widgets.cpp:297
armarx::RemoteGui::Client::IntSlider::getValue
int getValue() const
Definition: Widgets.cpp:292
armarx::RemoteGui::Client::CheckBox::getValue
bool getValue() const
Definition: Widgets.cpp:237
armarx::RemoteGui::Client::GridLayout
Definition: Widgets.h:186
armarx::RemoteGui::Client::ContainerWidget::addChildren
void addChildren(std::initializer_list< Widget > children)
Definition: Widgets.cpp:100
armarx::RemoteGui::Client::Pos
Definition: Widgets.h:174
armarx::RemoteGui::Client::Widget::Widget
Widget(void *iceWidget)
Definition: Widgets.cpp:8
armarx::RemoteGui::Client::Widget
Definition: Widgets.h:21
armarx::RemoteGui::Client::ComboBox::ComboBox
ComboBox()
Definition: Widgets.cpp:157
armarx::RemoteGui::Client::FloatSlider::getValue
float getValue() const
Definition: Widgets.cpp:366
armarx::RemoteGui::Client::FloatSlider
Definition: Widgets.h:107
armarx::RemoteGui::Client::IntSlider::setRange
void setRange(int min, int max)
Definition: Widgets.cpp:285
armarx::RemoteGui::Client::HBoxLayout::HBoxLayout
HBoxLayout()
Definition: Widgets.cpp:73
armarx::RemoteGui::Client::IntSlider
Definition: Widgets.h:81
armarx::RemoteGui::Client::ComboBox::addOption
void addOption(std::string const &option)
Definition: Widgets.cpp:162
armarx::RemoteGui::Client::GroupBox
Definition: Widgets.h:193
armarx::RemoteGui::Client::LineEdit
Definition: Widgets.h:40
armarx::RemoteGui::Client::GroupBox::setCollapsed
void setCollapsed(bool collapsed)
Definition: Widgets.cpp:401
armarx::RemoteGui::Client::ToggleButton::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:274
armarx::RemoteGui::Client::FloatSpinBox::FloatSpinBox
FloatSpinBox()
Definition: Widgets.cpp:307
armarx::RemoteGui::Client::FloatSpinBox::setDecimals
void setDecimals(int decimals)
Definition: Widgets.cpp:326
armarx::RemoteGui::Client::FloatSlider::FloatSlider
FloatSlider()
Definition: Widgets.cpp:347
armarx::RemoteGui::Client::ComboBox
Definition: Widgets.h:50
armarx::RemoteGui::Client::FloatSpinBox::setSteps
void setSteps(int steps)
Definition: Widgets.cpp:320
armarx::RemoteGui::Client::Span
Definition: Widgets.h:180
armarx::RemoteGui::Client::ComboBox::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:226
armarx::RemoteGui::Client::Button::setLabel
void setLabel(std::string const &label)
Definition: Widgets.cpp:124
armarx::RemoteGui::Client::Pos::column
int column
Definition: Widgets.h:177
armarx::RemoteGui::Client::GroupBox::setLabel
void setLabel(std::string const &text)
Definition: Widgets.cpp:395
armarx::RemoteGui::Client::FloatSlider::setRange
void setRange(float min, float max)
Definition: Widgets.cpp:353
armarx::RemoteGui::Client::HBoxLayout
Definition: Widgets.h:160
option
#define option(type, fn)
armarx::RemoteGui::Client::Label::setText
void setText(std::string const &text)
Definition: Widgets.cpp:40
armarx::RemoteGui::Client::LineEdit::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:152
armarx::RemoteGui::Client::LineEdit::setValue
void setValue(std::string const &text)
Definition: Widgets.cpp:146
armarx::RemoteGui::Client::ToggleButton::setValue
void setValue(bool newValue)
Definition: Widgets.cpp:269
armarx::RemoteGui::Client::LineEdit::LineEdit
LineEdit()
Definition: Widgets.cpp:135
armarx::RemoteGui::Client::CheckBox::CheckBox
CheckBox()
Definition: Widgets.cpp:231
armarx::RemoteGui::Client::CheckBox::setValue
void setValue(bool newValue)
Definition: Widgets.cpp:242
armarx::RemoteGui::Client::IntSpinBox::setRange
void setRange(int min, int max)
Definition: Widgets.cpp:51
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:294
armarx::RemoteGui::Client::ComboBox::addOptions
void addOptions(std::initializer_list< std::string > options)
Definition: Widgets.cpp:174
armarx::RemoteGui::Client::Span::rows
int rows
Definition: Widgets.h:182
armarx::RemoteGui::Client::IntSpinBox
Definition: Widgets.h:69
armarx::RemoteGui::Client::ComboBox::setOptions
void setOptions(std::vector< std::string > const &options)
Definition: Widgets.cpp:182
armarx::RemoteGui::Client::IntSpinBox::getValue
int getValue() const
Definition: Widgets.cpp:68
armarx::RemoteGui::Client::ComboBox::getValue
std::string getValue() const
Definition: Widgets.cpp:197
armarx::RemoteGui::Client::CheckBox
Definition: Widgets.h:129
armarx::RemoteGui::Client::Label::Label
Label()
Definition: Widgets.cpp:29
armarx::RemoteGui::Client::Button
Definition: Widgets.h:120
armarx::RemoteGui::Client::IntSlider::hasValueChanged
bool hasValueChanged() const
Definition: Widgets.cpp:302
armarx::RemoteGui::Client::Button::Button
Button()
Definition: Widgets.cpp:118
armarx::RemoteGui::Client
Definition: EigenWidgets.cpp:8
armarx::RemoteGui::Client::IntSpinBox::IntSpinBox
IntSpinBox()
Definition: Widgets.cpp:45
armarx::RemoteGui::Client::FloatSpinBox
Definition: Widgets.h:93
armarx::RemoteGui::Client::HSpacer::HSpacer
HSpacer()
Definition: Widgets.cpp:113
armarx::RemoteGui::Client::ComboBox::setValue
void setValue(std::string const &newValue)
Definition: Widgets.cpp:192
armarx::RemoteGui::Client::VSpacer::VSpacer
VSpacer()
Definition: Widgets.cpp:108
armarx::RemoteGui::Client::Widget::getName
std::string const & getName() const
Definition: Widgets.cpp:24
armarx::RemoteGui::Client::ToggleButton::getValue
bool getValue() const
Definition: Widgets.cpp:264
armarx::RemoteGui::Client::FloatSlider::setSteps
void setSteps(int steps)
Definition: Widgets.cpp:360