Trait cushy::widgets::indicator::IndicatorBehavior

source ·
pub trait IndicatorBehavior:
    Send
    + Debug
    + 'static {
    type Colors: LinearInterpolate + PartialEq + Debug + Send + Sync + Copy + 'static;

    // Required methods
    fn desired_colors(
        &mut self,
        context: &mut WidgetContext<'_>,
        state: IndicatorState,
    ) -> Self::Colors;
    fn activate(&mut self);
    fn will_be_empty_if_activated(&self) -> bool;
    fn empty(&self) -> bool;
    fn render(
        &mut self,
        is_active: bool,
        colors: &Self::Colors,
        selected_color: Color,
        region: Rect<Px>,
        context: &mut GraphicsContext<'_, '_, '_, '_>,
    );
    fn size(&self, context: &mut GraphicsContext<'_, '_, '_, '_>) -> Size<UPx>;
}
Expand description

A type that defines how an Indicator behaves and is drawn.

Required Associated Types§

source

type Colors: LinearInterpolate + PartialEq + Debug + Send + Sync + Copy + 'static

The type that contains all the colors needed to draw this indicator.

These colors are transitioned using animations depending on how the user is interacting with the indicator.

Required Methods§

source

fn desired_colors( &mut self, context: &mut WidgetContext<'_>, state: IndicatorState, ) -> Self::Colors

Returns the colors desired for the current state of the indicator.

source

fn activate(&mut self)

Updates the indicator’s state from the indicator being activated.

source

fn will_be_empty_if_activated(&self) -> bool

Returns true if the indicator will display empty if the indicator is activated.

source

fn empty(&self) -> bool

Returns true if the indicator is not currently filled in.

source

fn render( &mut self, is_active: bool, colors: &Self::Colors, selected_color: Color, region: Rect<Px>, context: &mut GraphicsContext<'_, '_, '_, '_>, )

Render the indicator in region given the current state and colors.

  • is_active is true if the widget is currently being activated by the user.
  • colors is the currently interpolated colors to draw.
  • selected_color is the color that a selected indicator should be drawn using.
  • region is the region the indicator should be drawn inside
  • context is the context to draw to.
source

fn size(&self, context: &mut GraphicsContext<'_, '_, '_, '_>) -> Size<UPx>

Returns the size of this indicator.

Implementors§