Skip to main content

Module appearance

Module appearance 

Source
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 StateStyle for each visual state of a Widget.
StateStyle
Look overrides for one visual state. A field left None is not overridden: it falls back to the normal style, and then to the Widget’s built-in default.