Skip to main content

UiLayoutView

Trait UiLayoutView 

Source
pub trait UiLayoutView {
    // Required methods
    fn get_all_ui_entities(&self) -> Vec<EntityId>;
    fn get_node(&self, entity: EntityId) -> Option<UiNode>;
    fn get_children(&self, entity: EntityId) -> Vec<EntityId>;
    fn has_parent(&self, entity: EntityId) -> bool;
    fn set_transform(&mut self, entity: EntityId, transform: UiTransform);

    // Provided method
    fn viewport_size(&self) -> (u32, u32) { ... }
}
Expand description

A trait providing a read/write view of UI data for layout computation.

This allows layout systems (in khora-infra) to operate on UI data without depending on the specific ECS implementation (in khora-data).

Required Methods§

Source

fn get_all_ui_entities(&self) -> Vec<EntityId>

Returns the IDs of all entities that should be considered for layout.

Source

fn get_node(&self, entity: EntityId) -> Option<UiNode>

Returns the UI node definition for a given entity.

Source

fn get_children(&self, entity: EntityId) -> Vec<EntityId>

Returns the children of a given entity.

Source

fn has_parent(&self, entity: EntityId) -> bool

Returns true if the entity has a parent.

Source

fn set_transform(&mut self, entity: EntityId, transform: UiTransform)

Writes the computed transform back to the entity.

Provided Methods§

Source

fn viewport_size(&self) -> (u32, u32)

The available layout viewport in physical pixels (width, height).

Layout systems use this as the root AvailableSpace so percentage and flex sizing resolve against the real surface rather than a fixed assumption. The default returns (1920, 1080) for views that do not track a surface size; implementors backed by a live surface should override it (e.g. the ECS World exposing the current surface size).

Implementors§