pub struct ChoiceState<T = usize>{Show 14 fields
pub area: Rect,
pub nav_char: Vec<Vec<char>>,
pub item_area: Rect,
pub button_area: Rect,
pub item_areas: Vec<Rect>,
pub core: ChoiceCore<T>,
pub popup: PopupCoreState,
pub popup_scroll: ScrollState,
pub behave_focus: Rc<Cell<ChoiceFocus>>,
pub behave_select: ChoiceSelect,
pub behave_close: ChoiceClose,
pub focus: FocusFlag,
pub mouse: MouseFlags,
pub non_exhaustive: NonExhaustive,
}Expand description
State.
Fields§
§area: RectTotal area. read only. renewed with each render.
First char of each item for navigation. read only. renewed with each render.
item_area: RectItem area in the main widget. read only. renewed with each render.
Button area in the main widget. read only. renewed with each render.
item_areas: Vec<Rect>Visible items in the popup. read only. renewed with each render.
core: ChoiceCore<T>Core
popup: PopupCoreStatePopup state.
popup_scroll: ScrollStatePopup scroll state.
behave_focus: Rc<Cell<ChoiceFocus>>Behaviour for opening the choice popup.
behave_select: ChoiceSelectBehaviour for selecting from the choice popup. read only renewed with each render.
behave_close: ChoiceCloseBehaviour for closing the choice popup. read only renewed with each render.
focus: FocusFlagFocus flag. read+write
mouse: MouseFlagsMouse util.
non_exhaustive: NonExhaustiveImplementations§
Source§impl<T> ChoiceState<T>
impl<T> ChoiceState<T>
pub fn new() -> Self
pub fn named(name: &str) -> Self
Sourcepub fn is_popup_active(&self) -> bool
pub fn is_popup_active(&self) -> bool
Popup is active?
Sourcepub fn flip_popup_active(&mut self)
pub fn flip_popup_active(&mut self)
Flip the popup state.
Sourcepub fn set_popup_active(&mut self, active: bool) -> bool
pub fn set_popup_active(&mut self, active: bool) -> bool
Show the popup.
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
Select 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 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.
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 clear_offset(&mut self)
pub fn clear_offset(&mut self)
Scroll offset for the item list.
Sourcepub fn set_offset(&mut self, offset: usize) -> bool
pub fn set_offset(&mut self, offset: usize) -> bool
Scroll offset for the item list.
Sourcepub fn max_offset(&self) -> usize
pub fn max_offset(&self) -> usize
Scroll offset for the item list.
Sourcepub fn scroll_to_selected(&mut self) -> bool
pub fn scroll_to_selected(&mut self) -> bool
Scroll the item list to the selected value.
Source§impl<T> ChoiceState<T>
impl<T> ChoiceState<T>
Sourcepub fn select_by_char(&mut self, c: char) -> bool
pub fn select_by_char(&mut self, c: char) -> bool
Select by first character.
Sourcepub fn reverse_select_by_char(&mut self, c: char) -> bool
pub fn reverse_select_by_char(&mut self, c: char) -> bool
Select by first character. Reverse direction
Sourcepub fn move_to(&mut self, n: usize) -> ChoiceOutcome
pub fn move_to(&mut self, n: usize) -> ChoiceOutcome
Select at position
Sourcepub fn move_down(&mut self, n: usize) -> ChoiceOutcome
pub fn move_down(&mut self, n: usize) -> ChoiceOutcome
Select next entry.
Sourcepub fn move_up(&mut self, n: usize) -> ChoiceOutcome
pub fn move_up(&mut self, n: usize) -> ChoiceOutcome
Select prev entry.
Trait Implementations§
Source§impl<T> Clone for ChoiceState<T>
impl<T> Clone for ChoiceState<T>
Source§impl<T> Debug for ChoiceState<T>
impl<T> Debug for ChoiceState<T>
Source§impl<T> Default for ChoiceState<T>
impl<T> Default for ChoiceState<T>
Source§impl<T: PartialEq + Clone + Default> HandleEvent<Event, MouseOnly, ChoiceOutcome> for ChoiceState<T>
impl<T: PartialEq + Clone + Default> HandleEvent<Event, MouseOnly, ChoiceOutcome> for ChoiceState<T>
Source§impl<T: PartialEq + Clone + Default> HandleEvent<Event, Popup, ChoiceOutcome> for ChoiceState<T>
impl<T: PartialEq + Clone + Default> HandleEvent<Event, Popup, ChoiceOutcome> for ChoiceState<T>
Source§impl<T> HasFocus for ChoiceState<T>
impl<T> HasFocus for ChoiceState<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 ChoiceState<T>
impl<T = usize> !RefUnwindSafe for ChoiceState<T>
impl<T = usize> !Send for ChoiceState<T>
impl<T = usize> !Sync for ChoiceState<T>
impl<T> Unpin for ChoiceState<T>where
T: Unpin,
impl<T = usize> !UnwindSafe for ChoiceState<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