diff --git a/crates/layout/src/panel.rs b/crates/layout/src/panel.rs index 4e187d1..94f9c1e 100644 --- a/crates/layout/src/panel.rs +++ b/crates/layout/src/panel.rs @@ -3,14 +3,36 @@ //! divider between them; dragging the seam resizes the panels and a //! double-click restores the half split. +use std::sync::Arc; + use gpui::{ - AnyElement, AnyView, App, Axis, Div, ElementId, IntoElement, ParentElement as _, RenderOnce, - StyleRefinement, Styled as _, Window, div, rems, + AnyElement, AnyView, App, Axis, Div, ElementId, Entity, IntoElement, ParentElement as _, + Render, RenderOnce, StyleRefinement, Styled as _, Window, div, rems, }; use gpui_native_theme::ActiveTheme as _; use crate::resizable::{Resizable, ResizableState}; +pub trait Panel: Render + 'static {} + +/// An object-safe handle to a panel, so apps can hold panels by kind. +pub trait PanelView: 'static { + /// The panel's view. + fn view(&self) -> AnyView; +} + +impl PanelView for Entity { + fn view(&self) -> AnyView { + self.clone().into() + } +} + +impl PanelView for Arc

{ + fn view(&self) -> AnyView { + (**self).view() + } +} + /// The layout the cached panel content lays out with. fn content_style() -> StyleRefinement { StyleRefinement::default().size_full() @@ -33,13 +55,13 @@ fn island(panel: Div, cx: &App) -> Div { /// The panel row drawn under the titlebar. #[derive(IntoElement)] #[must_use] -pub struct Panel { +pub struct PanelRow { id: ElementId, main: Option, split: Option, } -impl Panel { +impl PanelRow { /// Creates the panel row. pub fn new(id: I) -> Self where @@ -53,19 +75,25 @@ impl Panel { } /// Sets the main panel's content. - pub fn main(mut self, main: AnyView) -> Self { - self.main = Some(main.cached(content_style()).into_any_element()); + pub fn main

(mut self, main: P) -> Self + where + P: PanelView, + { + self.main = Some(main.view().cached(content_style()).into_any_element()); self } - /// Splits the row into two half-width panels, - pub fn split(mut self, panel: AnyView) -> Self { - self.split = Some(panel.cached(content_style()).into_any_element()); + /// Splits the row into two half-width panels. + pub fn split

