Struct ChipEditBuilder

Source
pub struct ChipEditBuilder { /* private fields */ }
Expand description

A builder for creating a ChipEdit widget with various customization options.

§Examples

use egui::Color32;
use egui_chip::ChipEditBuilder;

let chip_edit = ChipEditBuilder::new(",")
    .unwrap()
    .texts(vec!["Chip1", "Chip2", "Chip3"])
    .chip_colors(Color32::from_rgb(255, 0, 0), Color32::from_rgb(0, 255, 0))
    .widget_colors(Color32::from_rgb(0, 0, 255), Color32::from_rgb(255, 255, 0))
    .frame(true)
    .chip_size(Some([100.0, 50.0]))
    .build();

Implementations§

Source§

impl ChipEditBuilder

Source

pub fn new(separator: &str) -> Result<Self, String>

Creates a new ChipEditBuilder with the specified separator.

§Arguments
  • separator - The separator string used to split chip texts.
§Errors

Returns an error if the separator is empty.

Source

pub fn texts(self, texts: impl IntoIterator<Item = impl ToString>) -> Self

Sets the initial texts for the chips.

§Arguments
  • texts - An iterator of strings representing the initial texts for the chips.
Source

pub fn chip_colors(self, bg_color: Color32, text_color: Color32) -> Self

Sets the background and text colors for the chips within ChipEdit.

§Arguments
  • bg_color - The background color for the chips.
  • text_color - The text color for the chips.
Source

pub fn widget_colors(self, bg_color: Color32, fg_color: Color32) -> Self

Sets the background and foreground colors for the widget.

§Arguments
  • bg_color - The background color for the widget.
  • fg_color - The foreground color for the widget.
Source

pub fn frame(self, frame: bool) -> Self

Sets whether the widget should have a frame.

§Arguments
  • frame - A boolean indicating whether the widget should have a frame.
Source

pub fn chip_size(self, chip_size: Option<[f32; 2]>) -> Self

Sets the size of the chips.

§Arguments
  • chip_size - An optional array representing the width and height of the chips.
Source

pub fn chip_icon(self, icon: Option<RichText>) -> Result<Self, String>

Sets leading icon for the chips

§Arguments
  • char - A single char text
Source

pub fn build(self) -> ChipEdit

Builds the ChipEdit widget.

§Returns

The constructed ChipEdit widget.

Auto Trait Implementations§

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> 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, 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.