feat!(widget): rewrite button & icon widget APIs

This commit is contained in:
Michael Aaron Murphy 2023-09-01 07:29:19 +02:00 committed by Michael Murphy
parent 18debe546d
commit 4e4eeaac12
60 changed files with 2191 additions and 1113 deletions

View file

@ -3,10 +3,9 @@
use std::borrow::Cow;
use iced::Color;
use slotmap::{SecondaryMap, SparseSecondaryMap};
use crate::widget::IconSource;
use crate::widget::Icon;
use super::{Entity, Model, Selectable};
@ -90,18 +89,11 @@ where
/// model.insert().text("Item A").icon(IconSource::from("icon-a"));
/// ```
#[allow(clippy::must_use_candidate, clippy::return_self_not_must_use)]
pub fn icon(self, icon: impl Into<IconSource<'static>>) -> Self {
pub fn icon(self, icon: Icon) -> Self {
self.model.icon_set(self.id, icon);
self
}
/// Define the color for the icon.
#[allow(clippy::must_use_candidate, clippy::return_self_not_must_use)]
pub fn icon_color(self, icon: Option<Color>) -> Self {
self.model.icon_color_set(self.id, icon);
self
}
/// Returns the ID of the item that was inserted.
///
/// ```ignore