Module: ui.widgets.panel
Source: ./ui/widgets/panel.reef
Overview
ui/widgets/panel.reef - Container widget with background Part of reef-stdlib UI module
The Panel widget is a container that provides a background, border, and optional padding for its child content. It's used to group related UI elements visually.
Panels support:
- Background colors (solid or from theme)
- Borders with configurable width and radius
- Padding around content
- Shadow effects (visual depth)
Types
PanelStyle (enum)
Variants:
FlatRaisedSunkenOutlinedCard
Objects
Panel
Extends: widget.Widget
Fields:
| Name | Type |
|---|---|
style |
PanelStyle |
padding_top |
float |
padding_right |
float |
padding_bottom |
float |
padding_left |
float |
custom_background |
core.Color |
use_custom_background |
bool |
border_width |
float |
border_radius |
float |
kids |
[widget.Widget] |
proc init(id: widget.WidgetId)
Methods:
override shared fn kind(): string
exclusive proc add(child: widget.Widget)
override exclusive proc paint(surf: surface.Surface, th: theme.Theme)
exclusive proc set_style(style: PanelStyle)
exclusive proc set_padding(padding: float)
exclusive proc set_padding_each(top: float, right: float, bottom: float, left: float)
exclusive proc set_background(color: core.Color)
exclusive proc set_border_width(width: float)
exclusive proc set_border_radius(radius: float)
shared fn clone(): Panel
D2 (docs/design/2026-09-08-ui-modernization.md): a SHALLOW copy. Setters
mutate the receiver (reef-lang#62), so "give me a variant and leave the
original alone" has to be asked for explicitly. Referenced objects are
shared, not deep-copied.
The kids array is copied element-wise: append allocates a fresh array,
but an element store through the clone would otherwise reach the
original's array. The child widgets are shared references, deliberately.
shared fn preferred_size(content_size: core.Size): core.Size
exclusive proc layout(constraints: layout.Constraints)
override exclusive fn handle_event(e: event.Event): widget.EventResult
Functions
fn panel_style_flat(): PanelStyle
fn panel_style_raised(): PanelStyle
fn panel_style_sunken(): PanelStyle
fn panel_style_outlined(): PanelStyle
fn panel_style_card(): PanelStyle
fn is_panel_flat(s: PanelStyle): bool
fn is_panel_raised(s: PanelStyle): bool
fn is_panel_sunken(s: PanelStyle): bool
fn is_panel_outlined(s: PanelStyle): bool
fn is_panel_card(s: PanelStyle): bool
fn panel(): Panel
fn panel_with_style(style: PanelStyle): Panel
fn panel_with_padding(padding: float): Panel
fn panel_child_count(p: Panel): int
fn panel_padding(p: Panel): float
fn panel_content_bounds(p: Panel): core.Rect
fn get_panel_background(p: Panel, colors: theme.ThemeColors): core.Color
fn get_panel_border_color(p: Panel, colors: theme.ThemeColors): core.Color
Procedures
proc panel_add(p: Panel, child: widget.Widget)
proc draw_shadow(surf: surface.Surface, x: float, y: float, w: float, h: float, offset: float)
proc draw_raised_border(surf: surface.Surface, x: float, y: float, w: float, h: float, colors: theme.ThemeColors)
proc draw_sunken_border(surf: surface.Surface, x: float, y: float, w: float, h: float, colors: theme.ThemeColors)
proc draw_rect_border(surf: surface.Surface, x: float, y: float, w: float, h: float, color: core.Color, width: float)
Generated by reefc doc