Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::ui_system Class Reference

System responsible for managing user interface components and rendering. More...

#include <ui_system.h>

Classes

struct  ui_pointer_dispatch_result
 

Public Member Functions

auto init (rtti::context &ctx) -> bool
 Initializes the UI system with the given context.
 
auto deinit (rtti::context &ctx) -> bool
 Deinitializes the UI system with the given context.
 
void update_world_space (rtti::context &ctx, entt::handle camera_entity, scene &scn, bool &process_input)
 Update world-space UI documents (common + world-space specific). Call before render_world_space.
 
void render_world_space (rtti::context &ctx, entt::handle camera_entity, scene &scn, delta_t dt)
 Render world-space UI documents (sort + frame-state render). Call after update_world_space.
 
void update_screen_space (rtti::context &ctx, entt::handle camera_entity, scene &scn, bool &process_input)
 Update screen-space UI documents (common + screen-space specific). Call before render_screen_space.
 
void render_screen_space (rtti::context &ctx, const gfx::frame_buffer::ptr &output, entt::handle camera_entity, scene &scn, delta_t dt)
 Render screen-space overlay UI documents to output. Call after update_screen_space.
 
void on_os_event (rtti::context &ctx, os::event &event)
 Handle OS events and forward to RmlUi.
 
void load_fonts ()
 Load fonts.
 
void release_resources ()
 
void register_component_callbacks (rtti::context &ctx)
 Register component creation/destruction callbacks with ECS.
 
auto is_debugger_enabled () const -> bool
 
void set_debugger_enabled (bool enabled)
 
void update_ui_documents (rtti::context &ctx, scene &scn)
 Update UI documents (load, reload, visibility). No camera dependency.
 
void update_world_space_document (rtti::context &ctx, scene &scn, entt::handle handle, ui_document_component &comp, const camera &cam, float dp_ratio, bool process_input, bool &hit_found)
 Update a single world-space document (dimensions, density, input). Call from render path, back-to-front.
 
void update_screen_space_document (rtti::context &ctx, Rml::Context *context, int viewport_width, int viewport_height, float dp_ratio, scene &scn, bool process_input, bool &hit_found)
 Update a single screen-space document (dimensions, density, input). Call from render path.
 
void update_ui_document_common (entt::handle handle, ui_document_component &ui_comp, bool is_playing)
 
auto load_ui_document (entt::handle entity, ui_document_component &component, bool log_error=true) -> bool
 Load a UI document for a specific component.
 
auto is_not_root_element (scene &scn, Rml::Element *element) -> bool
 
auto find_keyboard_context (scene &scn) const -> Rml::Context *
 
auto try_consume_keyboard_event (scene &scn, os::event &event) -> bool
 
auto dispatch_pointer_event (rtti::context &ctx, scene &scn, os::event &event) -> ui_pointer_dispatch_result
 
void apply_mouse_press_focus (scene &scn, os::event &event, Rml::Context *target_context, bool input_allowed)
 
void blur_ui_context (Rml::Context *context) const
 
void refresh_mouse_state (rtti::context &ctx, scene &scn)
 
auto process_mouse_move (scene &scn, Rml::Context *context, int x, int y) -> bool
 
auto process_event (scene &scn, Rml::Context *context, os::event &event) -> bool
 
void load_font (const std::string &path)
 
void ensure_document_framebuffer (ui_document_component &comp)
 Ensure framebuffer exists for document; create or resize if needed.
 

Static Public Member Functions

static void on_create_component (entt::registry &r, entt::entity e)
 
static void on_load_component (entt::registry &r, entt::entity e)
 
static void on_destroy_component (entt::registry &r, entt::entity e)
 

Detailed Description

System responsible for managing user interface components and rendering.

This system integrates RmlUi for HTML/CSS-based user interfaces with the engine's rendering and input systems. It provides a high-level API for loading and managing UI documents.

Definition at line 38 of file ui_system.h.

