neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
ui_element.hpp
Go to the documentation of this file.
1// ui_element.hpp
2/*
3neoGFX Resource Compiler
4Copyright(C) 2019 Leigh Johnston
5
6This program is free software: you can redistribute it and / or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <algorithm>
24#include <boost/format.hpp>
29#include <neogfx/core/units.hpp>
36
37namespace neogfx::nrc
38{
39 template <typename Base = i_ui_element>
41 {
42 typedef ui_element<Base> self_type;
44 public:
45 using i_ui_element::no_parent;
46 using i_ui_element::wrong_type;
47 public:
50 using i_ui_element::data_t;
51 using i_ui_element::array_data_t;
53 protected:
54 typedef std::set<std::string> data_names_t;
55 public:
57 iParser{ aParser }, iParent{ nullptr }, iName{ aParser.current_element() }, iFragmentName{ aParser.current_fragment() }, iTypeName{ aParser.current_element() }, iMemberElement{ false }, iId{ aParser.get_optional<neolib::string>("id") }, iAnonymousIdCounter{ 0u }, iType{ aType }
58 {
59 init();
60 }
62 iParser{ aParser }, iParent{ nullptr }, iName{ aParser.current_element() }, iFragmentName{ aParser.current_fragment() }, iTypeName{ aParser.current_element() }, iMemberElement{ false }, iId{ aId }, iAnonymousIdCounter{ 0u }, iType{ aType }
63 {
64 init();
65 }
66 ui_element(const i_ui_element_parser& aParser, i_ui_element& aParent, ui_element_type aType) :
67 iParser{ aParser }, iParent{ &aParent }, iName{ aParser.current_element() }, iFragmentName{ aParser.current_fragment() }, iTypeName{ aParser.current_element() }, iMemberElement{ false }, iAnonymousIdCounter{ 0u }, iId{ aParser.get_optional<neolib::string>("id") }, iType{ aType }
68 {
69 init();
70 parent().children().push_back(neolib::ref_ptr<i_ui_element>{ this });
71 }
72 ui_element(const i_ui_element_parser& aParser, i_ui_element& aParent, ui_element_type aType, const neolib::optional<neolib::string>& aId) :
73 iParser{ aParser }, iParent{ &aParent }, iName{ aParser.current_element() }, iFragmentName{ aParser.current_fragment() }, iTypeName{ aParser.current_element() }, iMemberElement{ false }, iAnonymousIdCounter{ 0u }, iId{ aId }, iType{ aType }
74 {
75 init();
76 parent().children().push_back(neolib::ref_ptr<i_ui_element>{ this });
77 }
78 ui_element(const i_ui_element_parser& aParser, i_ui_element& aParent, member_element_t, ui_element_type aType) :
79 iParser{ aParser }, iParent{ &aParent }, iName{ aParser.current_element() }, iFragmentName{ aParser.current_fragment() }, iTypeName{ aParser.current_element() }, iMemberElement{ true }, iAnonymousIdCounter{ 0u }, iId{}, iType{ aType }
80 {
81 init();
82 parent().children().push_back(neolib::ref_ptr<i_ui_element>{ this });
83 }
85 {
86 }
87 public:
88 const i_ui_element_parser& parser() const override
89 {
90 return iParser;
91 }
92 public:
93 const neolib::i_string& name() const override
94 {
95 return iName;
96 }
97 const neolib::i_string& fragment_name() const override
98 {
99 return iFragmentName;
100 }
101 const neolib::i_string& type_name() const override
102 {
103 if (iDragDrop != std::nullopt && *iDragDrop)
104 {
105 thread_local neolib::string result;
106 result = "drag_drop_target<"_s + iTypeName + ">"_s;
107 return result;
108 }
109 return iTypeName;
110 }
111 void set_type_name(const neolib::i_string& aTypeName) override
112 {
113 iTypeName = aTypeName;
114 }
116 {
117 return iHeaders;
118 }
119 void add_header(std::string const& aHeader)
120 {
121 iHeaders.push_back(neolib::string{ aHeader });
122 }
123 public:
124 bool is_member_element() const override
125 {
126 return iMemberElement;
127 }
128 bool anonymous() const override
129 {
130 return !iId;
131 }
132 const neolib::i_string& id() const override
133 {
134 if (!anonymous())
135 return *iId;
136 return anonymous_id();
137 }
138 const neolib::i_string& anonymous_id() const override
139 {
140 if (!iAnonymousId)
141 {
142 if (!is_member_element())
143 {
144 if (has_parent())
145 iAnonymousId = parent().generate_anonymous_id();
146 else
147 iAnonymousId = parser().generate_anonymous_id();
148 }
149 else
150 {
151 switch (type() & ui_element_type::MASK_RESERVED_SPECIFIC)
152 {
153 case ui_element_type::Label:
154 iAnonymousId = parent().id() + ".label()";
155 break;
156 case ui_element_type::LineEdit:
157 iAnonymousId = parent().id() + ".input_box()";
158 break;
159 case ui_element_type::TextWidget:
160 iAnonymousId = parent().id() + ".text_widget()";
161 break;
162 case ui_element_type::ImageWidget:
163 iAnonymousId = parent().id() + ".image_widget()";
164 break;
165 default:
166 throw unsupported_member_element();
167 }
168 }
169 }
170 return *iAnonymousId;
171 }
172 using base_type::generate_anonymous_id;
173 void generate_anonymous_id(neolib::i_string& aNewAnonymousId) const override
174 {
175 aNewAnonymousId = neolib::string{ id() + "_" + boost::lexical_cast<std::string>(++iAnonymousIdCounter) };
176 }
177 ui_element_type type() const override
178 {
179 return iType;
180 }
181 using base_type::check_element_ref;
182 public:
183 const i_ui_element& fragment() const override
184 {
185 auto e = static_cast<const i_ui_element*>(this);
186 while (e->has_parent())
187 e = &e->parent();
188 return *e;
189 }
190 i_ui_element& fragment() override
191 {
192 return const_cast<i_ui_element&>(to_const(*this).fragment());
193 }
194 bool has_parent() const override
195 {
196 return iParent != nullptr;
197 }
198 const i_ui_element& parent() const override
199 {
200 if (has_parent())
201 return *iParent;
202 throw no_parent();
203 }
204 i_ui_element& parent() override
205 {
206 return const_cast<i_ui_element&>(to_const(*this).parent());
207 }
208 const children_t& children() const override
209 {
210 return iChildren;
211 }
213 {
214 return iChildren;
215 }
216 public:
217 void instantiate(i_app& aApp) override
218 {
219 }
220 void instantiate(i_widget& aWidget) override
221 {
222 }
223 void instantiate(i_layout& aLayout) override
224 {
225 }
226 protected:
227 using i_ui_element::enum_to_string;
228 using i_ui_element::get_enum;
229 using i_ui_element::get_scalar;
230 using i_ui_element::get_scalars;
231 using i_ui_element::emplace_2;
232 using i_ui_element::emplace_4;
233 using i_ui_element::get_color;
234 protected:
236 {
237 return iDataNames;
238 }
240 {
241 iDataNames.merge(aNames);
242 }
243 void parse(const neolib::i_string& aName, const data_t& aData) override
244 {
245 if (data_names().find(aName) == data_names().end())
246 {
247 std::cerr << parser().source_location() << ": warning: nrc: Unknown element key '" << aName << "' in element '" << id() << "'." << std::endl;
248 return;
249 }
250 if (aName == "drag_drop")
251 {
252 iDragDrop = aData.get<bool>();
253 if (*iDragDrop)
254 add_header("neogfx/app/drag_drop.hpp");
255 }
256 if (aName == "type")
257 iWidgetType = get_enum<widget_type>(aData);
258 if (aName == "weight")
259 iWeight.emplace(get_scalar<double>(aData));
260 else if (aName == "size_policy")
261 iSizePolicy = get_enum<size_constraint>(aData);
262 else if (aName == "alignment")
263 iAlignment = get_enum<alignment>(aData);
264 else if (aName == "size")
265 iFixedSize.emplace(get_scalar<length>(aData));
266 else if (aName == "minimum_size")
267 iMinimumSize.emplace(get_scalar<length>(aData));
268 else if (aName == "minimum_width")
269 iMinimumWidth.emplace(get_scalar<length>(aData));
270 else if (aName == "minimum_height")
271 iMinimumHeight.emplace(get_scalar<length>(aData));
272 else if (aName == "maximum_size")
273 iMaximumSize.emplace(get_scalar<length>(aData));
274 else if (aName == "maximum_width")
275 iMaximumWidth.emplace(get_scalar<length>(aData));
276 else if (aName == "maximum_height")
277 iMaximumHeight.emplace(get_scalar<length>(aData));
278 else if (aName == "padding")
279 iPadding.emplace(get_scalar<length>(aData));
280 else if (aName == "enabled")
281 iEnabled = aData.get<bool>();
282 else if (aName == "disabled")
283 iEnabled = !aData.get<bool>();
284 else if (aName == "focus_policy")
285 iFocusPolicy.first = get_enum<focus_policy>(aData);
286 else if (aName == "text")
287 iText = aData.get<neolib::i_string>();
288 else if (aName == "label")
289 iLabelText = aData.get<neolib::i_string>();
290 else if (aName == "image" || (aName == "uri" && (type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::ImageWidget))
291 iImage = aData.get<neolib::i_string>();
292 else if (aName == "aspect_ratio")
293 iAspectRatio = get_enum<aspect_ratio>(aData);
294 else if (aName == "placement")
295 {
296 if ((type() & ui_element_type::MASK_RESERVED_SPECIFIC) != ui_element_type::TextField)
297 {
298 if ((type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::Label || (type() & ui_element_type::HasLabel) == ui_element_type::HasLabel)
299 iLabelPlacement = get_enum<label_placement>(aData);
300 else if ((type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::ImageWidget || (type() & ui_element_type::HasImage) == ui_element_type::HasImage)
301 iImagePlacement = get_enum<cardinal>(aData);
302 }
303 else
304 iTextFieldPlacement = get_enum<text_field_placement>(aData);
305 }
306 else if (aName == "base_color")
307 iBaseColor = get_color(aData);
308 else if (aName == "background_color")
309 iBackgroundColor = get_color(aData);
310 else if (aName == "opacity")
311 iOpacity = aData.get<double>();
312 else if (aName == "transparency")
313 iOpacity = 1.0 - aData.get<double>();
314 else if (aName == "default_focus")
315 iDefaultFocus = aData.get<neolib::i_string>();
316 }
317 void parse(const neolib::i_string& aName, const array_data_t& aArrayData) override
318 {
319 if (data_names().find(aName) == data_names().end())
320 {
321 std::cerr << parser().source_location() << ": warning: nrc: Unknown element key '" << aName << "' in element '" << id() << "'." << std::endl;
322 return;
323 }
324 if (aName == "size_policy" && !aArrayData.empty())
325 iSizePolicy = size_policy::from_string(
326 aArrayData[0u].get<neolib::i_string>().to_std_string(),
327 aArrayData[std::min<std::size_t>(1u, aArrayData.size() - 1u)].get<neolib::i_string>().to_std_string());
328 else if (aName == "alignment")
329 iAlignment = get_enum<alignment>(aArrayData);
330 else if (aName == "size")
331 emplace_2<length>("size", iFixedSize);
332 else if (aName == "minimum_size")
333 emplace_2<length>("minimum_size", iMinimumSize);
334 else if (aName == "maximum_size")
335 emplace_2<length>("maximum_size", iMaximumSize);
336 else if (aName == "padding")
337 emplace_4<length>("padding", iPadding);
338 else if (aName == "weight")
339 emplace_2<double>("weight", iWeight);
340 else if (aName == "focus_policy")
341 iFocusPolicy.first = get_enum<focus_policy>(aArrayData, iFocusPolicy.second, "Default");
342 else if (aName == "base_color")
343 iBaseColor = get_color(aArrayData);
344 else if (aName == "background_color")
345 iBackgroundColor = get_color(aArrayData);
346 }
347 void add_element_ref(const neolib::i_string& aRef) override
348 {
349 auto const& fullRef = aRef.to_std_string_view();
350 auto part = fullRef.find_first_of('.');
351 auto ref = fullRef.substr(0, part);
352 auto resolved = parser().find(neolib::string{ ref });
353 if (!resolved || (part == std::string::npos && resolved->fragment_name() != fragment_name()))
354 throw element_not_found(std::string{ ref });
355 if (part != std::string::npos)
356 iRefs.insert(neolib::string{ ref });
357 }
359 {
360 return iRefs;
361 }
362 const neolib::i_string& generate_ctor_params(bool aParamsAfter = false) const override
363 {
364 std::string temp;
365 if (iWidgetType && *iWidgetType == widget_type::Child)
366 temp += "i_widget& aParent";
367 for (auto const& ref : iRefs)
368 {
369 if (!temp.empty())
370 temp += ", ";
371 auto const& e = parser().at(ref);
372 temp += e.fragment_name().to_std_string() + "& " + e.id().to_std_string();
373 }
374 if (aParamsAfter && !temp.empty())
375 temp += ", ";
376 thread_local neolib::string result;
377 result = temp;
378 return result;
379 }
380 const neolib::i_string& generate_base_ctor_args(bool aArgsAfter = false) const override
381 {
382 std::string temp;
383 if (iWidgetType && *iWidgetType == widget_type::Child)
384 temp += "aParent";
385 if (!temp.empty())
386 {
387 if (aArgsAfter)
388 temp += ", ";
389 else
390 temp = " " + temp + " ";
391 }
392 thread_local neolib::string result;
393 result = temp;
394 return result;
395 }
396 void emit_preamble() const override
397 {
398 for (auto const& child : children())
399 child->emit_preamble();
400 }
401 void emit_ctor() const override
402 {
403 for (auto const& child : children())
404 child->emit_ctor();
405 }
406 void emit_body() const override
407 {
408 if (iSizePolicy)
409 emit(" %1%.set_size_policy(%2%);\n", id(), *iSizePolicy);
410 if (iAlignment)
411 emit(" %1%.set_alignment(%2%);\n", id(), enum_to_string("alignment", *iAlignment));
412 if (iFixedSize)
413 emit(" %1%.set_fixed_size(size{ %2%, %3% });\n", id(), iFixedSize->cx, iFixedSize->cy);
414 if (iMinimumSize)
415 emit(" %1%.set_minimum_size(size{ %2%, %3% });\n", id(), iMinimumSize->cx, iMinimumSize->cy);
416 if (iMinimumWidth)
417 emit(" %1%.set_minimum_width(%2%);\n", id(), *iMinimumWidth);
418 if (iMinimumHeight)
419 emit(" %1%.set_minimum_height(%2%);\n", id(), *iMinimumHeight);
420 if (iMaximumSize)
421 emit(" %1%.set_maximum_size(size{ %2%, %3% });\n", id(), iMaximumSize->cx, iMaximumSize->cy);
422 if (iMaximumWidth)
423 emit(" %1%.set_maximum_width(%2%);\n", id(), *iMaximumWidth);
424 if (iMaximumHeight)
425 emit(" %1%.set_maximum_height(%2%);\n", id(), *iMaximumHeight);
426 if (iWeight)
427 emit(" %1%.set_weight(size{ %2%, %3% });\n", id(), iWeight->cx, iWeight->cy);
428 if (iPadding)
429 {
430 auto const& padding = *iPadding;
432 {
433 if (padding.left == padding.top)
434 emit(" %1%.set_padding(neogfx::padding{ %2% });\n", id(), padding.left);
435 else
436 emit(" %1%.set_padding(neogfx::padding{ %2%, %3% });\n", id(), padding.left, padding.top);
437 }
438 else
439 emit(" %1%.set_padding(neogfx::padding{ %2%, %3%, %4%, %5% });\n", id(), padding.left, padding.top, padding.right, padding.bottom);
440 }
441 if (iEnabled)
442 emit(" %1%.%2%();\n", id(), *iEnabled ? "enable" : "disable");
443 if (iFocusPolicy.first)
444 {
445 if (!iFocusPolicy.second)
446 emit(" %1%.set_focus_policy(%2%);\n", id(), enum_to_string("focus_policy", *iFocusPolicy.first));
447 else
448 emit(" %1%.set_focus_policy(%1%.focus_policy() | %2%);\n", id(), enum_to_string("focus_policy", *iFocusPolicy.first));
449 }
450 if (iLabelPlacement)
451 emit(" %1%.set_placement(%2%);\n", id(), enum_to_string("label_placement", *iLabelPlacement));
452 if (iTextFieldPlacement)
453 emit(" %1%.set_placement(%2%);\n", id(), enum_to_string("text_field_placement", *iTextFieldPlacement));
454 if (iImage)
455 emit(" %1%.set_image(image{ \"%2%\" });\n", id(), *iImage);
456 if (iAspectRatio)
457 emit(" %1%.set_aspect_ratio(%2%);\n", id(), enum_to_string("aspect_ratio", *iAspectRatio));
458 if (iImagePlacement)
459 emit(" %1%.set_placement(%2%);\n", id(), enum_to_string("cardinal", *iImagePlacement));
460 if (iText)
461 emit(" %1%.set_text(\"%2%\"_t);\n", id(), *iText);
462 if (iLabelText)
463 emit(" %1%.label().set_text(\"%2%\"_t);\n", id(), *iLabelText);
464 if (iOpacity)
465 emit(" %1%.set_opacity(%2%);\n", id(), *iOpacity);
466 if (iBaseColor)
467 emit(" %1%.set_base_color(color{ %2% });\n", id(), *iBaseColor);
468 if (iBackgroundColor)
469 emit(" %1%.set_background_color(color{ %2% });\n", id(), *iBackgroundColor);
470 if (iDefaultFocus)
471 {
472 check_element_ref(*iDefaultFocus);
473 emit(" %1%.set_focus();\n", *iDefaultFocus);
474 }
475 if ((type() & ui_element_type::Widget) == ui_element_type::Widget &&
476 (type() & ui_element_type::Separator) != ui_element_type::Separator && has_parent() &&
477 (parent().type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::StatusBar)
478 {
479 if (!iPadding)
480 emit(" %1%.set_padding(neogfx::padding{});\n", id());
481 emit(" %1%.set_font_role(font_role::StatusBar);\n", id());
482 }
483 for (auto const& child : children())
484 child->emit_body();
485 }
486 protected:
488 {
489 if ((parent().type() & ui_element_type::MASK_RESERVED_GENERIC) == ui_element_type::Window)
490 {
491 switch (type() & ui_element_type::MASK_RESERVED_SPECIFIC)
492 {
493 case ui_element_type::MenuBar:
494 return ".menu_layout()";
495 case ui_element_type::Toolbar:
496 return ".toolbar_layout()";
497 case ui_element_type::StatusBar:
498 return "";
499 default:
500 return ".client_layout()";
501 }
502 }
503 else if ((parent().type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::GroupBox)
504 return ".item_layout()";
505 else if ((parent().type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::StatusBar)
506 return ".normal_layout()";
507 else
508 return "";
509 }
510 void emit_generic_ctor() const
511 {
512 if (is_member_element())
513 return;
514 emit(",\n"
515 " %1%{ %2%%3% }", id(), parent().id(), layout());
516 }
517 void emit_generic_ctor(const std::optional<neolib::string>& aText) const
518 {
519 if (is_member_element())
520 return;
521 emit(",\n"
522 " %1%{ %2%%3%, \"%4%\"_t }", id(), parent().id(), layout(), *aText);
523 }
524 template <typename Enum>
525 std::enable_if_t<std::is_enum_v<Enum>, void> emit_generic_ctor(std::string const& aEnumName, Enum aEnum) const
526 {
527 if (is_member_element())
528 return;
529 emit(",\n"
530 " %1%{ %2%%3%, %4% }", id(), parent().id(), layout(), enum_to_string(aEnumName, aEnum));
531 }
532 template <typename T>
533 void emit_generic_ctor(const T& aArgument) const
534 {
535 if (is_member_element())
536 return;
537 emit(",\n"
538 " %1%{ %2%%3%, %4% }", id(), parent().id(), layout(), aArgument);
539 }
540 protected:
541 void emit(std::string const& aArgument) const
542 {
543 parser().emit(aArgument);
544 }
545 template <typename... Args>
546 void emit(std::string const& aFormat, const Args&... aArguments) const
547 {
548 parser().emit(aFormat, base_type::convert_emit_argument(aArguments)...);
549 }
550 protected:
551 private:
552 void init()
553 {
554 if (!anonymous())
555 parser().index(id(), *this);
556 if (!has_parent() && (type() & ui_element_type::Widget) == ui_element_type::Widget)
557 add_data_names({ "type", "default_focus" });
558 if ((type() & ui_element_type::Widget) == ui_element_type::Widget)
559 add_data_names({ "drag_drop", "enabled", "disabled", "focus_policy" });
560 if ((type() & ui_element_type::HasGeometry) == ui_element_type::HasGeometry)
561 add_data_names({ "size_policy", "padding", "minimum_size", "maximum_size", "size", "minimum_width", "minimum_height", "maximum_width", "maximum_height", "weight" });
562 if ((type() & ui_element_type::HasAlignment) == ui_element_type::HasAlignment)
563 add_data_names({ "alignment" });
564 if ((type() & (ui_element_type::HasText | ui_element_type::HasLabel)) != ui_element_type::None)
565 add_data_names({ "text" });
566 if ((type() & (ui_element_type::HasImage | ui_element_type::HasLabel)) != ui_element_type::None)
567 add_data_names({ "image", "aspect_ratio", "placement" });
568 if ((type() & ui_element_type::MASK_RESERVED_SPECIFIC) == ui_element_type::ImageWidget)
569 add_data_names({ "uri" });
570 if ((type() & ui_element_type::HasColor) == ui_element_type::HasColor)
571 add_data_names({ "base_color", "background_color", "opacity", "transparency" });
572 }
573 private:
574 const i_ui_element_parser& iParser;
575 i_ui_element* iParent;
576 neolib::string iName;
577 neolib::string iFragmentName;
578 neolib::string iTypeName;
580 bool iMemberElement;
581 data_names_t iDataNames;
583 mutable neolib::optional<neolib::string> iAnonymousId;
584 mutable uint32_t iAnonymousIdCounter;
585 ui_element_type iType;
586 children_t iChildren;
588 std::optional<bool> iDragDrop;
589 std::optional<widget_type> iWidgetType;
590 std::optional<size_policy> iSizePolicy;
591 std::optional<alignment> iAlignment;
592 std::optional<basic_size<length>> iFixedSize;
593 std::optional<basic_size<length>> iMinimumSize;
594 std::optional<basic_size<length>> iMaximumSize;
595 std::optional<length> iMinimumWidth;
596 std::optional<length> iMinimumHeight;
597 std::optional<length> iMaximumWidth;
598 std::optional<length> iMaximumHeight;
599 std::optional<size> iWeight;
600 std::optional<basic_padding<length>> iPadding;
601 std::optional<bool> iEnabled;
602 std::pair<std::optional<focus_policy>, bool> iFocusPolicy;
603 std::optional<label_placement> iLabelPlacement;
604 std::optional<text_field_placement> iTextFieldPlacement;
605 std::optional<string> iText;
606 std::optional<string> iLabelText;
607 std::optional<string> iImage;
608 std::optional<aspect_ratio> iAspectRatio;
609 std::optional<cardinal> iImagePlacement;
610 std::optional<double> iOpacity;
611 std::optional<color> iBaseColor;
612 std::optional<color> iBackgroundColor;
613 std::optional<string> iDefaultFocus;
614 };
615}
virtual void index(const neolib::i_string &aId, const i_ui_element &aElement) const =0
virtual void emit(const neolib::i_string &aText) const =0
virtual const i_ui_element * find(const neolib::i_string &aId) const =0
virtual void generate_anonymous_id(neolib::i_string &aNewAnonymousId) const =0
virtual const i_ui_element & at(const neolib::i_string &aId) const =0
void emit_ctor() const override
bool is_member_element() const override
neolib::ref_ptr< i_ui_element > element_ptr_t
const neolib::i_string & generate_base_ctor_args(bool aArgsAfter=false) const override
void emit_generic_ctor() const
const children_t & children() const override
i_ui_element & fragment() override
void set_type_name(const neolib::i_string &aTypeName) override
void parse(const neolib::i_string &aName, const data_t &aData) override
i_ui_element & parent() override
ui_element(const i_ui_element_parser &aParser, i_ui_element &aParent, member_element_t, ui_element_type aType)
const i_ui_element & parent() const override
const neolib::i_string & generate_ctor_params(bool aParamsAfter=false) const override
ui_element_type type() const override
void generate_anonymous_id(neolib::i_string &aNewAnonymousId) const override
void add_header(std::string const &aHeader)
const neolib::i_string & anonymous_id() const override
const neolib::i_string & name() const override
neolib::vector< neolib::simple_variant > concrete_array_data_t
neolib::string layout() const
bool anonymous() const override
const neolib::i_string & type_name() const override
const neolib::i_string & fragment_name() const override
void emit(std::string const &aArgument) const
void emit_preamble() const override
void emit(std::string const &aFormat, const Args &... aArguments) const
void emit_body() const override
ui_element(const i_ui_element_parser &aParser, ui_element_type aType)
const i_ui_element & fragment() const override
const data_names_t & data_names() const
void parse(const neolib::i_string &aName, const array_data_t &aArrayData) override
void add_data_names(data_names_t aNames)
void emit_generic_ctor(const T &aArgument) const
neolib::vector< element_ptr_t > children_t
void instantiate(i_app &aApp) override
ui_element(const i_ui_element_parser &aParser, i_ui_element &aParent, ui_element_type aType, const neolib::optional< neolib::string > &aId)
const i_ui_element_parser & parser() const override
const neolib::i_set< neolib::i_string > & element_refs() const override
void instantiate(i_layout &aLayout) override
children_t & children() override
const neolib::i_string & id() const override
void instantiate(i_widget &aWidget) override
ui_element(const i_ui_element_parser &aParser, ui_element_type aType, const neolib::optional< neolib::string > &aId)
std::enable_if_t< std::is_enum_v< Enum >, void > emit_generic_ctor(std::string const &aEnumName, Enum aEnum) const
void add_element_ref(const neolib::i_string &aRef) override
std::set< std::string > data_names_t
ui_element(const i_ui_element_parser &aParser, i_ui_element &aParent, ui_element_type aType)
bool has_parent() const override
const neolib::i_vector< neolib::i_string > & headers() const override
void emit_generic_ctor(const std::optional< neolib::string > &aText) const
bool empty() const noexcept
std::string_view to_std_string_view() const noexcept
Definition i_string.hpp:76
std::string to_std_string() const
Definition i_string.hpp:75
void push_back(abstract_value_type const &aValue) final
Definition vector.hpp:201
object_type ui_element_type