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§
Required Methods§
sourcefn desired_colors(
&mut self,
context: &mut WidgetContext<'_>,
state: IndicatorState,
) -> Self::Colors
fn desired_colors( &mut self, context: &mut WidgetContext<'_>, state: IndicatorState, ) -> Self::Colors
Returns the colors desired for the current state of the indicator.
sourcefn will_be_empty_if_activated(&self) -> bool
fn will_be_empty_if_activated(&self) -> bool
Returns true if the indicator will display empty if the indicator is activated.
sourcefn render(
&mut self,
is_active: bool,
colors: &Self::Colors,
selected_color: Color,
region: Rect<Px>,
context: &mut GraphicsContext<'_, '_, '_, '_>,
)
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 insidecontext
is the context to draw to.
sourcefn size(&self, context: &mut GraphicsContext<'_, '_, '_, '_>) -> Size<UPx>
fn size(&self, context: &mut GraphicsContext<'_, '_, '_, '_>) -> Size<UPx>
Returns the size of this indicator.