Member Function Documentation

◆ apply_mouse_press_focus()

void unravel::ui_system::apply_mouse_press_focus ( scene & scn,
os::event & event,
Rml::Context * target_context,
bool input_allowed )

Definition at line 182 of file ui_system_input.cpp.

◆ blur_ui_context()

void unravel::ui_system::blur_ui_context ( Rml::Context * context) const

Definition at line 296 of file ui_system_input.cpp.

◆ deinit()

auto unravel::ui_system::deinit ( rtti::context & ctx) -> bool

Deinitializes the UI system with the given context.

Parameters
ctxThe context to deinitialize.
Returns
True if deinitialization was successful, false otherwise.

Definition at line 123 of file ui_system.cpp.

◆ dispatch_pointer_event()

auto unravel::ui_system::dispatch_pointer_event ( rtti::context & ctx,
scene & scn,
os::event & event ) -> ui_pointer_dispatch_result

Definition at line 149 of file ui_system_input.cpp.

◆ ensure_document_framebuffer()

void unravel::ui_system::ensure_document_framebuffer ( ui_document_component & comp)

Ensure framebuffer exists for document; create or resize if needed.

Definition at line 694 of file ui_system.cpp.

◆ find_keyboard_context()

auto unravel::ui_system::find_keyboard_context ( scene & scn) const -> Rml::Context*

Definition at line 116 of file ui_system_input.cpp.

◆ init()

auto unravel::ui_system::init ( rtti::context & ctx) -> bool

Initializes the UI system with the given context.

Parameters
ctxThe context to initialize with.
Returns
True if initialization was successful, false otherwise.

Definition at line 68 of file ui_system.cpp.

◆ is_debugger_enabled()

auto unravel::ui_system::is_debugger_enabled ( ) const -> bool

Definition at line 573 of file ui_system.cpp.

◆ is_not_root_element()

auto unravel::ui_system::is_not_root_element ( scene & scn,
Rml::Element * element ) -> bool

Definition at line 226 of file ui_system_input.cpp.

◆ load_font()

void unravel::ui_system::load_font ( const std::string & path)

Definition at line 502 of file ui_system.cpp.

◆ load_fonts()

void unravel::ui_system::load_fonts ( )

Load fonts.

Definition at line 509 of file ui_system.cpp.

◆ load_ui_document()

auto unravel::ui_system::load_ui_document ( entt::handle entity,
ui_document_component & component,
bool log_error = true ) -> bool

Load a UI document for a specific component.

Parameters
entityEntity owning the component
componentThe ui_document_component to load the document for
Returns
True if loading was successful, false otherwise

Definition at line 632 of file ui_system.cpp.

◆ on_create_component()

void unravel::ui_system::on_create_component ( entt::registry & r,
entt::entity e )
static

Definition at line 521 of file ui_system.cpp.

◆ on_destroy_component()

void unravel::ui_system::on_destroy_component ( entt::registry & r,
entt::entity e )
static

Definition at line 539 of file ui_system.cpp.

◆ on_load_component()

void unravel::ui_system::on_load_component ( entt::registry & r,
entt::entity e )
static

Definition at line 527 of file ui_system.cpp.

◆ on_os_event()

void unravel::ui_system::on_os_event ( rtti::context & ctx,
os::event & event )

Handle OS events and forward to RmlUi.

Parameters
ctxEngine context
eventOS event to process

Definition at line 96 of file ui_system_input.cpp.

◆ process_event()

auto unravel::ui_system::process_event ( scene & scn,
Rml::Context * context,
os::event & event ) -> bool

Definition at line 268 of file ui_system_input.cpp.

◆ process_mouse_move()

auto unravel::ui_system::process_mouse_move ( scene & scn,
Rml::Context * context,
int x,
int y ) -> bool

Definition at line 249 of file ui_system_input.cpp.

◆ refresh_mouse_state()

