layout: replace panel descriptors with panel trait
This commit is contained in:
+75
-84
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use gpui::prelude::FluentBuilder as _;
|
use gpui::prelude::FluentBuilder as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
@@ -27,65 +28,59 @@ const MIN_SPLIT_RATIO: f32 = 0.1;
|
|||||||
/// The fraction a split opens at, and what a double-click on the seam restores.
|
/// The fraction a split opens at, and what a double-click on the seam restores.
|
||||||
const DEFAULT_SPLIT_RATIO: f32 = 0.5;
|
const DEFAULT_SPLIT_RATIO: f32 = 0.5;
|
||||||
|
|
||||||
/// Builds the view a panel opens as, once per open.
|
/// Builds a panel's view entity the first time its tab opens.
|
||||||
type PanelBuilder = Box<dyn Fn(&mut Window, &mut App) -> AnyView>;
|
type PanelBuilder = Box<dyn Fn(&mut Window, &mut App) -> Arc<dyn PanelView>>;
|
||||||
/// Runs when a panel with a right sidebar activates, so the app can open it.
|
/// Runs when a panel with a right sidebar activates, so the app can open it.
|
||||||
type OpenRightSidebarHandler = Rc<dyn Fn(&mut App)>;
|
type OpenRightSidebarHandler = Rc<dyn Fn(&mut App)>;
|
||||||
|
|
||||||
/// A registered panel: its identity, chrome, and how its view is built.
|
/// A dockable panel.
|
||||||
#[must_use]
|
#[allow(unused_variables)]
|
||||||
pub struct PanelDescriptor {
|
pub trait Panel: Render + 'static {
|
||||||
id: SharedString,
|
/// The panel's tab label.
|
||||||
title: Option<SharedString>,
|
fn title(&self, cx: &App) -> Option<SharedString> {
|
||||||
lead: Option<Rc<dyn Fn() -> AnyElement>>,
|
None
|
||||||
build: PanelBuilder,
|
|
||||||
right_sidebar: Option<PanelBuilder>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PanelDescriptor {
|
|
||||||
/// Creates a panel descriptor that opens through `build`.
|
|
||||||
pub fn new<I, F>(id: I, build: F) -> Self
|
|
||||||
where
|
|
||||||
I: Into<SharedString>,
|
|
||||||
F: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
|
||||||
{
|
|
||||||
Self {
|
|
||||||
id: id.into(),
|
|
||||||
title: None,
|
|
||||||
lead: None,
|
|
||||||
build: Box::new(build),
|
|
||||||
right_sidebar: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shows `title` as the panel's tab label.
|
/// An element, e.g. an icon or avatar, leading the tab label.
|
||||||
pub fn title<T>(mut self, title: T) -> Self
|
fn lead(&self, cx: &App) -> Option<AnyElement> {
|
||||||
where
|
None
|
||||||
T: Into<SharedString>,
|
|
||||||
{
|
|
||||||
self.title = Some(title.into());
|
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shows an element, e.g. an icon or avatar, leading the tab label.
|
/// The view the right sidebar shows while this panel is active.
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the view the right sidebar shows while this panel is active.
|
|
||||||
///
|
///
|
||||||
/// Activating the panel opens the right sidebar.
|
/// Activating the panel opens the right sidebar.
|
||||||
pub fn right_sidebar<F>(mut self, build: F) -> Self
|
fn right_sidebar(&mut self, window: &mut Window, cx: &mut App) -> Option<AnyView> {
|
||||||
where
|
None
|
||||||
F: Fn(&mut Window, &mut App) -> AnyView + 'static,
|
}
|
||||||
{
|
}
|
||||||
self.right_sidebar = Some(Box::new(build));
|
|
||||||
self
|
/// Object-safe handle to an open panel entity.
|
||||||
|
pub trait PanelView: 'static {
|
||||||
|
/// The panel's view.
|
||||||
|
fn view(&self) -> AnyView;
|
||||||
|
/// The tab label, read live from the panel.
|
||||||
|
fn title(&self, cx: &App) -> Option<SharedString>;
|
||||||
|
/// The element leading the tab label, read live from the panel.
|
||||||
|
fn lead(&self, cx: &App) -> Option<AnyElement>;
|
||||||
|
/// The right sidebar view, built through the panel.
|
||||||
|
fn right_sidebar(&self, window: &mut Window, cx: &mut App) -> Option<AnyView>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Panel> PanelView for Entity<T> {
|
||||||
|
fn view(&self) -> AnyView {
|
||||||
|
self.clone().into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn title(&self, cx: &App) -> Option<SharedString> {
|
||||||
|
self.read(cx).title(cx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lead(&self, cx: &App) -> Option<AnyElement> {
|
||||||
|
self.read(cx).lead(cx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn right_sidebar(&self, window: &mut Window, cx: &mut App) -> Option<AnyView> {
|
||||||
|
self.update(cx, |panel, cx| panel.right_sidebar(window, cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,12 +135,10 @@ impl Render for DragPreview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One open panel view.
|
/// One open panel: its dock id, live handle, and right sidebar view.
|
||||||
struct PanelTab {
|
struct PanelTab {
|
||||||
panel: SharedString,
|
panel: SharedString,
|
||||||
title: Option<SharedString>,
|
handle: Arc<dyn PanelView>,
|
||||||
lead: Option<Rc<dyn Fn() -> AnyElement>>,
|
|
||||||
view: AnyView,
|
|
||||||
right_view: Option<AnyView>,
|
right_view: Option<AnyView>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +166,7 @@ enum Node {
|
|||||||
/// The dock's pane tree, owned by the application.
|
/// The dock's pane tree, owned by the application.
|
||||||
pub struct DockState {
|
pub struct DockState {
|
||||||
root: Node,
|
root: Node,
|
||||||
panels: HashMap<SharedString, PanelDescriptor>,
|
panels: HashMap<SharedString, PanelBuilder>,
|
||||||
/// The pane new panels open into, kept on the last activated pane.
|
/// The pane new panels open into, kept on the last activated pane.
|
||||||
active_pane: u64,
|
active_pane: u64,
|
||||||
next_key: u64,
|
next_key: u64,
|
||||||
@@ -205,9 +198,18 @@ impl DockState {
|
|||||||
self.on_open_right_sidebar = Some(Rc::new(handler));
|
self.on_open_right_sidebar = Some(Rc::new(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers a panel descriptor, replacing any earlier one with its id.
|
/// Registers a panel under `id`, replacing any earlier one with it.
|
||||||
pub fn register_panel(&mut self, panel: PanelDescriptor) {
|
pub fn register_panel<I, F, P>(&mut self, id: I, build: F)
|
||||||
self.panels.insert(panel.id.clone(), panel);
|
where
|
||||||
|
I: Into<SharedString>,
|
||||||
|
F: Fn(&mut Window, &mut App) -> Entity<P> + 'static,
|
||||||
|
P: Panel,
|
||||||
|
{
|
||||||
|
let build: PanelBuilder = Box::new(move |window, cx| {
|
||||||
|
let panel = build(window, cx);
|
||||||
|
Arc::new(panel)
|
||||||
|
});
|
||||||
|
self.panels.insert(id.into(), build);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens a panel into the active pane and activates its tab.
|
/// Opens a panel into the active pane and activates its tab.
|
||||||
@@ -217,20 +219,16 @@ impl DockState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(panel) = self.panels.get(id) else {
|
let Some(build) = self.panels.get(id) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let right_view = panel
|
let handle = build(window, cx);
|
||||||
.right_sidebar
|
let right_view = handle.right_sidebar(window, cx);
|
||||||
.as_ref()
|
|
||||||
.map(|build| (build)(window, cx));
|
|
||||||
|
|
||||||
let tab = PanelTab {
|
let tab = PanelTab {
|
||||||
panel: SharedString::from(id),
|
panel: SharedString::from(id),
|
||||||
title: panel.title.clone(),
|
handle,
|
||||||
lead: panel.lead.clone(),
|
|
||||||
view: (panel.build)(window, cx),
|
|
||||||
right_view,
|
right_view,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -692,9 +690,7 @@ impl DockState {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|tab| TabView {
|
.map(|tab| TabView {
|
||||||
panel: tab.panel.clone(),
|
panel: tab.panel.clone(),
|
||||||
title: tab.title.clone(),
|
handle: tab.handle.clone(),
|
||||||
lead: tab.lead.clone(),
|
|
||||||
view: tab.view.clone(),
|
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
active: pane.active.clone(),
|
active: pane.active.clone(),
|
||||||
@@ -750,13 +746,11 @@ impl DockState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One open panel view, per frame.
|
/// One open panel's handle, per frame.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct TabView {
|
struct TabView {
|
||||||
panel: SharedString,
|
panel: SharedString,
|
||||||
title: Option<SharedString>,
|
handle: Arc<dyn PanelView>,
|
||||||
lead: Option<Rc<dyn Fn() -> AnyElement>>,
|
|
||||||
view: AnyView,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -1013,7 +1007,7 @@ fn render_pane(
|
|||||||
.tabs
|
.tabs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|tab| Some(&tab.panel) == pane.active.as_ref())
|
.find(|tab| Some(&tab.panel) == pane.active.as_ref())
|
||||||
.map(|tab| tab.view.clone());
|
.map(|tab| tab.handle.view());
|
||||||
|
|
||||||
// The cache keeps an un-notified panel from re-rendering on dock frames.
|
// The cache keeps an un-notified panel from re-rendering on dock frames.
|
||||||
let content_id = SharedString::from(format!("{dock_id}-content-{}", pane.key));
|
let content_id = SharedString::from(format!("{dock_id}-content-{}", pane.key));
|
||||||
@@ -1056,28 +1050,25 @@ fn render_pane(
|
|||||||
.selected(selected)
|
.selected(selected)
|
||||||
.tabs({
|
.tabs({
|
||||||
let tabs = pane.tabs.clone();
|
let tabs = pane.tabs.clone();
|
||||||
move |_, _| {
|
move |_, cx| {
|
||||||
tabs.iter()
|
tabs.iter()
|
||||||
.map(|tab| {
|
.map(|tab| {
|
||||||
Tab::new(tab.panel.clone(), tab.title.clone().unwrap_or_default())
|
Tab::new(tab.panel.clone(), tab.handle.title(cx).unwrap_or_default())
|
||||||
.when_some(tab.lead.as_ref().map(|build| build()), |entry, lead| {
|
.when_some(tab.handle.lead(cx), |entry, lead| entry.lead(lead))
|
||||||
entry.lead(lead)
|
|
||||||
})
|
|
||||||
.closeable(true)
|
.closeable(true)
|
||||||
.wrap({
|
.wrap({
|
||||||
let panel = tab.panel.clone();
|
let panel = tab.panel.clone();
|
||||||
let title = tab.title.clone();
|
let handle = tab.handle.clone();
|
||||||
move |tab| {
|
move |tab| {
|
||||||
tab.on_drag(
|
tab.on_drag(
|
||||||
PanelDrag {
|
PanelDrag {
|
||||||
panel: panel.clone(),
|
panel: panel.clone(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
let title = title.clone();
|
let handle = handle.clone();
|
||||||
move |_, _, _, cx| {
|
move |_, _, _, cx| {
|
||||||
cx.new(|_| DragPreview {
|
let title = handle.title(cx);
|
||||||
title: title.clone(),
|
cx.new(move |_| DragPreview { title })
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
+338
-231
@@ -3,10 +3,10 @@ use std::time::Duration;
|
|||||||
|
|
||||||
use gpui::prelude::FluentBuilder as _;
|
use gpui::prelude::FluentBuilder as _;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
App, AppContext as _, Axis, Bounds, Context, Entity, FontWeight, InteractiveElement as _,
|
AnyView, App, AppContext as _, Axis, Bounds, Context, Entity, FontWeight,
|
||||||
IntoElement, KeyBinding, ListAlignment, ListState, ParentElement as _, Pixels, Render,
|
InteractiveElement as _, IntoElement, KeyBinding, ListAlignment, ListState, ParentElement as _,
|
||||||
SharedString, Styled as _, UniformListScrollHandle, WeakEntity, Window, WindowBounds,
|
Pixels, Render, SharedString, Styled as _, UniformListScrollHandle, WeakEntity, Window,
|
||||||
WindowOptions, actions, div, list, px, rems, size, uniform_list,
|
WindowBounds, WindowOptions, actions, div, list, px, rems, size, uniform_list,
|
||||||
};
|
};
|
||||||
use gpui_native_core::alert::{Alert, AlertSeverity};
|
use gpui_native_core::alert::{Alert, AlertSeverity};
|
||||||
use gpui_native_core::avatar::Avatar;
|
use gpui_native_core::avatar::Avatar;
|
||||||
@@ -49,7 +49,7 @@ use gpui_native_editor::diff::{DiffRowKind, DiffViewState};
|
|||||||
use gpui_native_editor::highlight::Language;
|
use gpui_native_editor::highlight::Language;
|
||||||
use gpui_native_editor::markdown::{ListMarker, MarkdownBlock, MarkdownViewState, TextView};
|
use gpui_native_editor::markdown::{ListMarker, MarkdownBlock, MarkdownViewState, TextView};
|
||||||
use gpui_native_icons::{IconAssets, IconRole, icon};
|
use gpui_native_icons::{IconAssets, IconRole, icon};
|
||||||
use gpui_native_layout::dock::{Dock, DockSidebar, DockState, PanelDescriptor, SplitDirection};
|
use gpui_native_layout::dock::{Dock, DockSidebar, DockState, Panel, SplitDirection};
|
||||||
use gpui_native_layout::resizable::{Resizable, ResizableState};
|
use gpui_native_layout::resizable::{Resizable, ResizableState};
|
||||||
use gpui_native_layout::resize_handle::ResizeHandle;
|
use gpui_native_layout::resize_handle::ResizeHandle;
|
||||||
use gpui_native_layout::shell::{LayoutState, Shell};
|
use gpui_native_layout::shell::{LayoutState, Shell};
|
||||||
@@ -406,8 +406,7 @@ impl Gallery {
|
|||||||
) {
|
) {
|
||||||
let dock_state = cx.entity();
|
let dock_state = cx.entity();
|
||||||
|
|
||||||
dock.register_panel(
|
dock.register_panel("welcome", {
|
||||||
PanelDescriptor::new("welcome", {
|
|
||||||
let layout_state = layout_state.clone();
|
let layout_state = layout_state.clone();
|
||||||
let dock_state = dock_state.clone();
|
let dock_state = dock_state.clone();
|
||||||
let gallery = gallery.clone();
|
let gallery = gallery.clone();
|
||||||
@@ -417,134 +416,52 @@ impl Gallery {
|
|||||||
dock_state: dock_state.clone(),
|
dock_state: dock_state.clone(),
|
||||||
gallery: gallery.clone(),
|
gallery: gallery.clone(),
|
||||||
})
|
})
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.title("Welcome")
|
dock.register_panel("button", |_, cx| cx.new(|_| ButtonDemo { clicks: 0 }));
|
||||||
.right_sidebar(|_, cx| {
|
dock.register_panel("input", |_, cx| cx.new(InputDemo::new));
|
||||||
cx.new(|_| RightDetails {
|
dock.register_panel("field", |window, cx| {
|
||||||
title: "Welcome",
|
cx.new(|cx| FieldDemo::new(window, cx))
|
||||||
body: "Panels can declare this view; activating one opens the sidebar.",
|
});
|
||||||
})
|
dock.register_panel("combobox", |window, cx| {
|
||||||
.into()
|
cx.new(|cx| ComboboxDemo::new(window, cx))
|
||||||
}),
|
});
|
||||||
);
|
dock.register_panel("status-dot", |_, cx| cx.new(|_| StatusDotDemo));
|
||||||
dock.register_panel(
|
dock.register_panel("checkbox", |_, cx| {
|
||||||
PanelDescriptor::new("button", |_, cx| {
|
cx.new(|_| CheckboxDemo { checked: false })
|
||||||
cx.new(|_| ButtonDemo { clicks: 0 }).into()
|
});
|
||||||
})
|
dock.register_panel("radio", |_, cx| {
|
||||||
.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()
|
|
||||||
})
|
|
||||||
.title("Field"),
|
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("combobox", |window, cx| {
|
|
||||||
cx.new(|cx| ComboboxDemo::new(window, cx)).into()
|
|
||||||
})
|
|
||||||
.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()
|
|
||||||
})
|
|
||||||
.title("Checkbox"),
|
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("radio", |_, cx| {
|
|
||||||
cx.new(|_| RadioDemo {
|
cx.new(|_| RadioDemo {
|
||||||
plan: SharedString::from("starter"),
|
plan: SharedString::from("starter"),
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("switch", |_, cx| cx.new(|_| SwitchDemo { checked: true }));
|
||||||
.title("Radio"),
|
dock.register_panel("toggle", |_, cx| cx.new(|_| ToggleDemo { pressed: false }));
|
||||||
);
|
dock.register_panel("slider", |_, cx| cx.new(|_| SliderDemo { volume: 40.0 }));
|
||||||
dock.register_panel(
|
dock.register_panel("segmented", |_, cx| {
|
||||||
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 {
|
cx.new(|_| SegmentedDemo {
|
||||||
filter: ExploreFilter::default(),
|
filter: ExploreFilter::default(),
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("select", |_, cx| {
|
||||||
.title("Segmented"),
|
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("select", |_, cx| {
|
|
||||||
cx.new(|_| SelectDemo {
|
cx.new(|_| SelectDemo {
|
||||||
strategy: Some(Strategy::Curated),
|
strategy: Some(Strategy::Curated),
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("link", |_, cx| cx.new(|_| LinkDemo { clicks: 0 }));
|
||||||
.title("Select"),
|
dock.register_panel("clipboard", |_, cx| cx.new(|_| ClipboardDemo));
|
||||||
);
|
dock.register_panel("badge", |_, cx| cx.new(|_| BadgeDemo));
|
||||||
dock.register_panel(
|
dock.register_panel("avatar", |_, cx| cx.new(|_| AvatarDemo));
|
||||||
PanelDescriptor::new("link", |_, cx| cx.new(|_| LinkDemo { clicks: 0 }).into())
|
dock.register_panel("progress", |_, cx| cx.new(|_| ProgressDemo));
|
||||||
.title("Link"),
|
dock.register_panel("spinner", |_, cx| cx.new(|_| SpinnerDemo));
|
||||||
);
|
dock.register_panel("list", |_, cx| cx.new(|_| ListDemo { selected: None }));
|
||||||
dock.register_panel(
|
dock.register_panel("tree", |_, cx| {
|
||||||
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 {
|
cx.new(|_| TreeDemo {
|
||||||
nodes: TreeDemo::demo(),
|
nodes: TreeDemo::demo(),
|
||||||
selected: None,
|
selected: None,
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("tabs", |_, cx| {
|
||||||
.title("Tree"),
|
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("tabs", |_, cx| {
|
|
||||||
cx.new(|_| TabsDemo {
|
cx.new(|_| TabsDemo {
|
||||||
selected: 0,
|
selected: 0,
|
||||||
pill_tabs: vec![
|
pill_tabs: vec![
|
||||||
@@ -555,146 +472,68 @@ impl Gallery {
|
|||||||
pill_selected: 0,
|
pill_selected: 0,
|
||||||
lead_selected: 0,
|
lead_selected: 0,
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("alert", {
|
||||||
.title("Tabs"),
|
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("alert", {
|
|
||||||
let layout_state = layout_state.clone();
|
let layout_state = layout_state.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
cx.new(|_| AlertDemo {
|
cx.new(|_| AlertDemo {
|
||||||
layout_state: layout_state.clone(),
|
layout_state: layout_state.clone(),
|
||||||
dismissed: false,
|
dismissed: false,
|
||||||
})
|
})
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.title("Alert"),
|
dock.register_panel("toast", {
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("toast", {
|
|
||||||
let layout_state = layout_state.clone();
|
let layout_state = layout_state.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
cx.new(|_| ToastDemo {
|
cx.new(|_| ToastDemo {
|
||||||
layout_state: layout_state.clone(),
|
layout_state: layout_state.clone(),
|
||||||
})
|
})
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.title("Toast"),
|
dock.register_panel("dialog", {
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("dialog", {
|
|
||||||
let gallery = gallery.clone();
|
let gallery = gallery.clone();
|
||||||
move |_, cx| {
|
move |_, cx| {
|
||||||
cx.new(|_| DialogDemo {
|
cx.new(|_| DialogDemo {
|
||||||
gallery: gallery.clone(),
|
gallery: gallery.clone(),
|
||||||
})
|
})
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
.title("Dialog"),
|
dock.register_panel("command-palette", {
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("command-palette", {
|
|
||||||
let palette = palette.clone();
|
let palette = palette.clone();
|
||||||
move |_, cx| {
|
move |_, cx| cx.new(|cx| CommandPaletteDemo::new(gallery.clone(), palette.clone(), cx))
|
||||||
cx.new(|cx| CommandPaletteDemo::new(gallery.clone(), palette.clone(), cx))
|
});
|
||||||
.into()
|
dock.register_panel("menu", |_, cx| cx.new(|_| MenuDemo { open: false }));
|
||||||
}
|
dock.register_panel("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 {
|
cx.new(|_| DropdownMenuDemo {
|
||||||
open_menu: None,
|
open_menu: None,
|
||||||
status: None,
|
status: None,
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("context-menu", |_, cx| {
|
||||||
.title("Dropdown menu"),
|
|
||||||
);
|
|
||||||
dock.register_panel(
|
|
||||||
PanelDescriptor::new("context-menu", |_, cx| {
|
|
||||||
cx.new(|_| ContextMenuDemo {
|
cx.new(|_| ContextMenuDemo {
|
||||||
action: SharedString::from("Right-click the card"),
|
action: SharedString::from("Right-click the card"),
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("popover", |_, cx| cx.new(|_| PopoverDemo { open: false }));
|
||||||
.title("Context menu"),
|
dock.register_panel("tooltip", |_, cx| cx.new(|_| TooltipDemo));
|
||||||
);
|
dock.register_panel("empty-state", |_, cx| cx.new(|_| EmptyStateDemo));
|
||||||
dock.register_panel(
|
dock.register_panel("scroll-area", |_, cx| cx.new(|_| ScrollAreaDemo));
|
||||||
PanelDescriptor::new("popover", |_, cx| {
|
dock.register_panel("scrollbar", |_, cx| cx.new(|_| ScrollbarDemo::new()));
|
||||||
cx.new(|_| PopoverDemo { open: false }).into()
|
dock.register_panel("code-view", |_, cx| cx.new(CodeViewDemo::new));
|
||||||
})
|
dock.register_panel("diff-view", |_, cx| cx.new(DiffViewDemo::new));
|
||||||
.title("Popover"),
|
dock.register_panel("markdown-view", |_, cx| cx.new(MarkdownViewDemo::new));
|
||||||
);
|
dock.register_panel("text-view", |_, cx| cx.new(TextViewDemo::new));
|
||||||
dock.register_panel(
|
dock.register_panel("sidebar", |_, cx| {
|
||||||
PanelDescriptor::new("tooltip", |_, cx| cx.new(|_| TooltipDemo).into())
|
cx.new(|_| SidebarDemo { selected: None })
|
||||||
.title("Tooltip"),
|
});
|
||||||
);
|
dock.register_panel("resize-handle", |window, cx| {
|
||||||
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 {
|
cx.new(|_| ResizeDemo {
|
||||||
width: rems(ResizeDemo::WIDTH_DEFAULT_REMS).to_pixels(window.rem_size()),
|
width: rems(ResizeDemo::WIDTH_DEFAULT_REMS).to_pixels(window.rem_size()),
|
||||||
})
|
})
|
||||||
.into()
|
});
|
||||||
})
|
dock.register_panel("resizable", |_, cx| cx.new(ResizableDemo::new));
|
||||||
.title("Resize handle"),
|
dock.register_panel("separator", |_, cx| cx.new(|_| SeparatorDemo));
|
||||||
);
|
dock.register_panel("theme", |_, cx| cx.new(|_| ThemeDemo));
|
||||||
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"),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,6 +572,22 @@ struct WelcomePanel {
|
|||||||
gallery: WeakEntity<Gallery>,
|
gallery: WeakEntity<Gallery>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for WelcomePanel {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Welcome".into())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn right_sidebar(&mut self, _: &mut Window, cx: &mut App) -> Option<AnyView> {
|
||||||
|
Some(
|
||||||
|
cx.new(|_| RightDetails {
|
||||||
|
title: "Welcome",
|
||||||
|
body: "Panels can declare this view; activating one opens the sidebar.",
|
||||||
|
})
|
||||||
|
.into(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for WelcomePanel {
|
impl Render for WelcomePanel {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -869,6 +724,12 @@ impl ButtonDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ButtonDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Button".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ButtonDemo {
|
impl Render for ButtonDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1035,6 +896,12 @@ impl InputDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for InputDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Input".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for InputDemo {
|
impl Render for InputDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1119,6 +986,12 @@ impl FieldDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for FieldDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Field".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for FieldDemo {
|
impl Render for FieldDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1191,6 +1064,12 @@ impl Render for FieldDemo {
|
|||||||
|
|
||||||
struct StatusDotDemo;
|
struct StatusDotDemo;
|
||||||
|
|
||||||
|
impl Panel for StatusDotDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Status dot".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for StatusDotDemo {
|
impl Render for StatusDotDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1359,6 +1238,12 @@ impl ComboboxDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ComboboxDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Combobox".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ComboboxDemo {
|
impl Render for ComboboxDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1428,6 +1313,12 @@ struct CheckboxDemo {
|
|||||||
checked: bool,
|
checked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for CheckboxDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Checkbox".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for CheckboxDemo {
|
impl Render for CheckboxDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1470,6 +1361,12 @@ struct RadioDemo {
|
|||||||
plan: SharedString,
|
plan: SharedString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for RadioDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Radio".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for RadioDemo {
|
impl Render for RadioDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1506,6 +1403,12 @@ struct SwitchDemo {
|
|||||||
checked: bool,
|
checked: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for SwitchDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Switch".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SwitchDemo {
|
impl Render for SwitchDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1548,6 +1451,12 @@ struct ToggleDemo {
|
|||||||
pressed: bool,
|
pressed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ToggleDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Toggle".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ToggleDemo {
|
impl Render for ToggleDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1585,6 +1494,12 @@ struct SliderDemo {
|
|||||||
volume: f32,
|
volume: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for SliderDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Slider".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SliderDemo {
|
impl Render for SliderDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1622,6 +1537,12 @@ struct SegmentedDemo {
|
|||||||
filter: ExploreFilter,
|
filter: ExploreFilter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for SegmentedDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Segmented".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SegmentedDemo {
|
impl Render for SegmentedDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1704,6 +1625,12 @@ struct SelectDemo {
|
|||||||
strategy: Option<Strategy>,
|
strategy: Option<Strategy>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for SelectDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Select".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SelectDemo {
|
impl Render for SelectDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1752,6 +1679,12 @@ struct LinkDemo {
|
|||||||
clicks: usize,
|
clicks: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for LinkDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Link".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for LinkDemo {
|
impl Render for LinkDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -1800,6 +1733,12 @@ impl Render for LinkDemo {
|
|||||||
|
|
||||||
struct ClipboardDemo;
|
struct ClipboardDemo;
|
||||||
|
|
||||||
|
impl Panel for ClipboardDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Clipboard".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ClipboardDemo {
|
impl Render for ClipboardDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1834,6 +1773,12 @@ impl Render for ClipboardDemo {
|
|||||||
|
|
||||||
struct SeparatorDemo;
|
struct SeparatorDemo;
|
||||||
|
|
||||||
|
impl Panel for SeparatorDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Separator".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SeparatorDemo {
|
impl Render for SeparatorDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1886,6 +1831,12 @@ impl ResizableDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ResizableDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Resizable".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ResizableDemo {
|
impl Render for ResizableDemo {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1925,6 +1876,12 @@ impl Render for ResizableDemo {
|
|||||||
|
|
||||||
struct BadgeDemo;
|
struct BadgeDemo;
|
||||||
|
|
||||||
|
impl Panel for BadgeDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Badge".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for BadgeDemo {
|
impl Render for BadgeDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1964,6 +1921,12 @@ impl Render for BadgeDemo {
|
|||||||
|
|
||||||
struct AvatarDemo;
|
struct AvatarDemo;
|
||||||
|
|
||||||
|
impl Panel for AvatarDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Avatar".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for AvatarDemo {
|
impl Render for AvatarDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -1999,6 +1962,12 @@ impl Render for AvatarDemo {
|
|||||||
|
|
||||||
struct ProgressDemo;
|
struct ProgressDemo;
|
||||||
|
|
||||||
|
impl Panel for ProgressDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Progress".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ProgressDemo {
|
impl Render for ProgressDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -2024,6 +1993,12 @@ impl Render for ProgressDemo {
|
|||||||
|
|
||||||
struct SpinnerDemo;
|
struct SpinnerDemo;
|
||||||
|
|
||||||
|
impl Panel for SpinnerDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Spinner".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SpinnerDemo {
|
impl Render for SpinnerDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -2066,6 +2041,12 @@ struct ListDemo {
|
|||||||
selected: Option<usize>,
|
selected: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ListDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("List".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ListDemo {
|
impl Render for ListDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2241,6 +2222,12 @@ impl TreeDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for TreeDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Tree".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for TreeDemo {
|
impl Render for TreeDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2282,6 +2269,12 @@ struct TabsDemo {
|
|||||||
lead_selected: usize,
|
lead_selected: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for TabsDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Tabs".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for TabsDemo {
|
impl Render for TabsDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2403,6 +2396,12 @@ struct AlertDemo {
|
|||||||
dismissed: bool,
|
dismissed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for AlertDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Alert".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for AlertDemo {
|
impl Render for AlertDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2495,6 +2494,12 @@ struct ToastDemo {
|
|||||||
layout_state: Entity<LayoutState>,
|
layout_state: Entity<LayoutState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ToastDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Toast".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ToastDemo {
|
impl Render for ToastDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let toasts_undo = self.layout_state.clone();
|
let toasts_undo = self.layout_state.clone();
|
||||||
@@ -2565,6 +2570,12 @@ struct DialogDemo {
|
|||||||
gallery: WeakEntity<Gallery>,
|
gallery: WeakEntity<Gallery>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for DialogDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Dialog".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for DialogDemo {
|
impl Render for DialogDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let gallery_dialog = self.gallery.clone();
|
let gallery_dialog = self.gallery.clone();
|
||||||
@@ -2631,6 +2642,12 @@ impl CommandPaletteDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for CommandPaletteDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Command palette".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for CommandPaletteDemo {
|
impl Render for CommandPaletteDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -2697,6 +2714,12 @@ struct MenuDemo {
|
|||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for MenuDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Menu".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for MenuDemo {
|
impl Render for MenuDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2768,6 +2791,12 @@ impl DropdownMenuDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for DropdownMenuDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Dropdown menu".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for DropdownMenuDemo {
|
impl Render for DropdownMenuDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2919,6 +2948,12 @@ struct ContextMenuDemo {
|
|||||||
action: SharedString,
|
action: SharedString,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ContextMenuDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Context menu".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ContextMenuDemo {
|
impl Render for ContextMenuDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -2974,6 +3009,12 @@ struct PopoverDemo {
|
|||||||
open: bool,
|
open: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for PopoverDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Popover".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for PopoverDemo {
|
impl Render for PopoverDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -3015,6 +3056,12 @@ impl Render for PopoverDemo {
|
|||||||
|
|
||||||
struct TooltipDemo;
|
struct TooltipDemo;
|
||||||
|
|
||||||
|
impl Panel for TooltipDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Tooltip".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for TooltipDemo {
|
impl Render for TooltipDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -3060,6 +3107,12 @@ impl Render for TooltipDemo {
|
|||||||
|
|
||||||
struct EmptyStateDemo;
|
struct EmptyStateDemo;
|
||||||
|
|
||||||
|
impl Panel for EmptyStateDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Empty state".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for EmptyStateDemo {
|
impl Render for EmptyStateDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
@@ -3106,6 +3159,12 @@ impl Render for EmptyStateDemo {
|
|||||||
|
|
||||||
struct ScrollAreaDemo;
|
struct ScrollAreaDemo;
|
||||||
|
|
||||||
|
impl Panel for ScrollAreaDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Scroll area".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ScrollAreaDemo {
|
impl Render for ScrollAreaDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
@@ -3188,6 +3247,12 @@ impl ScrollbarDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ScrollbarDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Scrollbar".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ScrollbarDemo {
|
impl Render for ScrollbarDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
@@ -3397,6 +3462,12 @@ impl CodeViewDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for CodeViewDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Code view".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for CodeViewDemo {
|
impl Render for CodeViewDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -3567,6 +3638,12 @@ impl DiffViewDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for DiffViewDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Diff view".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for DiffViewDemo {
|
impl Render for DiffViewDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -3787,6 +3864,12 @@ impl MarkdownViewDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for MarkdownViewDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Markdown view".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for MarkdownViewDemo {
|
impl Render for MarkdownViewDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -3863,6 +3946,12 @@ impl TextViewDemo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for TextViewDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Text view".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for TextViewDemo {
|
impl Render for TextViewDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let colors = cx.theme().colors;
|
let colors = cx.theme().colors;
|
||||||
@@ -3910,6 +3999,12 @@ struct SidebarDemo {
|
|||||||
selected: Option<usize>,
|
selected: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for SidebarDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Sidebar".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for SidebarDemo {
|
impl Render for SidebarDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -4078,6 +4173,12 @@ impl ResizeDemo {
|
|||||||
const WIDTH_MAX_REMS: f32 = 20.;
|
const WIDTH_MAX_REMS: f32 = 20.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Panel for ResizeDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Resize handle".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ResizeDemo {
|
impl Render for ResizeDemo {
|
||||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let view = cx.entity();
|
let view = cx.entity();
|
||||||
@@ -4156,6 +4257,12 @@ impl Render for ResizeDemo {
|
|||||||
|
|
||||||
struct ThemeDemo;
|
struct ThemeDemo;
|
||||||
|
|
||||||
|
impl Panel for ThemeDemo {
|
||||||
|
fn title(&self, _: &App) -> Option<SharedString> {
|
||||||
|
Some("Theme".into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Render for ThemeDemo {
|
impl Render for ThemeDemo {
|
||||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
|
|||||||
Reference in New Issue
Block a user