Expand description
§Per-state appearance
A StateStyle is a set of optional look overrides (background, foreground, border color,
border width, font). An Appearance holds one StateStyle for each visual state a Widget
can be in. Widgets read the effective style for their current VisualState with
Widget::style, so applications can say “this button turns blue
on hover” without any widget code.
state change ──> effective style = appearance[state] ⟶ falls back to appearance.normal ⟶ built-in default
│
└─> repaint only if the effective style changed§Examples
use pushrod::appearance::{Appearance, StateStyle};
use pushrod::color::Color;
use pushrod::widget::VisualState;
let mut appearance = Appearance::default();
appearance.set(
VisualState::HOVERED,
StateStyle {
background: Some(Color::BLUE),
..StateStyle::default()
},
);
assert_eq!(appearance.effective(VisualState::HOVERED).background, Some(Color::BLUE));
assert_eq!(appearance.effective(VisualState::empty()).background, None);Structs§
- Appearance
- One
StateStylefor each visual state of aWidget. - State
Style - Look overrides for one visual state. A field left
Noneis not overridden: it falls back to thenormalstyle, and then to theWidget’s built-in default.