layout: replace panel icon with lead element and optional title
This commit is contained in:
+32
-26
@@ -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::{Icon, IconRole};
|
||||
use gpui_native_icons::IconRole;
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
|
||||
use crate::resize_handle::ResizeHandle;
|
||||
@@ -36,35 +36,44 @@ type OpenRightSidebarHandler = Rc<dyn Fn(&mut App)>;
|
||||
#[must_use]
|
||||
pub struct PanelDescriptor {
|
||||
id: SharedString,
|
||||
title: SharedString,
|
||||
icon: Option<Icon>,
|
||||
title: Option<SharedString>,
|
||||
lead: Option<Rc<dyn Fn() -> AnyElement>>,
|
||||
build: PanelBuilder,
|
||||
right_sidebar: Option<PanelBuilder>,
|
||||
}
|
||||
|
||||
impl PanelDescriptor {
|
||||
/// Creates a panel descriptor that opens through `build`.
|
||||
pub fn new<I, T, F>(id: I, title: T, build: F) -> Self
|
||||
pub fn new<I, F>(id: I, build: F) -> Self
|
||||
where
|
||||
I: Into<SharedString>,
|
||||
T: Into<SharedString>,
|
||||
F: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
||||
{
|
||||
Self {
|
||||
id: id.into(),
|
||||
title: title.into(),
|
||||
icon: None,
|
||||
title: None,
|
||||
lead: None,
|
||||
build: Box::new(build),
|
||||
right_sidebar: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows an icon leading the tab label.
|
||||
pub fn icon<I>(mut self, icon: I) -> Self
|
||||
/// Shows `title` as the panel's tab label.
|
||||
pub fn title<T>(mut self, title: T) -> Self
|
||||
where
|
||||
I: Into<Icon>,
|
||||
T: Into<SharedString>,
|
||||
{
|
||||
self.icon = Some(icon.into());
|
||||
self.title = Some(title.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Shows an element, e.g. an icon or avatar, leading the tab label.
|
||||
pub fn lead<F, E>(mut self, build: F) -> Self
|
||||
where
|
||||
F: Fn() -> E + 'static,
|
||||
E: IntoElement,
|
||||
{
|
||||
self.lead = Some(Rc::new(move || build().into_any_element()));
|
||||
self
|
||||
}
|
||||
|
||||
@@ -111,7 +120,7 @@ pub struct PanelDrag {
|
||||
|
||||
/// The card that follows the cursor while a tab is dragged.
|
||||
struct DragPreview {
|
||||
title: SharedString,
|
||||
title: Option<SharedString>,
|
||||
}
|
||||
|
||||
impl Render for DragPreview {
|
||||
@@ -127,15 +136,15 @@ impl Render for DragPreview {
|
||||
.text_size(theme.sizes.medium.text_size)
|
||||
.text_color(theme.colors.foreground)
|
||||
.opacity(0.85)
|
||||
.child(self.title.clone())
|
||||
.children(self.title.clone())
|
||||
}
|
||||
}
|
||||
|
||||
/// One open panel view.
|
||||
struct PanelTab {
|
||||
panel: SharedString,
|
||||
title: SharedString,
|
||||
icon: Option<Icon>,
|
||||
title: Option<SharedString>,
|
||||
lead: Option<Rc<dyn Fn() -> AnyElement>>,
|
||||
view: AnyView,
|
||||
right_view: Option<AnyView>,
|
||||
}
|
||||
@@ -220,7 +229,7 @@ impl DockState {
|
||||
let tab = PanelTab {
|
||||
panel: SharedString::from(id),
|
||||
title: panel.title.clone(),
|
||||
icon: panel.icon.clone(),
|
||||
lead: panel.lead.clone(),
|
||||
view: (panel.build)(window, cx),
|
||||
right_view,
|
||||
};
|
||||
@@ -684,7 +693,7 @@ impl DockState {
|
||||
.map(|tab| TabView {
|
||||
panel: tab.panel.clone(),
|
||||
title: tab.title.clone(),
|
||||
icon: tab.icon.clone(),
|
||||
lead: tab.lead.clone(),
|
||||
view: tab.view.clone(),
|
||||
})
|
||||
.collect(),
|
||||
@@ -745,8 +754,8 @@ impl DockState {
|
||||
#[derive(Clone)]
|
||||
struct TabView {
|
||||
panel: SharedString,
|
||||
title: SharedString,
|
||||
icon: Option<Icon>,
|
||||
title: Option<SharedString>,
|
||||
lead: Option<Rc<dyn Fn() -> AnyElement>>,
|
||||
view: AnyView,
|
||||
}
|
||||
|
||||
@@ -1047,15 +1056,12 @@ fn render_pane(
|
||||
.selected(selected)
|
||||
.tabs({
|
||||
let tabs = pane.tabs.clone();
|
||||
move |_, cx| {
|
||||
let theme = cx.theme();
|
||||
let metrics = theme.sizes.resolve(Size::default());
|
||||
|
||||
move |_, _| {
|
||||
tabs.iter()
|
||||
.map(|tab| {
|
||||
Tab::new(tab.panel.clone(), tab.title.clone())
|
||||
.when_some(tab.icon.clone(), |entry, icon| {
|
||||
entry.lead(icon.size(metrics.icon_size))
|
||||
Tab::new(tab.panel.clone(), tab.title.clone().unwrap_or_default())
|
||||
.when_some(tab.lead.as_ref().map(|build| build()), |entry, lead| {
|
||||
entry.lead(lead)
|
||||
})
|
||||
.closeable(true)
|
||||
.wrap({
|
||||
|
||||
@@ -36,11 +36,12 @@ impl Render for SidePanel {
|
||||
}
|
||||
|
||||
fn descriptor(tag: &'static str) -> PanelDescriptor {
|
||||
PanelDescriptor::new(tag, tag, move |_, cx| cx.new(|_| Panel { tag }).into())
|
||||
PanelDescriptor::new(tag, move |_, cx| cx.new(|_| Panel { tag }).into()).title(tag)
|
||||
}
|
||||
|
||||
fn descriptor_with_right_sidebar(tag: &'static str) -> PanelDescriptor {
|
||||
PanelDescriptor::new(tag, tag, move |_, cx| cx.new(|_| Panel { tag }).into())
|
||||
PanelDescriptor::new(tag, move |_, cx| cx.new(|_| Panel { tag }).into())
|
||||
.title(tag)
|
||||
.right_sidebar(move |_, cx| cx.new(|_| SidePanel { tag }).into())
|
||||
}
|
||||
|
||||
|
||||
@@ -392,15 +392,15 @@ mod tabbar_toggles {
|
||||
let dock = cx.update(|cx| {
|
||||
let dock = DockState::new(cx);
|
||||
dock.update(cx, |dock, _| {
|
||||
dock.register_panel(PanelDescriptor::new("one", "One", |_, cx| {
|
||||
cx.new(|_| DockPanel).into()
|
||||
}));
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("one", |_, cx| cx.new(|_| DockPanel).into()).title("One"),
|
||||
);
|
||||
for index in 0..14 {
|
||||
let tag = format!("panel-{index}");
|
||||
let id = tag.clone();
|
||||
dock.register_panel(PanelDescriptor::new(id, tag, |_, cx| {
|
||||
cx.new(|_| DockPanel).into()
|
||||
}));
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new(id, |_, cx| cx.new(|_| DockPanel).into()).title(tag),
|
||||
);
|
||||
}
|
||||
});
|
||||
dock
|
||||
|
||||
@@ -22,7 +22,7 @@ impl Render for Panel {
|
||||
}
|
||||
|
||||
fn descriptor(tag: &'static str) -> PanelDescriptor {
|
||||
PanelDescriptor::new(tag, tag, move |_, cx| cx.new(|_| Panel { tag }).into())
|
||||
PanelDescriptor::new(tag, move |_, cx| cx.new(|_| Panel { tag }).into()).title(tag)
|
||||
}
|
||||
|
||||
struct Harness {
|
||||
|
||||
+240
-179
@@ -407,7 +407,7 @@ impl Gallery {
|
||||
let dock_state = cx.entity();
|
||||
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("welcome", "Welcome", {
|
||||
PanelDescriptor::new("welcome", {
|
||||
let layout_state = layout_state.clone();
|
||||
let dock_state = dock_state.clone();
|
||||
let gallery = gallery.clone();
|
||||
@@ -420,6 +420,7 @@ impl Gallery {
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.title("Welcome")
|
||||
.right_sidebar(|_, cx| {
|
||||
cx.new(|_| RightDetails {
|
||||
title: "Welcome",
|
||||
@@ -428,212 +429,272 @@ impl Gallery {
|
||||
.into()
|
||||
}),
|
||||
);
|
||||
dock.register_panel(PanelDescriptor::new("button", "Button", |_, cx| {
|
||||
cx.new(|_| ButtonDemo { clicks: 0 }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("input", "Input", |_, cx| {
|
||||
cx.new(InputDemo::new).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("field", "Field", |window, cx| {
|
||||
cx.new(|cx| FieldDemo::new(window, cx)).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"combobox",
|
||||
"Combobox",
|
||||
|window, cx| cx.new(|cx| ComboboxDemo::new(window, cx)).into(),
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new("status-dot", "Status dot", |_, cx| {
|
||||
cx.new(|_| StatusDotDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("checkbox", "Checkbox", |_, cx| {
|
||||
cx.new(|_| CheckboxDemo { checked: false }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("radio", "Radio", |_, cx| {
|
||||
cx.new(|_| RadioDemo {
|
||||
plan: SharedString::from("starter"),
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("button", |_, cx| {
|
||||
cx.new(|_| ButtonDemo { clicks: 0 }).into()
|
||||
})
|
||||
.into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("switch", "Switch", |_, cx| {
|
||||
cx.new(|_| SwitchDemo { checked: true }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("toggle", "Toggle", |_, cx| {
|
||||
cx.new(|_| ToggleDemo { pressed: false }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("slider", "Slider", |_, cx| {
|
||||
cx.new(|_| SliderDemo { volume: 40.0 }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("segmented", "Segmented", |_, cx| {
|
||||
cx.new(|_| SegmentedDemo {
|
||||
filter: ExploreFilter::default(),
|
||||
.title("Button"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("input", |_, cx| cx.new(InputDemo::new).into()).title("Input"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("field", |window, cx| {
|
||||
cx.new(|cx| FieldDemo::new(window, cx)).into()
|
||||
})
|
||||
.into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("select", "Select", |_, cx| {
|
||||
cx.new(|_| SelectDemo {
|
||||
strategy: Some(Strategy::Curated),
|
||||
.title("Field"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("combobox", |window, cx| {
|
||||
cx.new(|cx| ComboboxDemo::new(window, cx)).into()
|
||||
})
|
||||
.into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("link", "Link", |_, cx| {
|
||||
cx.new(|_| LinkDemo { clicks: 0 }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("clipboard", "Clipboard", |_, cx| {
|
||||
cx.new(|_| ClipboardDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("badge", "Badge", |_, cx| {
|
||||
cx.new(|_| BadgeDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("avatar", "Avatar", |_, cx| {
|
||||
cx.new(|_| AvatarDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("progress", "Progress", |_, cx| {
|
||||
cx.new(|_| ProgressDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("spinner", "Spinner", |_, cx| {
|
||||
cx.new(|_| SpinnerDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("list", "List", |_, cx| {
|
||||
cx.new(|_| ListDemo { selected: None }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("tree", "Tree", |_, cx| {
|
||||
cx.new(|_| TreeDemo {
|
||||
nodes: TreeDemo::demo(),
|
||||
selected: None,
|
||||
.title("Combobox"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("status-dot", |_, cx| cx.new(|_| StatusDotDemo).into())
|
||||
.title("Status dot"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("checkbox", |_, cx| {
|
||||
cx.new(|_| CheckboxDemo { checked: false }).into()
|
||||
})
|
||||
.into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("tabs", "Tabs", |_, cx| {
|
||||
cx.new(|_| TabsDemo {
|
||||
selected: 0,
|
||||
pill_tabs: vec![
|
||||
SharedString::from("Explorer"),
|
||||
SharedString::from("Syncing"),
|
||||
SharedString::from("Blame"),
|
||||
],
|
||||
pill_selected: 0,
|
||||
lead_selected: 0,
|
||||
})
|
||||
.into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("alert", "Alert", {
|
||||
let layout_state = layout_state.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|_| AlertDemo {
|
||||
layout_state: layout_state.clone(),
|
||||
dismissed: false,
|
||||
.title("Checkbox"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("radio", |_, cx| {
|
||||
cx.new(|_| RadioDemo {
|
||||
plan: SharedString::from("starter"),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("toast", "Toast", {
|
||||
let layout_state = layout_state.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|_| ToastDemo {
|
||||
layout_state: layout_state.clone(),
|
||||
})
|
||||
.title("Radio"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("switch", |_, cx| {
|
||||
cx.new(|_| SwitchDemo { checked: true }).into()
|
||||
})
|
||||
.title("Switch"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("toggle", |_, cx| {
|
||||
cx.new(|_| ToggleDemo { pressed: false }).into()
|
||||
})
|
||||
.title("Toggle"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("slider", |_, cx| {
|
||||
cx.new(|_| SliderDemo { volume: 40.0 }).into()
|
||||
})
|
||||
.title("Slider"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("segmented", |_, cx| {
|
||||
cx.new(|_| SegmentedDemo {
|
||||
filter: ExploreFilter::default(),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("dialog", "Dialog", {
|
||||
let gallery = gallery.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|_| DialogDemo {
|
||||
gallery: gallery.clone(),
|
||||
})
|
||||
.title("Segmented"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("select", |_, cx| {
|
||||
cx.new(|_| SelectDemo {
|
||||
strategy: Some(Strategy::Curated),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"command-palette",
|
||||
"Command palette",
|
||||
{
|
||||
})
|
||||
.title("Select"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("link", |_, cx| cx.new(|_| LinkDemo { clicks: 0 }).into())
|
||||
.title("Link"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("clipboard", |_, cx| cx.new(|_| ClipboardDemo).into())
|
||||
.title("Clipboard"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("badge", |_, cx| cx.new(|_| BadgeDemo).into()).title("Badge"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("avatar", |_, cx| cx.new(|_| AvatarDemo).into()).title("Avatar"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("progress", |_, cx| cx.new(|_| ProgressDemo).into())
|
||||
.title("Progress"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("spinner", |_, cx| cx.new(|_| SpinnerDemo).into())
|
||||
.title("Spinner"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("list", |_, cx| {
|
||||
cx.new(|_| ListDemo { selected: None }).into()
|
||||
})
|
||||
.title("List"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("tree", |_, cx| {
|
||||
cx.new(|_| TreeDemo {
|
||||
nodes: TreeDemo::demo(),
|
||||
selected: None,
|
||||
})
|
||||
.into()
|
||||
})
|
||||
.title("Tree"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("tabs", |_, cx| {
|
||||
cx.new(|_| TabsDemo {
|
||||
selected: 0,
|
||||
pill_tabs: vec![
|
||||
SharedString::from("Explorer"),
|
||||
SharedString::from("Syncing"),
|
||||
SharedString::from("Blame"),
|
||||
],
|
||||
pill_selected: 0,
|
||||
lead_selected: 0,
|
||||
})
|
||||
.into()
|
||||
})
|
||||
.title("Tabs"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("alert", {
|
||||
let layout_state = layout_state.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|_| AlertDemo {
|
||||
layout_state: layout_state.clone(),
|
||||
dismissed: false,
|
||||
})
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.title("Alert"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("toast", {
|
||||
let layout_state = layout_state.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|_| ToastDemo {
|
||||
layout_state: layout_state.clone(),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.title("Toast"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("dialog", {
|
||||
let gallery = gallery.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|_| DialogDemo {
|
||||
gallery: gallery.clone(),
|
||||
})
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.title("Dialog"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("command-palette", {
|
||||
let palette = palette.clone();
|
||||
move |_, cx| {
|
||||
cx.new(|cx| CommandPaletteDemo::new(gallery.clone(), palette.clone(), cx))
|
||||
.into()
|
||||
}
|
||||
},
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new("menu", "Menu", |_, cx| {
|
||||
cx.new(|_| MenuDemo { open: false }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"dropdown-menu",
|
||||
"Dropdown menu",
|
||||
|_, cx| {
|
||||
})
|
||||
.title("Command palette"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("menu", |_, cx| cx.new(|_| MenuDemo { open: false }).into())
|
||||
.title("Menu"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("dropdown-menu", |_, cx| {
|
||||
cx.new(|_| DropdownMenuDemo {
|
||||
open_menu: None,
|
||||
status: None,
|
||||
})
|
||||
.into()
|
||||
},
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"context-menu",
|
||||
"Context menu",
|
||||
|_, cx| {
|
||||
})
|
||||
.title("Dropdown menu"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("context-menu", |_, cx| {
|
||||
cx.new(|_| ContextMenuDemo {
|
||||
action: SharedString::from("Right-click the card"),
|
||||
})
|
||||
.into()
|
||||
},
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new("popover", "Popover", |_, cx| {
|
||||
cx.new(|_| PopoverDemo { open: false }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("tooltip", "Tooltip", |_, cx| {
|
||||
cx.new(|_| TooltipDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"empty-state",
|
||||
"Empty state",
|
||||
|_, cx| cx.new(|_| EmptyStateDemo).into(),
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"scroll-area",
|
||||
"Scroll area",
|
||||
|_, cx| cx.new(|_| ScrollAreaDemo).into(),
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new("scrollbar", "Scrollbar", |_, cx| {
|
||||
cx.new(|_| ScrollbarDemo::new()).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("code-view", "Code view", |_, cx| {
|
||||
cx.new(CodeViewDemo::new).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("diff-view", "Diff view", |_, cx| {
|
||||
cx.new(DiffViewDemo::new).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"markdown-view",
|
||||
"Markdown view",
|
||||
|_, cx| cx.new(MarkdownViewDemo::new).into(),
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new("text-view", "Text view", |_, cx| {
|
||||
cx.new(TextViewDemo::new).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("sidebar", "Sidebar", |_, cx| {
|
||||
cx.new(|_| SidebarDemo { selected: None }).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new(
|
||||
"resize-handle",
|
||||
"Resize handle",
|
||||
|window, cx| {
|
||||
})
|
||||
.title("Context menu"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("popover", |_, cx| {
|
||||
cx.new(|_| PopoverDemo { open: false }).into()
|
||||
})
|
||||
.title("Popover"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("tooltip", |_, cx| cx.new(|_| TooltipDemo).into())
|
||||
.title("Tooltip"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("empty-state", |_, cx| cx.new(|_| EmptyStateDemo).into())
|
||||
.title("Empty state"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("scroll-area", |_, cx| cx.new(|_| ScrollAreaDemo).into())
|
||||
.title("Scroll area"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("scrollbar", |_, cx| cx.new(|_| ScrollbarDemo::new()).into())
|
||||
.title("Scrollbar"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("code-view", |_, cx| cx.new(CodeViewDemo::new).into())
|
||||
.title("Code view"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("diff-view", |_, cx| cx.new(DiffViewDemo::new).into())
|
||||
.title("Diff view"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("markdown-view", |_, cx| {
|
||||
cx.new(MarkdownViewDemo::new).into()
|
||||
})
|
||||
.title("Markdown view"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("text-view", |_, cx| cx.new(TextViewDemo::new).into())
|
||||
.title("Text view"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("sidebar", |_, cx| {
|
||||
cx.new(|_| SidebarDemo { selected: None }).into()
|
||||
})
|
||||
.title("Sidebar"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("resize-handle", |window, cx| {
|
||||
cx.new(|_| ResizeDemo {
|
||||
width: rems(ResizeDemo::WIDTH_DEFAULT_REMS).to_pixels(window.rem_size()),
|
||||
})
|
||||
.into()
|
||||
},
|
||||
));
|
||||
dock.register_panel(PanelDescriptor::new("resizable", "Resizable", |_, cx| {
|
||||
cx.new(ResizableDemo::new).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("separator", "Separator", |_, cx| {
|
||||
cx.new(|_| SeparatorDemo).into()
|
||||
}));
|
||||
dock.register_panel(PanelDescriptor::new("theme", "Theme", |_, cx| {
|
||||
cx.new(|_| ThemeDemo).into()
|
||||
}));
|
||||
})
|
||||
.title("Resize handle"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("resizable", |_, cx| cx.new(ResizableDemo::new).into())
|
||||
.title("Resizable"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("separator", |_, cx| cx.new(|_| SeparatorDemo).into())
|
||||
.title("Separator"),
|
||||
);
|
||||
dock.register_panel(
|
||||
PanelDescriptor::new("theme", |_, cx| cx.new(|_| ThemeDemo).into()).title("Theme"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user