pub struct Toggler<'a, Message, Renderer>{ /* private fields */ }Expand description
A toggler widget.
§Example
pub enum Message {
TogglerToggled(bool),
}
let is_toggled = true;
Toggler::new(String::from("Toggle me!"), is_toggled, |b| Message::TogglerToggled(b));Implementations§
Source§impl<'a, Message, Renderer> Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> Toggler<'a, Message, Renderer>
Sourcepub const DEFAULT_SIZE: f32 = 20f32
pub const DEFAULT_SIZE: f32 = 20f32
The default size of a Toggler.
Sourcepub fn text_alignment(self, alignment: Horizontal) -> Self
pub fn text_alignment(self, alignment: Horizontal) -> Self
Sets the horizontal alignment of the text of the Toggler
Sourcepub fn spacing(self, spacing: impl Into<Pixels>) -> Self
pub fn spacing(self, spacing: impl Into<Pixels>) -> Self
Sets the spacing between the Toggler and the text.
Sourcepub fn style(
self,
style: impl Into<<Renderer::Theme as StyleSheet>::Style>,
) -> Self
pub fn style( self, style: impl Into<<Renderer::Theme as StyleSheet>::Style>, ) -> Self
Sets the style of the Toggler.
Sourcepub fn percent(self, percent: f32) -> Self
pub fn percent(self, percent: f32) -> Self
The percent completion of the toggler animation. This is indented to automated cosmic-time use, and shouldn’t need to be called manually.
Sourcepub fn anim_multiplier(self, multiplier: f32) -> Self
pub fn anim_multiplier(self, multiplier: f32) -> Self
The default animation time is 100ms, to speed up the toggle animation use a value less than 1.0, and to slow down the animation use a value greater than 1.0.
Trait Implementations§
Source§impl<'a, Message, Renderer> From<Toggler<'a, Message, Renderer>> for Element<'a, Message, Renderer>
impl<'a, Message, Renderer> From<Toggler<'a, Message, Renderer>> for Element<'a, Message, Renderer>
Source§impl<'a, Message, Renderer> Widget<Message, Renderer> for Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> Widget<Message, Renderer> for Toggler<'a, Message, Renderer>
Source§fn on_event(
&mut self,
_state: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
) -> Status
fn on_event( &mut self, _state: &mut Tree, event: Event, layout: Layout<'_>, cursor_position: Point, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, ) -> Status
Source§fn mouse_interaction(
&self,
_state: &Tree,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle,
_renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, _state: &Tree, layout: Layout<'_>, cursor_position: Point, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction
Source§fn draw(
&self,
_state: &Tree,
renderer: &mut Renderer,
theme: &Renderer::Theme,
style: &Style,
layout: Layout<'_>,
cursor_position: Point,
_viewport: &Rectangle,
)
fn draw( &self, _state: &Tree, renderer: &mut Renderer, theme: &Renderer::Theme, style: &Style, layout: Layout<'_>, cursor_position: Point, _viewport: &Rectangle, )
Draws the
Widget using the associated Renderer.Auto Trait Implementations§
impl<'a, Message, Renderer> Freeze for Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> !RefUnwindSafe for Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> !Send for Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> !Sync for Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> Unpin for Toggler<'a, Message, Renderer>
impl<'a, Message, Renderer> !UnwindSafe for Toggler<'a, Message, Renderer>
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Convert into T with values clamped to the color defined bounds Read more
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an
OutOfBounds error is returned which contains
the unclamped color. Read more