lxgui
gui_slider_parser.cpp
1 #include "lxgui/gui_layout_node.hpp"
2 #include "lxgui/gui_out.hpp"
3 #include "lxgui/gui_parser_common.hpp"
4 #include "lxgui/gui_slider.hpp"
5 #include "lxgui/gui_texture.hpp"
6 
7 namespace lxgui::gui {
8 
11 
12  if (const auto attr = node.try_get_attribute_value<float>("valueStep"))
13  set_value_step(attr.value());
14  if (const auto attr = node.try_get_attribute_value<float>("minValue"))
15  set_min_value(attr.value());
16  if (const auto attr = node.try_get_attribute_value<float>("maxValue"))
17  set_max_value(attr.value());
18  if (const auto attr = node.try_get_attribute_value<float>("defaultValue"))
19  set_value(attr.value());
20  if (const auto attr = node.try_get_attribute_value<layer>("drawLayer"))
21  set_thumb_draw_layer(attr.value());
22  if (const auto attr = node.try_get_attribute_value<orientation>("orientation"))
23  set_orientation(attr.value());
24 }
25 
28 
29  if (const layout_node* thumb_node = node.try_get_child("ThumbTexture")) {
30  layout_node defaulted = *thumb_node;
31  defaulted.get_or_set_attribute_value("name", "$parentThumbTexture");
32 
33  auto thumb_texture = parse_region_(defaulted, "ARTWORK", "Texture");
34  if (thumb_texture) {
35  thumb_texture->set_manually_inherited(true);
36  set_thumb_texture(utils::static_pointer_cast<texture>(thumb_texture));
37  }
38 
39  warn_for_not_accessed_node(defaulted);
40  thumb_node->bypass_access_check();
41  }
42 }
43 
44 } // namespace lxgui::gui
virtual void parse_all_nodes_before_children_(const layout_node &node)
void parse_attributes_(const layout_node &node) override
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::optional< std::string_view > try_get_attribute_value(std::string_view name) const noexcept
Returns the value of the attribute with the provided name, nullopt if not found.
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.
void set_value(float value, bool silent=false)
Sets this slider's value.
Definition: gui_slider.cpp:217
void set_orientation(orientation orient)
Sets the orientation of this slider.
Definition: gui_slider.cpp:265
void parse_attributes_(const layout_node &node) override
void set_min_value(float min_value)
Sets this slider's minimum value.
Definition: gui_slider.cpp:164
void set_thumb_texture(utils::observer_ptr< texture > tex)
Sets the texture to use for the thumb.
Definition: gui_slider.cpp:251
void parse_all_nodes_before_children_(const layout_node &node) override
void set_thumb_draw_layer(layer thumb_layer)
Sets the draw layer of this slider's thumb texture.
Definition: gui_slider.cpp:280
void set_value_step(float value_step)
Sets this slider's value step.
Definition: gui_slider.cpp:232
void set_max_value(float max_value)
Sets this slider's maximum value.
Definition: gui_slider.cpp:182
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.