1 #include "lxgui/gui_layout_node.hpp"
2 #include "lxgui/gui_manager.hpp"
3 #include "lxgui/gui_out.hpp"
4 #include "lxgui/gui_texture.hpp"
11 parse_tex_coords_node_(node);
16 parse_gradient_node_(node);
19 void texture::parse_attributes_(
const layout_node& node) {
28 void texture::parse_tex_coords_node_(
const layout_node& node) {
29 if (
const layout_node* tex_coords_node = node.try_get_child(
"TexCoords")) {
31 {tex_coords_node->get_attribute_value_or<
float>(
"left", 0.0f),
32 tex_coords_node->get_attribute_value_or<
float>(
"top", 0.0f),
33 tex_coords_node->get_attribute_value_or<
float>(
"right", 1.0f),
34 tex_coords_node->get_attribute_value_or<
float>(
"bottom", 1.0f)});
38 void texture::parse_gradient_node_(
const layout_node& node) {
39 if (
const layout_node* gradient_node = node.try_get_child(
"Gradient")) {
40 std::string orientation_name =
41 gradient_node->get_attribute_value_or<std::string>(
"orientation",
"HORIZONTAL");
44 if (
auto converted = utils::from_string<orientation>(orientation_name);
45 converted.has_value()) {
46 orient = converted.value();
49 <<
": Unknown gradient orientation for " <<
name_ <<
": \"" << orientation_name
50 <<
"\". No gradient will be shown for this texture." << std::endl;
54 const layout_node* min_color_node = gradient_node->try_get_child(
"MinColor");
55 if (!min_color_node) {
57 <<
": Gradient requires MinColor child node." << std::endl;
61 const layout_node* max_color_node = gradient_node->try_get_child(
"MaxColor");
62 if (!max_color_node) {
64 <<
": Gradient requires MaxColor child node." << std::endl;
void parse_attributes_(const layout_node &node) override
void parse_layout(const layout_node &node) override
Parses data from a layout_node.
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.
const layout_node * try_get_child(std::string_view name) const noexcept
Returns the first child with a given name, or null if none.
color parse_color_node_(const layout_node &node)
void set_gradient(const gradient &g)
Adds a gradient effect to this texture.
void set_tex_rect(const std::array< float, 4 > &texture_rect)
Sets this texture's texture coordinates.
void set_solid_color(const color &c)
Sets this texture's color.
void set_filter_mode(material::filter filt)
Sets this texture's filtering mode.
void parse_layout(const layout_node &node) override
Parses data from a layout_node.
void set_texture(const std::string &file_name)
Sets this texture's texture file.
const std::string warning