#[must_use]
pub struct Combobox {
pub(crate) items: Vec<String>,
pub(crate) placeholder: String,
pub(crate) width: Option<f32>,
}
impl Combobox {
pub fn new(items: Vec<String>) -> Self {
Self {
items,
placeholder: "Select...".to_owned(),
width: None,
}
}
pub fn placeholder(mut self, text: impl Into<String>) -> Self {
self.placeholder = text.into();
self
}
pub fn width(mut self, width: f32) -> Self {
self.width = Some(width);
self
}
}
#[must_use]
pub struct ComboboxValue<'a, T: Clone + PartialEq> {
pub(crate) entries: &'a [(T, String)],
pub(crate) placeholder: String,
pub(crate) width: Option<f32>,
}
impl<'a, T: Clone + PartialEq> ComboboxValue<'a, T> {
pub fn new(entries: &'a [(T, String)]) -> Self {
Self {
entries,
placeholder: "Select...".to_owned(),
width: None,
}
}
pub fn placeholder(mut self, text: impl Into<String>) -> Self {
self.placeholder = text.into();
self
}
pub fn width(mut self, width: f32) -> Self {
self.width = Some(width);
self
}
}