Skip to main content

impl_state_builders

Macro impl_state_builders 

Source
macro_rules! impl_state_builders {
    ($widget:ty) => { ... };
}
Expand description

Generate builder methods for widgets with state: WidgetState field.

This macro generates the following methods:

  • focused(self, bool) -> Self - Set focused state
  • disabled(self, bool) -> Self - Set disabled state
  • fg(self, Color) -> Self - Set foreground color
  • bg(self, Color) -> Self - Set background color
  • is_focused(&self) -> bool - Check if focused
  • is_disabled(&self) -> bool - Check if disabled
  • set_focused(&mut self, bool) - Mutably set focused state

§Example

struct MyWidget {
    state: WidgetState,
    props: WidgetProps,
}

impl_state_builders!(MyWidget);