feat: support app-defined icon sets
This commit is contained in:
@@ -5,7 +5,7 @@ use gpui::{
|
||||
App, ElementId, InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Role,
|
||||
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window,
|
||||
};
|
||||
use gpui_native_icons::{IconRole, icon};
|
||||
use gpui_native_icons::{Icon, IconRole, icon};
|
||||
use gpui_native_theme::{ActiveTheme as _, BORDER_WIDTH, Size};
|
||||
use gpui_native_utils::focus_ring;
|
||||
|
||||
@@ -20,7 +20,7 @@ pub type SelectHandler<T> = Rc<dyn Fn(Option<T>, &mut Window, &mut App)>;
|
||||
pub struct SelectOption<T> {
|
||||
value: T,
|
||||
label: SharedString,
|
||||
icon: Option<IconRole>,
|
||||
icon: Option<Icon>,
|
||||
}
|
||||
|
||||
impl<T> SelectOption<T> {
|
||||
@@ -37,8 +37,11 @@ impl<T> SelectOption<T> {
|
||||
}
|
||||
|
||||
/// Sets a leading icon for the option's row.
|
||||
pub fn icon(mut self, role: IconRole) -> Self {
|
||||
self.icon = Some(role);
|
||||
pub fn icon<I>(mut self, icon: I) -> Self
|
||||
where
|
||||
I: Into<Icon>,
|
||||
{
|
||||
self.icon = Some(icon.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
@@ -272,8 +275,8 @@ where
|
||||
};
|
||||
|
||||
let mut row = MenuItem::new(option.label.clone());
|
||||
if let Some(role) = option.icon {
|
||||
row = row.icon(role);
|
||||
if let Some(icon) = option.icon.clone() {
|
||||
row = row.icon(icon);
|
||||
}
|
||||
row.checked(is_selected).handler(handler)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user