(mut self, panel: P) -> Self + where + P: PanelView, + { + self.split = Some(panel.view().cached(content_style()).into_any_element()); self } } -impl RenderOnce for Panel { +impl RenderOnce for PanelRow { fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement { let id = self.id.clone(); let gutter = rems(0.5).to_pixels(window.rem_size()); diff --git a/crates/layout/tests/panel.rs b/crates/layout/tests/panel.rs index 6f2aecc..69917e8 100644 --- a/crates/layout/tests/panel.rs +++ b/crates/layout/tests/panel.rs @@ -4,11 +4,11 @@ //! half-width islands with a drag divider that resizes them. use gpui::{ - AnyView, AppContext as _, Context, InteractiveElement as _, IntoElement, Modifiers, - MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement as _, Render, - SharedString, Styled as _, TestAppContext, VisualTestContext, Window, div, point, px, size, + AppContext as _, Context, Entity, InteractiveElement as _, IntoElement, Modifiers, MouseButton, + MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement as _, Render, SharedString, + Styled as _, TestAppContext, VisualTestContext, Window, div, point, px, size, }; -use gpui_native_layout::panel::Panel; +use gpui_native_layout::panel::{Panel, PanelRow}; use gpui_native_theme::Theme; const WINDOW_WIDTH: f32 = 1024.0; @@ -36,15 +36,17 @@ impl Render for TagView { } } +impl Panel for TagView {} + struct PanelHarness { split: bool, - main: AnyView, - split_view: AnyView, + main: Entity, + split_view: Entity, } impl Render for PanelHarness { fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - let panel = Panel::new("panel-harness").main(self.main.clone()); + let panel = PanelRow::new("panel-harness").main(self.main.clone()); let panel = if self.split { panel.split(self.split_view.clone()) } else { @@ -65,8 +67,8 @@ fn panel_window(cx: &mut TestAppContext, split: bool) -> VisualTestContext { let window = cx.open_window(size(px(WINDOW_WIDTH), px(WINDOW_HEIGHT)), |_, _| { PanelHarness { split, - main: main.into(), - split_view: split_view.into(), + main, + split_view, } }); let cx = VisualTestContext::from_window(window.into(), cx); diff --git a/docs/CHECKLIST.md b/docs/CHECKLIST.md index ff1ad13..6d2e53c 100644 --- a/docs/CHECKLIST.md +++ b/docs/CHECKLIST.md @@ -225,9 +225,11 @@ Gaps surfaced by the signed comparison; ordered by signed's usage. trailing buttons, `Theme::titlebar_height` - [x] Shell — the titlebar over the panel row in the window frame, hosting the toast and alert overlays -- [x] Panel — island layout on the muted app background: the main island +- [x] Panel row — island layout on the muted app background: the main island fills the window and can split once into two half-width islands with - a drag divider between them (double-click restores the half split) + a drag divider between them (double-click restores the half split); + apps define panels by implementing the `Panel` trait on their views + and hand entities or `PanelView` handles to `PanelRow` - [x] Resizable group — stacked panes with drag dividers, per-pane floors, double-click reset, keyboard steps diff --git a/examples/gallery/src/main.rs b/examples/gallery/src/main.rs index e2c0ef3..1fd543b 100644 --- a/examples/gallery/src/main.rs +++ b/examples/gallery/src/main.rs @@ -4,10 +4,10 @@ use std::time::Duration; use gpui::prelude::FluentBuilder as _; use gpui::{ - AnyView, App, AppContext as _, Axis, Bounds, Context, Entity, FontWeight, - InteractiveElement as _, IntoElement, KeyBinding, ListAlignment, ListState, ParentElement as _, - Pixels, Render, SharedString, Styled as _, UniformListScrollHandle, WeakEntity, Window, - WindowBounds, WindowOptions, actions, div, list, px, rems, size, uniform_list, + App, AppContext as _, Axis, Bounds, Context, Entity, FontWeight, InteractiveElement as _, + IntoElement, KeyBinding, ListAlignment, ListState, ParentElement as _, Pixels, Render, + SharedString, Styled as _, UniformListScrollHandle, WeakEntity, Window, WindowBounds, + WindowOptions, actions, div, list, px, rems, size, uniform_list, }; use gpui_native_core::alert::{Alert, AlertSeverity, Alerts}; use gpui_native_core::avatar::Avatar; @@ -50,7 +50,7 @@ use gpui_native_editor::diff::{DiffRowKind, DiffViewState}; use gpui_native_editor::highlight::Language; use gpui_native_editor::markdown::{ListMarker, MarkdownBlock, MarkdownViewState, TextView}; use gpui_native_icons::{IconAssets, IconRole, icon}; -use gpui_native_layout::panel::Panel; +use gpui_native_layout::panel::{Panel, PanelRow, PanelView}; use gpui_native_layout::resizable::{Resizable, ResizableState}; use gpui_native_layout::resize_handle::ResizeHandle; use gpui_native_layout::shell::Shell; @@ -226,9 +226,9 @@ struct Gallery { tabs: Vec, active: Option, /// Created demo views, kept so state survives tab switches. - views: HashMap, + views: HashMap>, /// The panel the row is split with, if any. - split_panel: Option, + split_panel: Option>, palette: Option>, palette_runs: Vec, dialog_open: bool, @@ -259,19 +259,19 @@ impl Gallery { } /// The panel row: the active demo, split with the opened sub panel. - fn render_panel(&self) -> Panel { - let panel = match self + fn render_panel(&self) -> PanelRow { + let row = match self .active .as_ref() .and_then(|active| self.views.get(active).cloned()) { - Some(view) => Panel::new("gallery-panel").main(view), - None => Panel::new("gallery-panel"), + Some(panel) => PanelRow::new("gallery-panel").main(panel), + None => PanelRow::new("gallery-panel"), }; match &self.split_panel { - Some(split) => panel.split(split.clone()), - None => panel, + Some(split) => row.split(split.clone()), + None => row, } } @@ -433,7 +433,7 @@ impl Gallery { return; } let view = cx.new(|_| column_details()); - self.split_panel = Some(view.into()); + self.split_panel = Some(Arc::new(view)); cx.notify(); } @@ -453,111 +453,90 @@ impl Gallery { gallery: WeakEntity, window: &mut Window, cx: &mut Context, - ) -> Option { - let view: AnyView = match id { - "welcome" => cx.new(|_| WelcomePanel { gallery }).into(), - "button" => cx.new(|_| ButtonDemo { clicks: 0 }).into(), - "input" => cx.new(InputDemo::new).into(), - "field" => cx.new(|cx| FieldDemo::new(window, cx)).into(), - "combobox" => cx.new(|cx| ComboboxDemo::new(window, cx)).into(), - "status-dot" => cx.new(|_| StatusDotDemo).into(), - "checkbox" => cx.new(|_| CheckboxDemo { checked: false }).into(), - "radio" => cx - .new(|_| RadioDemo { - plan: SharedString::from("starter"), - }) - .into(), - "switch" => cx.new(|_| SwitchDemo { checked: true }).into(), - "toggle" => cx.new(|_| ToggleDemo { pressed: false }).into(), - "slider" => cx.new(|_| SliderDemo { volume: 40.0 }).into(), - "segmented" => cx - .new(|_| SegmentedDemo { - filter: ExploreFilter::default(), - }) - .into(), - "select" => cx - .new(|_| SelectDemo { - strategy: Some(Strategy::Curated), - }) - .into(), - "link" => cx.new(|_| LinkDemo { clicks: 0 }).into(), - "clipboard" => cx.new(|_| ClipboardDemo).into(), - "badge" => cx.new(|_| BadgeDemo).into(), - "avatar" => cx.new(|_| AvatarDemo).into(), - "progress" => cx.new(|_| ProgressDemo).into(), - "spinner" => cx.new(|_| SpinnerDemo).into(), - "list" => cx.new(|_| ListDemo { selected: None }).into(), - "tree" => cx - .new(|_| TreeDemo { - nodes: TreeDemo::demo(), - selected: None, - }) - .into(), - "tabs" => cx - .new(|_| TabsDemo { - selected: 0, - pill_tabs: vec![ - SharedString::from("Explorer"), - SharedString::from("Syncing"), - SharedString::from("Blame"), - ], - pill_selected: 0, - lead_selected: 0, - overflow_selected: 0, - overflow_open: false, - }) - .into(), - "alert" => cx - .new(|_| AlertDemo { - alerts: self.alerts.clone(), - dismissed: false, - }) - .into(), - "toast" => cx - .new(|_| ToastDemo { - toasts: self.toasts.clone(), - }) - .into(), - "dialog" => cx.new(|_| DialogDemo { gallery }).into(), + ) -> Option> { + let panel: Arc = match id { + "welcome" => Arc::new(cx.new(|_| WelcomePanel { gallery })), + "button" => Arc::new(cx.new(|_| ButtonDemo { clicks: 0 })), + "input" => Arc::new(cx.new(InputDemo::new)), + "field" => Arc::new(cx.new(|cx| FieldDemo::new(window, cx))), + "combobox" => Arc::new(cx.new(|cx| ComboboxDemo::new(window, cx))), + "status-dot" => Arc::new(cx.new(|_| StatusDotDemo)), + "checkbox" => Arc::new(cx.new(|_| CheckboxDemo { checked: false })), + "radio" => Arc::new(cx.new(|_| RadioDemo { + plan: SharedString::from("starter"), + })), + "switch" => Arc::new(cx.new(|_| SwitchDemo { checked: true })), + "toggle" => Arc::new(cx.new(|_| ToggleDemo { pressed: false })), + "slider" => Arc::new(cx.new(|_| SliderDemo { volume: 40.0 })), + "segmented" => Arc::new(cx.new(|_| SegmentedDemo { + filter: ExploreFilter::default(), + })), + "select" => Arc::new(cx.new(|_| SelectDemo { + strategy: Some(Strategy::Curated), + })), + "link" => Arc::new(cx.new(|_| LinkDemo { clicks: 0 })), + "clipboard" => Arc::new(cx.new(|_| ClipboardDemo)), + "badge" => Arc::new(cx.new(|_| BadgeDemo)), + "avatar" => Arc::new(cx.new(|_| AvatarDemo)), + "progress" => Arc::new(cx.new(|_| ProgressDemo)), + "spinner" => Arc::new(cx.new(|_| SpinnerDemo)), + "list" => Arc::new(cx.new(|_| ListDemo { selected: None })), + "tree" => Arc::new(cx.new(|_| TreeDemo { + nodes: TreeDemo::demo(), + selected: None, + })), + "tabs" => Arc::new(cx.new(|_| TabsDemo { + selected: 0, + pill_tabs: vec![ + SharedString::from("Explorer"), + SharedString::from("Syncing"), + SharedString::from("Blame"), + ], + pill_selected: 0, + lead_selected: 0, + overflow_selected: 0, + overflow_open: false, + })), + "alert" => Arc::new(cx.new(|_| AlertDemo { + alerts: self.alerts.clone(), + dismissed: false, + })), + "toast" => Arc::new(cx.new(|_| ToastDemo { + toasts: self.toasts.clone(), + })), + "dialog" => Arc::new(cx.new(|_| DialogDemo { gallery })), "command-palette" => { let palette = self.palette.clone()?; - cx.new(|cx| CommandPaletteDemo::new(gallery, palette, cx)) - .into() + Arc::new(cx.new(|cx| CommandPaletteDemo::new(gallery, palette, cx))) } - "menu" => cx.new(|_| MenuDemo { open: false }).into(), - "dropdown-menu" => cx - .new(|_| DropdownMenuDemo { - open_menu: None, - status: None, - }) - .into(), - "context-menu" => cx - .new(|_| ContextMenuDemo { - action: SharedString::from("Right-click the card"), - }) - .into(), - "popover" => cx.new(|_| PopoverDemo { open: false }).into(), - "tooltip" => cx.new(|_| TooltipDemo).into(), - "empty-state" => cx.new(|_| EmptyStateDemo).into(), - "scroll-area" => cx.new(|_| ScrollAreaDemo).into(), - "scrollbar" => cx.new(|_| ScrollbarDemo::new()).into(), - "code-view" => cx.new(CodeViewDemo::new).into(), - "diff-view" => cx.new(DiffViewDemo::new).into(), - "markdown-view" => cx.new(MarkdownViewDemo::new).into(), - "text-view" => cx.new(TextViewDemo::new).into(), - "sidebar" => cx.new(|_| SidebarDemo { selected: None }).into(), - "resize-handle" => cx - .new(|_| ResizeDemo { - width: rems(ResizeDemo::WIDTH_DEFAULT_REMS).to_pixels(window.rem_size()), - }) - .into(), - "resizable" => cx.new(ResizableDemo::new).into(), - "separator" => cx.new(|_| SeparatorDemo).into(), - "theme" => cx.new(|_| ThemeDemo).into(), + "menu" => Arc::new(cx.new(|_| MenuDemo { open: false })), + "dropdown-menu" => Arc::new(cx.new(|_| DropdownMenuDemo { + open_menu: None, + status: None, + })), + "context-menu" => Arc::new(cx.new(|_| ContextMenuDemo { + action: SharedString::from("Right-click the card"), + })), + "popover" => Arc::new(cx.new(|_| PopoverDemo { open: false })), + "tooltip" => Arc::new(cx.new(|_| TooltipDemo)), + "empty-state" => Arc::new(cx.new(|_| EmptyStateDemo)), + "scroll-area" => Arc::new(cx.new(|_| ScrollAreaDemo)), + "scrollbar" => Arc::new(cx.new(|_| ScrollbarDemo::new())), + "code-view" => Arc::new(cx.new(CodeViewDemo::new)), + "diff-view" => Arc::new(cx.new(DiffViewDemo::new)), + "markdown-view" => Arc::new(cx.new(MarkdownViewDemo::new)), + "text-view" => Arc::new(cx.new(TextViewDemo::new)), + "sidebar" => Arc::new(cx.new(|_| SidebarDemo { selected: None })), + "resize-handle" => Arc::new(cx.new(|_| ResizeDemo { + width: rems(ResizeDemo::WIDTH_DEFAULT_REMS).to_pixels(window.rem_size()), + })), + "resizable" => Arc::new(cx.new(ResizableDemo::new)), + "separator" => Arc::new(cx.new(|_| SeparatorDemo)), + "theme" => Arc::new(cx.new(|_| ThemeDemo)), _ => return None, }; - Some(view) + Some(panel) } } @@ -698,6 +677,8 @@ struct WelcomePanel { gallery: WeakEntity, } +impl Panel for WelcomePanel {} + impl Render for WelcomePanel { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -806,6 +787,8 @@ struct RightDetails { body: SharedString, } +impl Panel for RightDetails {} + impl Render for RightDetails { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -841,6 +824,8 @@ impl ButtonDemo { } } +impl Panel for ButtonDemo {} + impl Render for ButtonDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1005,6 +990,8 @@ impl InputDemo { } } +impl Panel for InputDemo {} + impl Render for InputDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1089,6 +1076,8 @@ impl FieldDemo { } } +impl Panel for FieldDemo {} + impl Render for FieldDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1161,6 +1150,8 @@ impl Render for FieldDemo { struct StatusDotDemo; +impl Panel for StatusDotDemo {} + impl Render for StatusDotDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1329,6 +1320,8 @@ impl ComboboxDemo { } } +impl Panel for ComboboxDemo {} + impl Render for ComboboxDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1398,6 +1391,8 @@ struct CheckboxDemo { checked: bool, } +impl Panel for CheckboxDemo {} + impl Render for CheckboxDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1440,6 +1435,8 @@ struct RadioDemo { plan: SharedString, } +impl Panel for RadioDemo {} + impl Render for RadioDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1476,6 +1473,8 @@ struct SwitchDemo { checked: bool, } +impl Panel for SwitchDemo {} + impl Render for SwitchDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1518,6 +1517,8 @@ struct ToggleDemo { pressed: bool, } +impl Panel for ToggleDemo {} + impl Render for ToggleDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1555,6 +1556,8 @@ struct SliderDemo { volume: f32, } +impl Panel for SliderDemo {} + impl Render for SliderDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1592,6 +1595,8 @@ struct SegmentedDemo { filter: ExploreFilter, } +impl Panel for SegmentedDemo {} + impl Render for SegmentedDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1674,6 +1679,8 @@ struct SelectDemo { strategy: Option, } +impl Panel for SelectDemo {} + impl Render for SelectDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1722,6 +1729,8 @@ struct LinkDemo { clicks: usize, } +impl Panel for LinkDemo {} + impl Render for LinkDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -1770,6 +1779,8 @@ impl Render for LinkDemo { struct ClipboardDemo; +impl Panel for ClipboardDemo {} + impl Render for ClipboardDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1804,6 +1815,8 @@ impl Render for ClipboardDemo { struct SeparatorDemo; +impl Panel for SeparatorDemo {} + impl Render for SeparatorDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1856,6 +1869,8 @@ impl ResizableDemo { } } +impl Panel for ResizableDemo {} + impl Render for ResizableDemo { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1895,6 +1910,8 @@ impl Render for ResizableDemo { struct BadgeDemo; +impl Panel for BadgeDemo {} + impl Render for BadgeDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1932,6 +1949,8 @@ impl Render for BadgeDemo { struct AvatarDemo; +impl Panel for AvatarDemo {} + impl Render for AvatarDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1967,6 +1986,8 @@ impl Render for AvatarDemo { struct ProgressDemo; +impl Panel for ProgressDemo {} + impl Render for ProgressDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -1992,6 +2013,8 @@ impl Render for ProgressDemo { struct SpinnerDemo; +impl Panel for SpinnerDemo {} + impl Render for SpinnerDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -2034,6 +2057,8 @@ struct ListDemo { selected: Option, } +impl Panel for ListDemo {} + impl Render for ListDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2209,6 +2234,8 @@ impl TreeDemo { } } +impl Panel for TreeDemo {} + impl Render for TreeDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2252,6 +2279,8 @@ struct TabsDemo { overflow_open: bool, } +impl Panel for TabsDemo {} + impl Render for TabsDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2427,6 +2456,8 @@ struct AlertDemo { dismissed: bool, } +impl Panel for AlertDemo {} + impl Render for AlertDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2519,6 +2550,8 @@ struct ToastDemo { toasts: Entity, } +impl Panel for ToastDemo {} + impl Render for ToastDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let toasts_undo = self.toasts.clone(); @@ -2589,6 +2622,8 @@ struct DialogDemo { gallery: WeakEntity, } +impl Panel for DialogDemo {} + impl Render for DialogDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let gallery_dialog = self.gallery.clone(); @@ -2655,6 +2690,8 @@ impl CommandPaletteDemo { } } +impl Panel for CommandPaletteDemo {} + impl Render for CommandPaletteDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -2721,6 +2758,8 @@ struct MenuDemo { open: bool, } +impl Panel for MenuDemo {} + impl Render for MenuDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2792,6 +2831,8 @@ impl DropdownMenuDemo { } } +impl Panel for DropdownMenuDemo {} + impl Render for DropdownMenuDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2943,6 +2984,8 @@ struct ContextMenuDemo { action: SharedString, } +impl Panel for ContextMenuDemo {} + impl Render for ContextMenuDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -2998,6 +3041,8 @@ struct PopoverDemo { open: bool, } +impl Panel for PopoverDemo {} + impl Render for PopoverDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -3039,6 +3084,8 @@ impl Render for PopoverDemo { struct TooltipDemo; +impl Panel for TooltipDemo {} + impl Render for TooltipDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -3084,6 +3131,8 @@ impl Render for TooltipDemo { struct EmptyStateDemo; +impl Panel for EmptyStateDemo {} + impl Render for EmptyStateDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let theme = cx.theme(); @@ -3130,6 +3179,8 @@ impl Render for EmptyStateDemo { struct ScrollAreaDemo; +impl Panel for ScrollAreaDemo {} + impl Render for ScrollAreaDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let theme = cx.theme(); @@ -3212,6 +3263,8 @@ impl ScrollbarDemo { } } +impl Panel for ScrollbarDemo {} + impl Render for ScrollbarDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let theme = cx.theme(); @@ -3421,6 +3474,8 @@ impl CodeViewDemo { } } +impl Panel for CodeViewDemo {} + impl Render for CodeViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -3591,6 +3646,8 @@ impl DiffViewDemo { } } +impl Panel for DiffViewDemo {} + impl Render for DiffViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -3811,6 +3868,8 @@ impl MarkdownViewDemo { } } +impl Panel for MarkdownViewDemo {} + impl Render for MarkdownViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -3887,6 +3946,8 @@ impl TextViewDemo { } } +impl Panel for TextViewDemo {} + impl Render for TextViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let colors = cx.theme().colors; @@ -3934,6 +3995,8 @@ struct SidebarDemo { selected: Option, } +impl Panel for SidebarDemo {} + impl Render for SidebarDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -4102,6 +4165,8 @@ impl ResizeDemo { const WIDTH_MAX_REMS: f32 = 20.; } +impl Panel for ResizeDemo {} + impl Render for ResizeDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let view = cx.entity(); @@ -4180,6 +4245,8 @@ impl Render for ResizeDemo { struct ThemeDemo; +impl Panel for ThemeDemo {} + impl Render for ThemeDemo { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let theme = cx.theme();