Skip to content

[Feature] Label widget #151

@vmarcella

Description

@vmarcella

Overview

Add a label widget for displaying static or dynamic text in the UI.

Current State

No response

Scope

Goals:

  • Display text string
  • Configurable text alignment
  • Dynamic text updates
  • Optional text wrapping

Non-Goals:

  • Rich text
  • Editable text

Proposed API

pub struct Label {
  text: String,
  font_size: f32,
  color: [f32; 4],
  align: TextAlign,
  wrap: bool,
}

impl Label {
  pub fn new(text: &str) -> Self;
  pub fn with_size(self, size: f32) -> Self;
  pub fn with_color(self, color: [f32; 4]) -> Self;
  pub fn with_align(self, align: TextAlign) -> Self;
  pub fn with_wrap(self, wrap: bool) -> Self;
  pub fn set_text(&mut self, text: &str);
  pub fn text(&self) -> &str;
}

impl Widget for Label {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
  // Labels don't need complex hit testing
}

Acceptance Criteria

  • Label displays text
  • Font size configurable
  • Text color configurable
  • Alignment options work
  • Text updates reflect immediately

Affected Crates

lambda-rs

Notes

  • Consider caching text layout for performance
  • May need to relayout when bounds change

Metadata

Metadata

Assignees

No one assigned

    Labels

    UIAll things user interface relatedenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions