1 #ifndef LXGUI_GUI_ROOT_HPP
2 #define LXGUI_GUI_ROOT_HPP
4 #include "lxgui/gui_anchor.hpp"
5 #include "lxgui/gui_frame_container.hpp"
6 #include "lxgui/gui_frame_renderer.hpp"
7 #include "lxgui/gui_key_binder.hpp"
8 #include "lxgui/gui_registry.hpp"
9 #include "lxgui/gui_vector2.hpp"
10 #include "lxgui/input_signals.hpp"
11 #include "lxgui/lxgui.hpp"
12 #include "lxgui/utils_observer.hpp"
13 #include "lxgui/utils_signal.hpp"
20 class world_dispatcher;
46 explicit root(utils::control_block& block,
manager& mgr);
106 return hovered_frame_;
114 return hovered_frame_;
122 return hovered_frame_.get() == &obj;
130 return dragged_frame_;
138 return dragged_frame_;
146 return dragged_frame_.get() == &obj;
159 utils::observer_ptr<region> obj,
162 std::function<
void()> apply_constraint_func =
nullptr);
262 return object_registry_;
270 return object_registry_;
290 void create_caching_render_target_();
291 void create_strata_cache_render_target_(
strata_data& strata_obj);
293 void clear_hovered_frame_();
294 void update_hovered_frame_();
298 void on_window_resized_(
const vector2ui& dimensions);
304 bool on_key_state_changed_(
input::key key,
bool is_down,
bool is_repeat);
305 bool on_mouse_button_state_changed_(
308 bool is_double_click,
321 bool caching_enabled_ =
false;
323 std::shared_ptr<render_target> target_;
327 std::vector<utils::scoped_connection> connections_;
330 utils::observer_ptr<frame> hovered_frame_ =
nullptr;
331 utils::observer_ptr<frame> dragged_frame_ =
nullptr;
332 utils::observer_ptr<frame> start_click_frame_ =
nullptr;
334 utils::observer_ptr<region> moved_object_ =
nullptr;
335 utils::observer_ptr<region> sized_object_ =
nullptr;
338 anchor* moved_anchor_ =
nullptr;
341 std::function<void()> apply_constraint_func_;
344 bool is_resizing_width_ =
false;
345 bool is_resizing_height_ =
false;
346 bool is_resizing_from_right_ =
false;
347 bool is_resizing_from_bottom_ =
false;
350 std::vector<utils::observer_ptr<frame>> focus_stack_;
Stores a position for a UI region.
Abstract class for layering and rendering frames.
A region that can contain other regions and react to events.
Binds global actions to key presses.
Manages the user interface.
The base class of all elements in the GUI.
Keeps track of created UI objects and records their names for lookup.
Abstract type for implementation specific management.
Root of the UI object hierarchy.
const utils::observer_ptr< frame > & get_hovered_frame()
Returns the currently hovered frame, if any.
void render() const
Renders the UI into the current render target.
root(utils::control_block &block, manager &mgr)
Constructor.
void notify_scaling_factor_updated()
Tells this object that the global interface scaling factor has changed.
root & operator=(root &&)=delete
bool is_moving(const region &obj) const
Checks if the given object is allowed to move.
const key_binder & get_key_binder() const
Returns the key_binder object, which enables binding global actions to key presses.
root(const root &)=delete
void start_moving(utils::observer_ptr< region > obj, anchor *a=nullptr, constraint constraint=constraint::none, std::function< void()> apply_constraint_func=nullptr)
Start manually moving a region with the mouse.
bool is_hovered(const frame &obj) const
Check if a given frame is being hovered.
void stop_sizing()
Stops sizing for the current object.
const utils::observer_ptr< frame > & get_dragged_frame()
Returns the currently dragged frame, if any.
void request_focus(utils::observer_ptr< frame > receiver)
Sets whether keyboard input should be focused.
root & operator=(const root &)=delete
vector2f get_target_dimensions() const override
Returns the width and height of this renderer's main render target (e.g., screen).
void toggle_caching()
Toggles interface caching.
key_binder & get_key_binder()
Returns the key_binder object, which enables binding global actions to key presses.
bool is_dragged(const frame &obj) const
Check if a given frame is being dragged.
void notify_hovered_frame_dirty()
Notifies the root that it should update the hovered frame.
bool is_caching_enabled() const
Checks if interface caching is enabled.
const manager & get_manager() const
Returns the manager instance associated with this root.
utils::observer_ptr< frame > get_focused_frame()
Returns the currently focused frame (nullptr if none).
void clear_focus()
Release all requested focus.
bool is_sizing(const region &obj) const
Checks if the given object is allowed to be resized.
bool is_focused() const
Checks whether keyboard input is focused somewhere, to prevent multiple inputs.
const registry & get_registry() const
Returns the UI object registry, which keeps track of all objects in the UI.
utils::observer_ptr< const frame > get_hovered_frame() const
Returns the currently hovered frame, if any.
utils::observer_ptr< const frame > get_dragged_frame() const
Returns the currently dragged frame, if any.
void update(float delta)
updates this root and its regions.
registry & get_registry()
Returns the UI object registry, which keeps track of all objects in the UI.
void start_sizing(utils::observer_ptr< region > obj, point p)
Starts manually resizing a region with the mouse.
void stop_moving()
Stops movement for the current object.
void release_focus(const frame &receiver)
Give up focus of keyboard input.
utils::observer_ptr< const frame > get_focused_frame() const
Returns the currently focused frame (nullptr if none).
~root() override
Destructor.
manager & get_manager()
Returns the manager instance associated with this root.
void enable_caching(bool enable)
Enables or disables interface caching.
oup::enable_observer_from_this_sealed< T > enable_observer_from_this
Simple structure holding four vertices and a material.
Contains frames sorted by level.
static const vector2 zero
Data for on_text_entered signal.