lxgui
gui_check_button_parser.cpp
1 #include "lxgui/gui_check_button.hpp"
2 #include "lxgui/gui_layout_node.hpp"
3 #include "lxgui/gui_parser_common.hpp"
4 #include "lxgui/gui_texture.hpp"
5 
6 namespace lxgui::gui {
7 
10 
11  if (const layout_node* special_node = node.try_get_child("CheckedTexture")) {
12  std::string layer = special_node->get_attribute_value_or<std::string>("layer", "ARTWORK");
13 
14  layout_node defaulted = *special_node;
15  defaulted.get_or_set_attribute_value("name", "$parentCheckedTexture");
16  defaulted.get_or_set_attribute_value("setAllAnchors", "true");
17 
18  auto tex = parse_region_(defaulted, layer, "Texture");
19  if (tex) {
20  tex->set_manually_inherited(true);
21  set_checked_texture(utils::static_pointer_cast<texture>(tex));
22  }
23 
24  warn_for_not_accessed_node(defaulted);
25  special_node->bypass_access_check();
26  }
27 
28  if (const layout_node* special_node = node.try_get_child("DisabledCheckedTexture")) {
29  std::string layer = special_node->get_attribute_value_or<std::string>("layer", "ARTWORK");
30 
31  layout_node defaulted = *special_node;
32  defaulted.get_or_set_attribute_value("name", "$parentDisabledCheckedTexture");
33  defaulted.get_or_set_attribute_value("setAllAnchors", "true");
34 
35  auto tex = parse_region_(defaulted, layer, "Texture");
36  if (tex) {
37  tex->set_manually_inherited(true);
38  set_disabled_checked_texture(utils::static_pointer_cast<texture>(tex));
39  }
40 
41  warn_for_not_accessed_node(defaulted);
42  special_node->bypass_access_check();
43  }
44 }
45 
46 } // namespace lxgui::gui
void parse_all_nodes_before_children_(const layout_node &node) override
void set_disabled_checked_texture(utils::observer_ptr< texture > tex)
Sets this button's disabled checked texture.
void parse_all_nodes_before_children_(const layout_node &node) override
void set_checked_texture(utils::observer_ptr< texture > tex)
Sets this button's checked texture.
utils::observer_ptr< layered_region > parse_region_(const layout_node &node, const std::string &layer_name, const std::string &type)
An node in a layout file.
std::string_view get_or_set_attribute_value(std::string_view name, std::string_view value)
Returns the value of the attribute with the provided name, or set it if none.
const layout_node * try_get_child(std::string_view name) const noexcept
Returns the first child with a given name, or null if none.
layer
ID of a layer for rendering inside a frame.
void warn_for_not_accessed_node(const layout_node &node)
Emit a warning if this node (or any of its attributes/children) was not read.