lxgui
gui_scroll_frame_parser.cpp
1 #include "lxgui/gui_layout_node.hpp"
2 #include "lxgui/gui_manager.hpp"
3 #include "lxgui/gui_out.hpp"
4 #include "lxgui/gui_scroll_frame.hpp"
5 
6 namespace lxgui::gui {
7 
11 }
12 
14  if (const layout_node* scroll_child_node = node.try_get_child("ScrollChild")) {
15  if (scroll_child_node->get_child_count() == 0) {
16  gui::out << gui::warning << scroll_child_node->get_location()
17  << ": ScrollChild node needs a child node." << std::endl;
18  return;
19  }
20 
21  if (scroll_child_node->get_child_count() > 1) {
22  gui::out << gui::warning << scroll_child_node->get_location()
23  << ": ScrollChild node needs only one child node; other nodes will be ignored."
24  << std::endl;
25  return;
26  }
27 
28  const layout_node& child_node = scroll_child_node->get_child(0);
29  auto scroll_child = parse_child_(child_node, "");
30  if (!scroll_child)
31  return;
32 
33  const layout_node* anchors = child_node.try_get_child("Anchors");
34  if (anchors) {
35  gui::out << gui::warning << anchors->get_location() << ": "
36  << "Scroll child's anchors are ignored." << std::endl;
37  }
38 
39  if (!child_node.has_child("Size")) {
40  gui::out << gui::warning << child_node.get_location()
41  << ": Scroll child needs its size to be defined in a Size block." << std::endl;
42  }
43 
44  this->set_scroll_child(remove_child(scroll_child));
45  }
46 }
47 
48 } // namespace lxgui::gui
virtual void parse_all_nodes_before_children_(const layout_node &node)
utils::owner_ptr< frame > remove_child(const utils::observer_ptr< frame > &child)
Removes a frame from this frame's children.
Definition: gui_frame.cpp:690
utils::observer_ptr< frame > parse_child_(const layout_node &node, const std::string &type)
std::string_view get_location() const noexcept
Returns this node's location in the file as {file}:{line}.
An node in a layout file.
const layout_node & get_child(std::size_t index) const noexcept
Returns a specific child of this node, by index.
const layout_node * try_get_child(std::string_view name) const noexcept
Returns the first child with a given name, or null if none.
bool has_child(std::string_view name) const noexcept
Checks if at least one child exists with the given name.
void set_scroll_child(utils::owner_ptr< frame > obj)
Sets this scroll_frame's scroll child.
virtual void parse_scroll_child_node_(const layout_node &node)
void parse_all_nodes_before_children_(const layout_node &node) override
std::ostream out
const std::string warning
Definition: gui_out.cpp:6