Choice

Struct Choice 

Source
pub struct Choice<'a, T = usize>
where T: PartialEq + Clone + Default,
{ /* private fields */ }
Expand description

Choice.

Select one of a list. No editable mode for this widget.

This doesn’t render itself. into_widgets creates the base part and the popup part, which are rendered separately.

Implementations§

Source§

impl<'a> Choice<'a, usize>

Source

pub fn auto_items<V: Into<Line<'a>>>( self, items: impl IntoIterator<Item = V>, ) -> Self

Add items with auto-generated values.

Source

pub fn auto_item(self, item: impl Into<Line<'a>>) -> Self

Add an item with an auto generated value.

Source§

impl<'a, T> Choice<'a, T>
where T: PartialEq + Clone + Default,

Source

pub fn new() -> Self

Source

pub fn unknown_item(self, unknown: impl Into<Line<'a>>) -> Self

Source

pub fn items<V: Into<Line<'a>>>( self, items: impl IntoIterator<Item = (T, V)>, ) -> Self

Button text.

Source

pub fn item(self, value: T, item: impl Into<Line<'a>>) -> Self

Add an item.

Source

pub fn default_value(self, default: T) -> Self

Can return to default with user interaction.

Source

pub fn styles(self, styles: ChoiceStyle) -> Self

Combined styles.

Source

pub fn style(self, style: Style) -> Self

Base style.

Source

pub fn button_style(self, style: Style) -> Self

Style for the down button.

Source

pub fn select_style(self, style: Style) -> Self

Selection in the list.

Source

pub fn select_marker(self, marker: char) -> Self

Selection in the list.

Source

pub fn focus_style(self, style: Style) -> Self

Focused style.

Source

pub fn block(self, block: Block<'a>) -> Self

Block for the main widget.

Source

pub fn skip_item_render(self, skip: bool) -> Self

Skips rendering the selected item. This is a flag for Combobox, that wants to do its own rendering instead.

Source

pub fn popup_alignment(self, alignment: Alignment) -> Self

Alignment of the popup.

Default Default is Left.

Source

pub fn popup_placement(self, placement: Placement) -> Self

Placement of the popup.

Default Default is BelowOrAbove.

Source

pub fn popup_boundary(self, boundary: Rect) -> Self

Outer boundary for the popup.

Source

pub fn popup_len(self, len: u16) -> Self

Override the popup length.

Default Defaults to the number of items or 5.

Source

pub fn popup_style(self, style: Style) -> Self

Base style for the popup.

Source

pub fn popup_block(self, block: Block<'a>) -> Self

Block for the popup.

Source

pub fn popup_scroll(self, scroll: Scroll<'a>) -> Self

Scroll for the popup.

Source

pub fn popup_offset(self, offset: (i16, i16)) -> Self

Adds an extra offset to the widget area.

This can be used to

  • place the widget under the mouse cursor.
  • align the widget not by the outer bounds but by the text content.
Source

pub fn popup_x_offset(self, offset: i16) -> Self

Sets only the x offset. See offset

Source

pub fn popup_y_offset(self, offset: i16) -> Self

Sets only the y offset. See offset

Source

pub fn behave_focus(self, focus: ChoiceFocus) -> Self

Sets the behaviour for selecting from the list.

Source

pub fn behave_select(self, select: ChoiceSelect) -> Self

Sets the behaviour for selecting from the list.

Source

pub fn behave_close(self, close: ChoiceClose) -> Self

Sets the behaviour for closing the list.

Source

pub fn width(&self) -> u16

Inherent width.

Source

pub fn height(&self) -> u16

Inherent height.

Source

pub fn into_widgets(self) -> (ChoiceWidget<'a, T>, ChoicePopup<'a, T>)

Choice itself doesn’t render.

This builds the widgets from the parameters set for Choice.

Trait Implementations§

Source§

impl<'a, T> Clone for Choice<'a, T>
where T: PartialEq + Clone + Default + Clone,

Source§

fn clone(&self) -> Choice<'a, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T> Debug for Choice<'a, T>
where T: PartialEq + Clone + Default + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Choice<'_, T>
where T: PartialEq + Clone + Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, T = usize> !Freeze for Choice<'a, T>

§

impl<'a, T = usize> !RefUnwindSafe for Choice<'a, T>

§

impl<'a, T = usize> !Send for Choice<'a, T>

§

impl<'a, T = usize> !Sync for Choice<'a, T>

§

impl<'a, T> Unpin for Choice<'a, T>
where T: Unpin,

§

impl<'a, T = usize> !UnwindSafe for Choice<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.