pub struct RadioState<T = usize>{
pub area: Rect,
pub inner: Rect,
pub marker_area: Rect,
pub continue_area: Rect,
pub check_areas: Vec<Rect>,
pub text_areas: Vec<Rect>,
pub core: ChoiceCore<T>,
pub focus: FocusFlag,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
Widget state.
Fields§
§area: RectComplete area read only. renewed for each render.
inner: RectArea inside the block. read only. renewed for each render.
marker_area: RectArea for the focus marker. read only. renewed for each render.
continue_area: RectArea for a continue marker. This is displayed if not all items can be displayed.
check_areas: Vec<Rect>read only. renewed for each render. Area of the check marks. read only. renewed for each render.
text_areas: Vec<Rect>Area for the texts. read only. renewed for each render.
core: ChoiceCore<T>Core
focus: FocusFlagCurrent focus state. read+write
mouse: MouseFlagsMouse helper read+write
non_exhaustive: NonExhaustiveImplementations§
Source§impl<T> RadioState<T>
impl<T> RadioState<T>
pub fn new() -> Self
pub fn named(name: &str) -> Self
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn set_default_value(&mut self, default_value: Option<T>)
pub fn set_default_value(&mut self, default_value: Option<T>)
Set a default-value other than T::default()
The starting value will still be T::default() after this. You must call clear() to use this default.
This default will be overridden by a default set on the widget.
Sourcepub fn default_value(&self) -> &Option<T>
pub fn default_value(&self) -> &Option<T>
A default value.
Sourcepub fn set_value(&mut self, value: T) -> bool
pub fn set_value(&mut self, value: T) -> bool
Set the given value.
If the value doesn’t exist in the list or the list is empty the value will still be set, but selected will be None. The list will be empty before the first render, but the first thing render will do is set the list of values. This will adjust the selected index if possible. It’s still ok to set a value here that can not be represented. As long as there is no user interaction, the same value will be returned by value().
Sourcepub fn value(&self) -> T
pub fn value(&self) -> T
Get the selected value or None if no value is selected or there are no options.
Sourcepub fn selected(&self) -> Option<usize>
pub fn selected(&self) -> Option<usize>
Returns the selected index or None if the value is not in the list or the list is empty.
You can still get the value set with set_value() though.
Sourcepub fn select(&mut self, select: usize) -> bool
pub fn select(&mut self, select: usize) -> bool
Select the value at index. This will set the value to the given index in the value-list. If the index is out of bounds or the value-list is empty it will set selected to None and leave the value as is. The list is empty before the first render so this may not work as expected.
The selected index is a best effort artefact, the main thing is the value itself.
Use of set_value() is preferred.
Trait Implementations§
Source§impl<T> Clone for RadioState<T>
impl<T> Clone for RadioState<T>
Source§impl<T> Debug for RadioState<T>
impl<T> Debug for RadioState<T>
Source§impl<T> Default for RadioState<T>
impl<T> Default for RadioState<T>
Source§impl<T> HandleEvent<Event, MouseOnly, RadioOutcome> for RadioState<T>
impl<T> HandleEvent<Event, MouseOnly, RadioOutcome> for RadioState<T>
Source§impl<T> HandleEvent<Event, Regular, RadioOutcome> for RadioState<T>
impl<T> HandleEvent<Event, Regular, RadioOutcome> for RadioState<T>
Source§impl<T> HasFocus for RadioState<T>
impl<T> HasFocus for RadioState<T>
Source§fn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Source§fn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Source§fn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Source§fn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Auto Trait Implementations§
impl<T = usize> !Freeze for RadioState<T>
impl<T = usize> !RefUnwindSafe for RadioState<T>
impl<T = usize> !Send for RadioState<T>
impl<T = usize> !Sync for RadioState<T>
impl<T> Unpin for RadioState<T>where
T: Unpin,
impl<T = usize> !UnwindSafe for RadioState<T>
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.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
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
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>
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>
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> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
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>>
OutOfBounds error is returned which contains
the unclamped color. Read more