void unravel::ui_system::refresh_mouse_state ( rtti::context & ctx,
scene & scn )

Definition at line 312 of file ui_system_input.cpp.

◆ register_component_callbacks()

void unravel::ui_system::register_component_callbacks ( rtti::context & ctx)

Register component creation/destruction callbacks with ECS.

Parameters
ctxEngine context

Definition at line 557 of file ui_system.cpp.

◆ release_resources()

void unravel::ui_system::release_resources ( )

Definition at line 565 of file ui_system.cpp.

◆ render_screen_space()

void unravel::ui_system::render_screen_space ( rtti::context & ctx,
const gfx::frame_buffer::ptr & output,
entt::handle camera_entity,
scene & scn,
delta_t dt )

Render screen-space overlay UI documents to output. Call after update_screen_space.

Definition at line 443 of file ui_system.cpp.

◆ render_world_space()

void unravel::ui_system::render_world_space ( rtti::context & ctx,
entt::handle camera_entity,
scene & scn,
delta_t dt )

Render world-space UI documents (sort + frame-state render). Call after update_world_space.

Definition at line 330 of file ui_system.cpp.

◆ set_debugger_enabled()

void unravel::ui_system::set_debugger_enabled ( bool enabled)

Definition at line 577 of file ui_system.cpp.

◆ try_consume_keyboard_event()

auto unravel::ui_system::try_consume_keyboard_event ( scene & scn,
os::event & event ) -> bool

Definition at line 135 of file ui_system_input.cpp.

◆ update_screen_space()

void unravel::ui_system::update_screen_space ( rtti::context & ctx,
entt::handle camera_entity,
scene & scn,
bool & process_input )

Update screen-space UI documents (common + screen-space specific). Call before render_screen_space.

Definition at line 382 of file ui_system.cpp.

◆ update_screen_space_document()

void unravel::ui_system::update_screen_space_document ( rtti::context & ctx,
Rml::Context * context,
int viewport_width,
int viewport_height,
float dp_ratio,
scene & scn,
bool process_input,
bool & hit_found )

Update a single screen-space document (dimensions, density, input). Call from render path.

Parameters
ctxEngine context for input
compUI document component
viewport_widthViewport width
viewport_heightViewport height
dp_ratioDensity-independent pixel ratio
scnScene for process_mouse_move
hit_foundIn/out: true if a previous doc already consumed the mouse

Definition at line 240 of file ui_system.cpp.

◆ update_ui_document_common()

void unravel::ui_system::update_ui_document_common ( entt::handle handle,
ui_document_component & ui_comp,
bool is_playing )

Definition at line 159 of file ui_system.cpp.

◆ update_ui_documents()

void unravel::ui_system::update_ui_documents ( rtti::context & ctx,
scene & scn )

Update UI documents (load, reload, visibility). No camera dependency.

Parameters
ctxEngine context
scnScene containing UI documents

Definition at line 582 of file ui_system.cpp.

◆ update_world_space()

void unravel::ui_system::update_world_space ( rtti::context & ctx,
entt::handle camera_entity,
scene & scn,
bool & process_input )

Update world-space UI documents (common + world-space specific). Call before render_world_space.

State between update_world_space and render_world_space

Definition at line 263 of file ui_system.cpp.

◆ update_world_space_document()

void unravel::ui_system::update_world_space_document ( rtti::context & ctx,
scene & scn,
entt::handle handle,
ui_document_component & comp,
const camera & cam,
float dp_ratio,
bool process_input,
bool & hit_found )

Update a single world-space document (dimensions, density, input). Call from render path, back-to-front.

Parameters
ctxEngine context for input
scnScene for process_mouse_move
handleEntity handle with ui_document_component and transform_component
compUI document component
camCamera for projection
dp_ratioDensity-independent pixel ratio
hit_foundIn/out: true if a closer doc already consumed the mouse

Definition at line 202 of file ui_system.cpp.


The documentation for this class was generated from the following files: