LayoutWidgets.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Basic.h"
4 
6 {
7  template <typename Derived>
8  struct ChildrenMixin
9  {
10  Derived& appendChild(WidgetPtr const& child)
11  {
12  Derived& this_ = *static_cast<Derived*>(this);
13  this_.widget().children.push_back(child);
14  return this_;
15  }
16  Derived& prependChild(WidgetPtr const& child)
17  {
18  Derived& this_ = *static_cast<Derived*>(this);
19  this_.widget().children.insert(this_.widget().children.begin(), child);
20  return this_;
21  }
22  Derived& addChild(WidgetPtr const& child)
23  {
24  return appendChild(child);
25  }
26  Derived& addChildren(std::vector<WidgetPtr> const& children)
27  {
28  Derived& this_ = *static_cast<Derived*>(this);
29  this_.widget().children.insert(
30  this_.widget().children.end(),
31  children.begin(), children.end()
32  );
33  return this_;
34  }
35 
36  Derived& children(std::vector<WidgetPtr> const& children)
37  {
38  Derived& this_ = *static_cast<Derived*>(this);
39  this_.widget().children = children;
40  return this_;
41  }
42 
43  Derived& child(WidgetPtr const& child)
44  {
45  Derived& this_ = *static_cast<Derived*>(this);
46  this_.widget().children = {child};
47  return this_;
48  }
49 
50  const WidgetPtr& child(std::size_t i)
51  {
52  Derived& this_ = *static_cast<Derived*>(this);
53  return this_.widget().children.at(i);
54  }
55 
56  Derived& addTextLabel(std::string const& text)
57  {
58  return appendChild(new Label("", makeValue(text), {}, {}, {}));
59  }
60 
61  Derived& addHSpacer()
62  {
63  return appendChild(new HSpacer);
64  }
65 
66  Derived& addVSpacer()
67  {
68  return appendChild(new VSpacer);
69  }
70 
71  Derived& addEmptyWidget()
72  {
73  return appendChild(new Widget);
74  }
75 
76  Derived& addHLine()
77  {
78  return appendChild(new HLine);
79  }
80 
81  Derived& addVLine()
82  {
83  return appendChild(new VLine);
84  }
85  };
86 
88  : public NoValueMixin<HBoxLayout, HBoxLayoutBuilder>
89  , public ChildrenMixin<HBoxLayoutBuilder>
90  {
91  using NoValueMixin::NoValueMixin;
92  };
93 
95  : public NoValueMixin<VBoxLayout, VBoxLayoutBuilder>
96  , public ChildrenMixin<VBoxLayoutBuilder>
97  {
98  using NoValueMixin::NoValueMixin;
99  };
100 
102  : public NoValueMixin<SimpleGridLayout, SimpleGridLayoutBuilder>
103  , public ChildrenMixin<SimpleGridLayoutBuilder>
104  {
106  using NoValueMixin::NoValueMixin;
107 
109  {
110  widget().columns = n;
111  return *this;
112  }
113 
115  {
116  widget().columns = n;
117  return *this;
118  }
119 
120  using Base::addChild;
122  {
123  SimpleGridLayoutSpanningChildPtr c = new SimpleGridLayoutSpanningChild;
124  c->children.emplace_back(child);
125  c->columns = colspan;
126  return appendChild(c);
127  }
128 
129  using Base::addTextLabel;
130  SimpleGridLayoutBuilder& addTextLabel(std::string const& text, int colspan)
131  {
132  return addChild(new Label("", makeValue(text), {}, {}, {}), colspan);
133  }
134 
135  using Base::addHSpacer;
137  {
138  return addChild(new HSpacer, colspan);
139  }
140 
141  using Base::addVSpacer;
143  {
144  return addChild(new VSpacer, colspan);
145  }
146 
147  using Base::addEmptyWidget;
149  {
150  return addChild(new Widget, colspan);
151  }
152 
153  using Base::addHLine;
155  {
156  return addChild(new HLine, colspan);
157  }
158 
159  using Base::addVLine;
161  {
162  return addChild(new VLine, colspan);
163  }
164  };
165 
167  : public NoValueMixin<GroupBox, GroupBoxBuilder>
168  , public ChildrenMixin<GroupBoxBuilder>
169  , public LabelMixin<GroupBoxBuilder>
170  {
171  GroupBoxBuilder(const std::string& name) : NoValueMixin(name)
172  {
173  label(name);
174  }
175 
176  GroupBoxBuilder& collapsed(bool isCollapsed = true)
177  {
178  this->widget().collapsed = isCollapsed;
179  return *this;
180  }
181  };
182 
184  : public NoValueMixin<GridLayout, GridLayoutBuilder>
185  //can't use ChildrenMixin since it is missing the index information
186  {
187  using NoValueMixin::NoValueMixin;
188 
189  GridLayoutBuilder& addChild(WidgetPtr const& child, int row, int col, int spanRow = 1, int spanCol = 1)
190  {
191  this->widget().children.emplace_back(child);
192  this->widget().childrenLayoutInfo.push_back({row, col, spanRow, spanCol});
193  return *this;
194  }
195 
196  GridLayoutBuilder& addTextLabel(std::string const& text, int row, int col, int spanRow = 1, int spanCol = 1)
197  {
198  return addChild(new Label("", makeValue(text), {}, {}, {}), row, col, spanRow, spanCol);
199  }
200 
201  GridLayoutBuilder& addHSpacer(int row, int col, int spanRow = 1, int spanCol = 1)
202  {
203  return addChild(new HSpacer, row, col, spanRow, spanCol);
204  }
205 
206  GridLayoutBuilder& addVSpacer(int row, int col, int spanRow = 1, int spanCol = 1)
207  {
208  return addChild(new VSpacer, row, col, spanRow, spanCol);
209  }
210 
211  GridLayoutBuilder& addEmptyWidget(int row, int col, int spanRow = 1, int spanCol = 1)
212  {
213  return addChild(new Widget, row, col, spanRow, spanCol);
214  }
215 
216  GridLayoutBuilder& addHLine(int row, int col, int spanRow = 1, int spanCol = 1)
217  {
218  return addChild(new HLine, row, col, spanRow, spanCol);
219  }
220 
221  GridLayoutBuilder& addVLine(int row, int col, int spanRow = 1, int spanCol = 1)
222  {
223  return addChild(new VLine, row, col, spanRow, spanCol);
224  }
225  };
226 }
227 
228 namespace armarx::RemoteGui
229 {
230  inline detail::HBoxLayoutBuilder makeHBoxLayout(std::string const& name = "")
231  {
232  return detail::HBoxLayoutBuilder(name);
233  }
234 
235  inline detail::SimpleGridLayoutBuilder makeSimpleGridLayout(std::string const& name = "")
236  {
237  return detail::SimpleGridLayoutBuilder(name);
238  }
239 
240  inline detail::GridLayoutBuilder makeGridLayout(std::string const& name = "")
241  {
242  return detail::GridLayoutBuilder(name);
243  }
244 
245  inline detail::VBoxLayoutBuilder makeVBoxLayout(std::string const& name = "")
246  {
247  return detail::VBoxLayoutBuilder(name);
248  }
249 
250  inline detail::GroupBoxBuilder makeGroupBox(std::string const& name = "")
251  {
252  return detail::GroupBoxBuilder(name);
253  }
254 }
armarx::RemoteGui::detail::GroupBoxBuilder
Definition: LayoutWidgets.h:166
armarx::RemoteGui::detail::ChildrenMixin::child
Derived & child(WidgetPtr const &child)
Definition: LayoutWidgets.h:43
armarx::RemoteGui::detail::GridLayoutBuilder::addTextLabel
GridLayoutBuilder & addTextLabel(std::string const &text, int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:196
armarx::RemoteGui::makeVBoxLayout
detail::VBoxLayoutBuilder makeVBoxLayout(std::string const &name="")
Definition: LayoutWidgets.h:245
armarx::RemoteGui::detail::ChildrenMixin
Definition: LayoutWidgets.h:8
armarx::RemoteGui::makeHBoxLayout
detail::HBoxLayoutBuilder makeHBoxLayout(std::string const &name="")
Definition: LayoutWidgets.h:230
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addEmptyWidget
SimpleGridLayoutBuilder & addEmptyWidget(int colspan)
Definition: LayoutWidgets.h:148
armarx::RemoteGui::detail::ChildrenMixin::child
const WidgetPtr & child(std::size_t i)
Definition: LayoutWidgets.h:50
Basic.h
armarx::RemoteGui::detail::HBoxLayoutBuilder
Definition: LayoutWidgets.h:87
armarx::RemoteGui::detail::VBoxLayoutBuilder
Definition: LayoutWidgets.h:94
armarx::RemoteGui
Definition: LightweightRemoteGuiComponentPlugin.h:30
armarx::RemoteGui::detail::GridLayoutBuilder::addHSpacer
GridLayoutBuilder & addHSpacer(int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:201
armarx::RemoteGui::detail
Definition: Basic.h:10
armarx::RemoteGui::Client::HSpacer
Definition: Widgets.h:209
armarx::RemoteGui::detail::ChildrenMixin::appendChild
Derived & appendChild(WidgetPtr const &child)
Definition: LayoutWidgets.h:10
armarx::RemoteGui::detail::GridLayoutBuilder
Definition: LayoutWidgets.h:183
armarx::RemoteGui::detail::ChildrenMixin::addVLine
Derived & addVLine()
Definition: LayoutWidgets.h:81
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addChild
SimpleGridLayoutBuilder & addChild(WidgetPtr const &child, int colspan)
Definition: LayoutWidgets.h:121
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::RemoteGui::detail::LabelMixin
Definition: Basic.h:189
armarx::RemoteGui::Client::VSpacer
Definition: Widgets.h:204
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::columns
SimpleGridLayoutBuilder & columns(int n)
Definition: LayoutWidgets.h:114
armarx::RemoteGui::makeSimpleGridLayout
detail::SimpleGridLayoutBuilder makeSimpleGridLayout(std::string const &name="")
Definition: LayoutWidgets.h:235
armarx::RemoteGui::detail::ChildrenMixin::addTextLabel
Derived & addTextLabel(std::string const &text)
Definition: LayoutWidgets.h:56
armarx::RemoteGui::detail::GridLayoutBuilder::addVSpacer
GridLayoutBuilder & addVSpacer(int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:206
visionx::voxelgrid::Label
uint32_t Label
Type of an object label.
Definition: types.h:7
armarx::RemoteGui::detail::GroupBoxBuilder::collapsed
GroupBoxBuilder & collapsed(bool isCollapsed=true)
Definition: LayoutWidgets.h:176
armarx::RemoteGui::detail::WidgetMixin::widget
WidgetT & widget()
Definition: Basic.h:50
armarx::RemoteGui::detail::GridLayoutBuilder::addVLine
GridLayoutBuilder & addVLine(int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:221
armarx::RemoteGui::Client::Widget
Definition: Widgets.h:21
armarx::RemoteGui::detail::ChildrenMixin::addChild
Derived & addChild(WidgetPtr const &child)
Definition: LayoutWidgets.h:22
armarx::RemoteGui::detail::GridLayoutBuilder::addHLine
GridLayoutBuilder & addHLine(int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:216
armarx::RemoteGui::detail::ChildrenMixin::prependChild
Derived & prependChild(WidgetPtr const &child)
Definition: LayoutWidgets.h:16
armarx::RemoteGui::detail::NoValueMixin
Definition: Basic.h:57
armarx::RemoteGui::detail::ChildrenMixin::addHLine
Derived & addHLine()
Definition: LayoutWidgets.h:76
armarx::RemoteGui::detail::LabelMixin< GroupBoxBuilder >::label
GroupBoxBuilder & label(std::string const &label)
Definition: Basic.h:191
armarx::RemoteGui::makeGroupBox
detail::GroupBoxBuilder makeGroupBox(std::string const &name="")
Definition: LayoutWidgets.h:250
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addVLine
SimpleGridLayoutBuilder & addVLine(int colspan)
Definition: LayoutWidgets.h:160
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addHLine
SimpleGridLayoutBuilder & addHLine(int colspan)
Definition: LayoutWidgets.h:154
armarx::RemoteGui::detail::SimpleGridLayoutBuilder
Definition: LayoutWidgets.h:101
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addTextLabel
SimpleGridLayoutBuilder & addTextLabel(std::string const &text, int colspan)
Definition: LayoutWidgets.h:130
armarx::RemoteGui::detail::ChildrenMixin::addHSpacer
Derived & addHSpacer()
Definition: LayoutWidgets.h:61
armarx::RemoteGui::makeValue
ValueVariant makeValue(bool value)
Definition: Storage.cpp:133
armarx::RemoteGui::detail::ChildrenMixin::children
Derived & children(std::vector< WidgetPtr > const &children)
Definition: LayoutWidgets.h:36
armarx::RemoteGui::detail::ChildrenMixin::addVSpacer
Derived & addVSpacer()
Definition: LayoutWidgets.h:66
armarx::WidgetDescription::WidgetPtr
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
Definition: NJointControllerBase.h:66
armarx::RemoteGui::detail::GridLayoutBuilder::addChild
GridLayoutBuilder & addChild(WidgetPtr const &child, int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:189
armarx::RemoteGui::detail::ChildrenMixin::addChildren
Derived & addChildren(std::vector< WidgetPtr > const &children)
Definition: LayoutWidgets.h:26
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::cols
SimpleGridLayoutBuilder & cols(int n)
Definition: LayoutWidgets.h:108
armarx::RemoteGui::makeGridLayout
detail::GridLayoutBuilder makeGridLayout(std::string const &name="")
Definition: LayoutWidgets.h:240
armarx::RemoteGui::detail::GridLayoutBuilder::addEmptyWidget
GridLayoutBuilder & addEmptyWidget(int row, int col, int spanRow=1, int spanCol=1)
Definition: LayoutWidgets.h:211
armarx::RemoteGui::detail::ChildrenMixin::addEmptyWidget
Derived & addEmptyWidget()
Definition: LayoutWidgets.h:71
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addHSpacer
SimpleGridLayoutBuilder & addHSpacer(int colspan)
Definition: LayoutWidgets.h:136
armarx::RemoteGui::detail::SimpleGridLayoutBuilder::addVSpacer
SimpleGridLayoutBuilder & addVSpacer(int colspan)
Definition: LayoutWidgets.h:142
armarx::RemoteGui::detail::GroupBoxBuilder::GroupBoxBuilder
GroupBoxBuilder(const std::string &name)
Definition: LayoutWidgets.h:171