pub struct Radio<'a, Message, Theme = Theme, Renderer = Renderer<Renderer, Renderer>>{ /* private fields */ }
Expand description
A circular button representing a choice.
§Example
use iced::widget::{column, radio};
struct State {
selection: Option<Choice>,
}
#[derive(Debug, Clone, Copy)]
enum Message {
RadioSelected(Choice),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Choice {
A,
B,
C,
All,
}
fn view(state: &State) -> Element<'_, Message> {
let a = radio(
"A",
Choice::A,
state.selection,
Message::RadioSelected,
);
let b = radio(
"B",
Choice::B,
state.selection,
Message::RadioSelected,
);
let c = radio(
"C",
Choice::C,
state.selection,
Message::RadioSelected,
);
let all = radio(
"All of the above",
Choice::All,
state.selection,
Message::RadioSelected
);
column![a, b, c, all].into()
}
Implementations§
Source§impl<'a, Message, Theme, Renderer> Radio<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> Radio<'a, Message, Theme, Renderer>
Sourcepub const DEFAULT_SIZE: f32 = 16f32
pub const DEFAULT_SIZE: f32 = 16f32
The default size of a Radio
button.
Sourcepub const DEFAULT_SPACING: f32 = 8f32
pub const DEFAULT_SPACING: f32 = 8f32
The default spacing of a Radio
button.
Sourcepub fn new<F, V>(
label: impl Into<String>,
value: V,
selected: Option<V>,
f: F,
) -> Radio<'a, Message, Theme, Renderer>
pub fn new<F, V>( label: impl Into<String>, value: V, selected: Option<V>, f: F, ) -> Radio<'a, Message, Theme, Renderer>
Sourcepub fn size(
self,
size: impl Into<Pixels>,
) -> Radio<'a, Message, Theme, Renderer>
pub fn size( self, size: impl Into<Pixels>, ) -> Radio<'a, Message, Theme, Renderer>
Sets the size of the Radio
button.
Sourcepub fn width(
self,
width: impl Into<Length>,
) -> Radio<'a, Message, Theme, Renderer>
pub fn width( self, width: impl Into<Length>, ) -> Radio<'a, Message, Theme, Renderer>
Sets the width of the Radio
button.
Sourcepub fn spacing(
self,
spacing: impl Into<Pixels>,
) -> Radio<'a, Message, Theme, Renderer>
pub fn spacing( self, spacing: impl Into<Pixels>, ) -> Radio<'a, Message, Theme, Renderer>
Sets the spacing between the Radio
button and the text.
Sourcepub fn text_size(
self,
text_size: impl Into<Pixels>,
) -> Radio<'a, Message, Theme, Renderer>
pub fn text_size( self, text_size: impl Into<Pixels>, ) -> Radio<'a, Message, Theme, Renderer>
Sets the text size of the Radio
button.
Sourcepub fn text_line_height(
self,
line_height: impl Into<LineHeight>,
) -> Radio<'a, Message, Theme, Renderer>
pub fn text_line_height( self, line_height: impl Into<LineHeight>, ) -> Radio<'a, Message, Theme, Renderer>
Sets the text text::LineHeight
of the Radio
button.
Sourcepub fn text_shaping(
self,
shaping: Shaping,
) -> Radio<'a, Message, Theme, Renderer>
pub fn text_shaping( self, shaping: Shaping, ) -> Radio<'a, Message, Theme, Renderer>
Sets the text::Shaping
strategy of the Radio
button.
Sourcepub fn text_wrapping(
self,
wrapping: Wrapping,
) -> Radio<'a, Message, Theme, Renderer>
pub fn text_wrapping( self, wrapping: Wrapping, ) -> Radio<'a, Message, Theme, Renderer>
Sets the text::Wrapping
strategy of the Radio
button.
Sourcepub fn font(
self,
font: impl Into<<Renderer as Renderer>::Font>,
) -> Radio<'a, Message, Theme, Renderer>
pub fn font( self, font: impl Into<<Renderer as Renderer>::Font>, ) -> Radio<'a, Message, Theme, Renderer>
Sets the text font of the Radio
button.
Trait Implementations§
Source§impl<'a, Message, Theme, Renderer> From<Radio<'a, Message, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> From<Radio<'a, Message, Theme, Renderer>> for Element<'a, Message, Theme, Renderer>
Source§impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Radio<'_, Message, Theme, Renderer>
impl<Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Radio<'_, Message, Theme, Renderer>
Source§fn update(
&mut self,
_state: &mut Tree,
event: &Event,
layout: Layout<'_>,
cursor: Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
_viewport: &Rectangle,
)
fn update( &mut self, _state: &mut Tree, event: &Event, layout: Layout<'_>, cursor: Cursor, _renderer: &Renderer, _clipboard: &mut dyn Clipboard, shell: &mut Shell<'_, Message>, _viewport: &Rectangle, )
Source§fn mouse_interaction(
&self,
_state: &Tree,
layout: Layout<'_>,
cursor: Cursor,
_viewport: &Rectangle,
_renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, _state: &Tree, layout: Layout<'_>, cursor: Cursor, _viewport: &Rectangle, _renderer: &Renderer, ) -> Interaction
Source§fn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &Theme,
defaults: &Style,
layout: Layout<'_>,
_cursor: Cursor,
viewport: &Rectangle,
)
fn draw( &self, tree: &Tree, renderer: &mut Renderer, theme: &Theme, defaults: &Style, layout: Layout<'_>, _cursor: Cursor, viewport: &Rectangle, )
Draws the
Widget
using the associated Renderer
.Auto Trait Implementations§
impl<'a, Message, Theme, Renderer> Freeze for Radio<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> RefUnwindSafe for Radio<'a, Message, Theme, Renderer>where
Message: RefUnwindSafe,
<Theme as Catalog>::Class<'a>: RefUnwindSafe,
<Renderer as Renderer>::Font: RefUnwindSafe,
impl<'a, Message, Theme, Renderer> Send for Radio<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> Sync for Radio<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> Unpin for Radio<'a, Message, Theme, Renderer>
impl<'a, Message, Theme, Renderer> UnwindSafe for Radio<'a, Message, Theme, Renderer>where
Message: UnwindSafe,
<Theme as Catalog>::Class<'a>: UnwindSafe,
<Renderer as Renderer>::Font: UnwindSafe,
Blanket Implementations§
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Turns some type into the initial state of some
Application
.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 more