Expand description
Status mapping code generation for widget state styling
This module generates Rust code that maps Iced widget-specific status enums to Dampen’s unified WidgetState enum. This enables state-aware styling in codegen mode (matching the behavior of interpreted mode).
§Architecture
The generated code mirrors the runtime status mapping logic from
dampen-iced::style_mapping, but produces compile-time Rust code instead
of runtime function calls.
§Example Generated Code
For a button with hover styling:
let style = move |_theme: &Theme, status: iced::widget::button::Status| {
use iced::widget::button::Status;
let widget_state = match status {
Status::Active => None,
Status::Hovered => Some(dampen_core::ir::WidgetState::Hover),
Status::Pressed => Some(dampen_core::ir::WidgetState::Active),
Status::Disabled => Some(dampen_core::ir::WidgetState::Disabled),
};
if let Some(state) = widget_state {
// Apply state-specific styling
} else {
// Apply base styling
}
};
button.style(style)Functions§
- generate_
status_ mapping - Generate status mapping code for a specific widget kind