lxgui
Loading...
Searching...
No Matches
gui_scroll_frame.hpp
1#ifndef LXGUI_GUI_SCROLL_FRAME_HPP
2#define LXGUI_GUI_SCROLL_FRAME_HPP
3
4#include "lxgui/gui_frame.hpp"
5#include "lxgui/gui_frame_renderer.hpp"
6#include "lxgui/lxgui.hpp"
7#include "lxgui/utils.hpp"
8
9namespace lxgui::gui {
10
11class texture;
12
35class scroll_frame : public frame, public frame_renderer {
36public:
37 using base = frame;
38
40 explicit scroll_frame(
41 utils::control_block& block, manager& mgr, const frame_core_attributes& attr);
42
44 ~scroll_frame() override;
45
50 void copy_from(const region& obj) override;
51
57 bool can_use_script(const std::string& script_name) const override;
58
67 void
68 fire_script(const std::string& script_name, const event_data& data = event_data{}) override;
69
76
81 const utils::observer_ptr<frame>& get_scroll_child() {
82 return scroll_child_;
83 }
84
89 utils::observer_ptr<const frame> get_scroll_child() const {
90 return scroll_child_;
91 }
92
97 void set_horizontal_scroll(float horizontal_scroll);
98
103 float get_horizontal_scroll() const;
104
109 float get_horizontal_scroll_range() const;
110
115 void set_vertical_scroll(float vertical_scroll);
116
121 float get_vertical_scroll() const;
122
127 float get_vertical_scroll_range() const;
128
139 utils::observer_ptr<const frame>
140 find_topmost_frame(const std::function<bool(const frame&)>& predicate) const override;
141
143 void notify_strata_needs_redraw(strata strata_id) override;
144
149 vector2f get_target_dimensions() const override;
150
152 void notify_scaling_factor_updated() override;
153
155 static void register_on_lua(sol::state& lua);
156
157 static constexpr const char* class_name = "ScrollFrame";
158
159protected:
160 void parse_all_nodes_before_children_(const layout_node& node) override;
161 virtual void parse_scroll_child_node_(const layout_node& node);
162
163 void update_(float delta) override;
164
165 const std::vector<std::string>& get_type_list_() const override;
166
170
173
174 utils::observer_ptr<frame> scroll_child_ = nullptr;
176
178 std::shared_ptr<render_target> scroll_render_target_;
179
180 utils::observer_ptr<texture> scroll_texture_ = nullptr;
181};
182
183} // namespace lxgui::gui
184
185#endif
Stores a variable number of arguments for an event.
Abstract class for layering and rendering frames.
A region that can contain other regions and react to events.
An node in a layout file.
Manages the user interface.
The base class of all elements in the GUI.
A frame with scrollable content.
std::shared_ptr< render_target > scroll_render_target_
void set_scroll_child(utils::owner_ptr< frame > obj)
Sets this scroll_frame's scroll child.
float get_vertical_scroll_range() const
Returns the maximum vertical offset of the scroll child.
float get_horizontal_scroll_range() const
Returns the maximum horizontal offset of the scroll child.
utils::observer_ptr< const frame > get_scroll_child() const
Returns this scroll_frame's scroll child.
~scroll_frame() override
Destructor.
void set_vertical_scroll(float vertical_scroll)
Sets the vertical offset of the scroll child.
void notify_scaling_factor_updated() override
Tells this region that the global interface scaling factor has changed.
utils::observer_ptr< texture > scroll_texture_
utils::observer_ptr< frame > scroll_child_
virtual void parse_scroll_child_node_(const layout_node &node)
void copy_from(const region &obj) override
Copies a region's parameters into this scroll_frame (inheritance).
void update_(float delta) override
void fire_script(const std::string &script_name, const event_data &data=event_data{}) override
Calls a script.
static void register_on_lua(sol::state &lua)
Registers this region class to the provided Lua state.
utils::scoped_connection scroll_child_on_resize_connection_
static constexpr const char * class_name
const std::vector< std::string > & get_type_list_() const override
float get_horizontal_scroll() const
Returns the horizontal offset of the scroll child.
vector2f get_target_dimensions() const override
Returns the width and height of of this renderer's main render target (e.g., screen).
bool can_use_script(const std::string &script_name) const override
Returns 'true' if this scroll_frame can use a script.
utils::observer_ptr< const frame > find_topmost_frame(const std::function< bool(const frame &)> &predicate) const override
Find the topmost frame matching the provided predicate.
const utils::observer_ptr< frame > & get_scroll_child()
Returns this scroll_frame's scroll child.
float get_vertical_scroll() const
Returns the vertical offset of the scroll child.
void notify_strata_needs_redraw(strata strata_id) override
Tells this renderer that one of its region requires redraw.
void set_horizontal_scroll(float horizontal_scroll)
Sets the horizontal offset of the scroll child.
void parse_all_nodes_before_children_(const layout_node &node) override
A connection that automatically disconnects when going out of scope.
oup::observable_sealed_ptr< T > owner_ptr
Struct holding all the core information about a frame necessary for its creation.