Skip to content

[Feature] Panel/container widget #152

@vmarcella

Description

@vmarcella

Overview

Add a panel widget that provides a visual container for grouping other widgets
with optional background and border.

Current State

No response

Scope

Goals:

  • Container for child widgets
  • Optional background color
  • Optional border
  • Corner radius option

Non-Goals:

  • Complex borders
  • Shadows
  • Scrolling

Proposed API

pub struct Panel {
  children: Vec<Box<dyn Widget>>,
  background: Option<[f32; 4]>,
  border_color: Option<[f32; 4]>,
  border_width: f32,
  corner_radius: f32,
}

impl Panel {
  pub fn new() -> Self;
  pub fn with_background(self, color: [f32; 4]) -> Self;
  pub fn with_border(self, color: [f32; 4], width: f32) -> Self;
  pub fn with_corner_radius(self, radius: f32) -> Self;
  pub fn add_child(&mut self, widget: impl Widget + 'static);
}

impl Widget for Panel {
  fn render(&self, ctx: &mut UiRenderContext) -> Vec<RenderCommand>;
  fn hit_test(&self, x: f32, y: f32) -> bool;
}

Acceptance Criteria

  • Panel renders background color
  • Border renders with specified width/color
  • Corner radius rounds corners
  • Children render within panel bounds
  • Hit test considers panel bounds

Affected Crates

lambda-rs

Notes

  • Rounded rectangles need custom shader or geometry
  • Consider 9-slice for complex backgrounds

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