pub struct UiLayer {
pub screen_width: f32,
pub screen_height: f32,
pub char_width: f32,
pub char_height: f32,
pub enabled: bool,
/* private fields */
}Expand description
The screen-space UI layer. Collects draw commands each frame, then renders them all in a single pass with an orthographic projection.
Fields§
§screen_width: f32Screen dimensions (updated on resize).
screen_height: f32§char_width: f32Character cell dimensions in screen pixels.
char_height: f32§enabled: boolWhether the UI layer is enabled.
Implementations§
Source§impl UiLayer
impl UiLayer
pub fn new(screen_width: f32, screen_height: f32) -> Self
Sourcepub fn set_char_size(&mut self, width: f32, height: f32)
pub fn set_char_size(&mut self, width: f32, height: f32)
Set the character cell size in screen pixels.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Clear all queued commands. Call at the start of each frame.
Sourcepub fn projection(&self) -> Mat4
pub fn projection(&self) -> Mat4
Get the orthographic projection matrix for this UI layer. Maps (0,0) at top-left to (screen_width, screen_height) at bottom-right.
Sourcepub fn draw_queue(&self) -> &[UiDrawCommand]
pub fn draw_queue(&self) -> &[UiDrawCommand]
Get the draw queue for rendering.
Sourcepub fn command_count(&self) -> usize
pub fn command_count(&self) -> usize
Number of pending draw commands.
Sourcepub fn draw_text(&mut self, x: f32, y: f32, text: &str, scale: f32, color: Vec4)
pub fn draw_text(&mut self, x: f32, y: f32, text: &str, scale: f32, color: Vec4)
Draw text at screen coordinates.
Sourcepub fn draw_text_glowing(
&mut self,
x: f32,
y: f32,
text: &str,
scale: f32,
color: Vec4,
emission: f32,
)
pub fn draw_text_glowing( &mut self, x: f32, y: f32, text: &str, scale: f32, color: Vec4, emission: f32, )
Draw text with emission (for bloom-capable UI text).
Sourcepub fn draw_text_aligned(
&mut self,
x: f32,
y: f32,
text: &str,
scale: f32,
color: Vec4,
align: TextAlign,
)
pub fn draw_text_aligned( &mut self, x: f32, y: f32, text: &str, scale: f32, color: Vec4, align: TextAlign, )
Draw text with alignment.
Sourcepub fn draw_centered_text(
&mut self,
y: f32,
text: &str,
scale: f32,
color: Vec4,
)
pub fn draw_centered_text( &mut self, y: f32, text: &str, scale: f32, color: Vec4, )
Draw centered text (centers horizontally at the given y).
Sourcepub fn draw_wrapped_text(
&mut self,
x: f32,
y: f32,
max_width: f32,
text: &str,
scale: f32,
color: Vec4,
)
pub fn draw_wrapped_text( &mut self, x: f32, y: f32, max_width: f32, text: &str, scale: f32, color: Vec4, )
Draw word-wrapped text within a max width (in pixels).
Sourcepub fn measure_text(&self, text: &str, scale: f32) -> (f32, f32)
pub fn measure_text(&self, text: &str, scale: f32) -> (f32, f32)
Measure text dimensions in screen pixels.
Sourcepub fn draw_rect(
&mut self,
x: f32,
y: f32,
w: f32,
h: f32,
color: Vec4,
filled: bool,
)
pub fn draw_rect( &mut self, x: f32, y: f32, w: f32, h: f32, color: Vec4, filled: bool, )
Draw a filled or outlined rectangle.
Sourcepub fn draw_panel(
&mut self,
x: f32,
y: f32,
w: f32,
h: f32,
border: BorderStyle,
fill_color: Vec4,
border_color: Vec4,
)
pub fn draw_panel( &mut self, x: f32, y: f32, w: f32, h: f32, border: BorderStyle, fill_color: Vec4, border_color: Vec4, )
Draw a panel with a border and optional fill.
Sourcepub fn draw_bar(
&mut self,
x: f32,
y: f32,
w: f32,
h: f32,
fill_pct: f32,
fill_color: Vec4,
bg_color: Vec4,
)
pub fn draw_bar( &mut self, x: f32, y: f32, w: f32, h: f32, fill_pct: f32, fill_color: Vec4, bg_color: Vec4, )
Draw a progress bar using █ and ░ characters.