forked from reya/gpui-native-kit
feat: support app-defined icon sets
This commit is contained in:
+13
-10
@@ -15,7 +15,7 @@ use gpui_native_core::common::{h_flex, v_flex};
|
||||
use gpui_native_core::context_menu::ContextMenu;
|
||||
use gpui_native_core::menu::MenuItem;
|
||||
use gpui_native_data::tabs::{Tab, Tabs, TabsVariant};
|
||||
use gpui_native_icons::IconRole;
|
||||
use gpui_native_icons::{Icon, IconRole};
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
|
||||
use crate::resize_handle::ResizeHandle;
|
||||
@@ -35,7 +35,7 @@ type OpenRightSidebarHandler = Rc<dyn Fn(&mut App)>;
|
||||
pub struct PanelDescriptor {
|
||||
id: SharedString,
|
||||
title: SharedString,
|
||||
icon: Option<IconRole>,
|
||||
icon: Option<Icon>,
|
||||
build: PanelBuilder,
|
||||
right_sidebar: Option<PanelBuilder>,
|
||||
}
|
||||
@@ -58,8 +58,11 @@ impl PanelDescriptor {
|
||||
}
|
||||
|
||||
/// Shows an icon leading the tab label.
|
||||
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
|
||||
}
|
||||
|
||||
@@ -130,7 +133,7 @@ impl Render for DragPreview {
|
||||
struct PanelTab {
|
||||
panel: SharedString,
|
||||
title: SharedString,
|
||||
icon: Option<IconRole>,
|
||||
icon: Option<Icon>,
|
||||
view: AnyView,
|
||||
right_view: Option<AnyView>,
|
||||
}
|
||||
@@ -215,7 +218,7 @@ impl DockState {
|
||||
let tab = PanelTab {
|
||||
panel: SharedString::from(id),
|
||||
title: panel.title.clone(),
|
||||
icon: panel.icon,
|
||||
icon: panel.icon.clone(),
|
||||
view: (panel.build)(window, cx),
|
||||
right_view,
|
||||
};
|
||||
@@ -679,7 +682,7 @@ impl DockState {
|
||||
.map(|tab| TabView {
|
||||
panel: tab.panel.clone(),
|
||||
title: tab.title.clone(),
|
||||
icon: tab.icon,
|
||||
icon: tab.icon.clone(),
|
||||
view: tab.view.clone(),
|
||||
})
|
||||
.collect(),
|
||||
@@ -747,7 +750,7 @@ fn take_node(node: &mut Node) -> Node {
|
||||
struct TabView {
|
||||
panel: SharedString,
|
||||
title: SharedString,
|
||||
icon: Option<IconRole>,
|
||||
icon: Option<Icon>,
|
||||
view: AnyView,
|
||||
}
|
||||
|
||||
@@ -1039,8 +1042,8 @@ fn render_pane(
|
||||
tabs.iter()
|
||||
.map(|tab| {
|
||||
let mut entry = Tab::new(tab.panel.clone(), tab.title.clone());
|
||||
if let Some(role) = tab.icon {
|
||||
entry = entry.icon(role);
|
||||
if let Some(icon) = tab.icon.clone() {
|
||||
entry = entry.icon(icon);
|
||||
}
|
||||
entry.closeable(true).wrap({
|
||||
let panel = tab.panel.clone();
|
||||
|
||||
Reference in New Issue
Block a user