[][src]Struct coffee::ui::widget::radio::Radio

pub struct Radio<Message> { /* fields omitted */ }

A circular button representing a choice.

It implements Widget when the core::Renderer implements the radio::Renderer trait.

Example

use coffee::graphics::Color;
use coffee::ui::{Column, Radio};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Choice {
    A,
    B,
}

#[derive(Debug, Clone, Copy)]
pub enum Message {
    RadioSelected(Choice),
}

let selected_choice = Some(Choice::A);

Column::new()
    .spacing(20)
    .push(
        Radio::new(Choice::A, "This is A", selected_choice, Message::RadioSelected)
            .label_color(Color::BLACK),
    )
    .push(
        Radio::new(Choice::B, "This is B", selected_choice, Message::RadioSelected)
            .label_color(Color::BLACK),
    );

Checkbox drawn by the built-in renderer

Implementations

impl<Message> Radio<Message>[src]

pub fn new<F, V>(value: V, label: &str, selected: Option<V>, f: F) -> Self where
    V: Eq + Copy,
    F: 'static + Fn(V) -> Message, 
[src]

Creates a new Radio button.

It expects:

  • the value related to the Radio button
  • the label of the Radio button
  • the current selected value
  • a function that will be called when the Radio is selected. It receives the value of the radio and must produce a Message.

pub fn label_color(self, color: Color) -> Self[src]

Sets the Color of the label of the Radio.

Trait Implementations

impl<Message> Debug for Radio<Message> where
    Message: Debug
[src]

impl<'a, Message, Renderer> From<Radio<Message>> for Element<'a, Message, Renderer> where
    Renderer: Renderer + Renderer,
    Message: 'static + Copy + Debug
[src]

impl<Message, Renderer> Widget<Message, Renderer> for Radio<Message> where
    Renderer: Renderer + Renderer,
    Message: Copy + Debug
[src]

Auto Trait Implementations

impl<Message> RefUnwindSafe for Radio<Message> where
    Message: RefUnwindSafe

impl<Message> Send for Radio<Message> where
    Message: Send

impl<Message> Sync for Radio<Message> where
    Message: Sync

impl<Message> Unpin for Radio<Message> where
    Message: Unpin

impl<Message> UnwindSafe for Radio<Message> where
    Message: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SetParameter for T

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,