From daca373f77b49277835c1b17d1b9f81cb4c8f48e Mon Sep 17 00:00:00 2001 From: Ren Amamiya Date: Sun, 15 Nov 2026 14:50:48 +0700 Subject: [PATCH] tabs: collapse same-kind tabs into group chips --- crates/data/src/tabs.rs | 350 +++++++++++++++++++++++++++++++---- crates/data/tests/tabs.rs | 96 ++++++++++ crates/layout/src/panel.rs | 35 ++-- docs/CHECKLIST.md | 5 + examples/gallery/src/main.rs | 272 ++++++++++++++++++++++----- 5 files changed, 668 insertions(+), 90 deletions(-) create mode 100644 crates/data/tests/tabs.rs diff --git a/crates/data/src/tabs.rs b/crates/data/src/tabs.rs index b48c6f4..3228a35 100644 --- a/crates/data/src/tabs.rs +++ b/crates/data/src/tabs.rs @@ -79,6 +79,33 @@ impl TabsMeasurements { } } +/// One slot of a strip: a lone tab, or same-kind tabs collapsed into a group chip. +enum StripItem { + /// A tab outside any two-member kind group, at its original index. + Single(usize, Tab), + /// Tabs of one kind collapsed into a chip, at the first member's index. + Group { + kind: SharedString, + /// The collapsed tabs with their original indices. + members: Vec<(usize, Tab)>, + }, +} + +impl StripItem { + /// The key the strip's geometry records the item under. + fn measure_key(&self, tabs_id: &ElementId) -> String { + match self { + StripItem::Single(_, tab) => tab.key.to_string(), + StripItem::Group { kind, .. } => group_key(tabs_id, kind).to_string(), + } + } +} + +/// The group chip's identity for one strip and kind. +fn group_key(tabs_id: &ElementId, kind: &SharedString) -> ElementId { + SharedString::from(format!("{tabs_id}-tabs-group-{kind}")).into() +} + /// The visual language of a [`Tabs`] strip. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub enum TabsVariant { @@ -97,6 +124,7 @@ pub struct Tab { busy: bool, disabled: bool, closeable: bool, + kind: Option, wrap: Option, } @@ -114,6 +142,7 @@ impl Tab { busy: false, disabled: false, closeable: false, + kind: None, wrap: None, } } @@ -145,6 +174,15 @@ impl Tab { self } + /// Sets the kind the tab belongs to; same-kind tabs collapse into one group. + pub fn kind(mut self, kind: K) -> Self + where + K: Into, + { + self.kind = Some(kind.into()); + self + } + /// Hands the rendered tab through `wrap`, e.g. to attach a drag payload. pub fn wrap(mut self, wrap: F) -> Self where @@ -271,13 +309,13 @@ impl Tabs { self } - /// The number of tabs that fit before the popover trigger, from last frame's geometry. - fn inline_count(tabs: &[Tab], measure: &StripMeasure) -> usize { + /// The number of items that fit before the popover trigger, from last frame's geometry. + fn inline_count(tabs_id: &ElementId, items: &[StripItem], measure: &StripMeasure) -> usize { let limit = measure.container_width - measure.trigger_width.unwrap_or(Pixels::ZERO); let mut count = 0; - for tab in tabs { - let Some(entry) = measure.tabs.get(&tab.key.to_string()) else { - return tabs.len(); + for item in items { + let Some(entry) = measure.tabs.get(&item.measure_key(tabs_id)) else { + return items.len(); }; if entry.left + entry.width > limit { break; @@ -290,8 +328,7 @@ impl Tabs { #[allow(clippy::too_many_arguments)] fn render_overflow_popover( id: &ElementId, - overflow_tabs: Vec, - inline_count: usize, + overflow_items: Vec, selected_index: usize, variant: TabsVariant, open: bool, @@ -344,11 +381,10 @@ impl Tabs { .into_any_element() }) .content(move |_, cx| { - let rows: Vec = overflow_tabs + let rows: Vec = overflow_items .into_iter() - .zip(inline_count..) - .map(|(tab, index)| { - tab.render_tab( + .flat_map(|item| match item { + StripItem::Single(index, tab) => vec![tab.render_tab( &id, cx, index, @@ -358,35 +394,264 @@ impl Tabs { &on_close, &focus, None, + )], + StripItem::Group { members, .. } => members + .into_iter() + .map(|(index, tab)| { + tab.render_tab( + &id, + cx, + index, + selected_index, + variant, + &row_change, + &on_close, + &focus, + None, + ) + }) + .collect::>(), + }) + .collect(); + + ScrollArea::new((id.clone(), "tabs-overflow-list")) + .axes(ScrollAxes::Vertical) + .max_h(POPUP_MAX_HEIGHT) + .child(v_flex().gap_0p5().p_1().children(rows)) + .into_any_element() + }) + } + + /// Collapses same-kind tabs (two or more) into group chips, keeping strip order. + fn group_by_kind(tabs: Vec) -> Vec { + let mut counts: HashMap = HashMap::new(); + for tab in &tabs { + if let Some(kind) = &tab.kind { + *counts.entry(kind.clone()).or_default() += 1; + } + } + + let mut items: Vec = Vec::new(); + let mut group_slots: HashMap = HashMap::new(); + + for (index, tab) in tabs.into_iter().enumerate() { + let grouped_kind = tab + .kind + .clone() + .filter(|kind| counts.get(kind).copied().unwrap_or(0) >= 2); + + match grouped_kind { + Some(kind) => match group_slots.get(&kind).copied() { + Some(slot) => { + if let StripItem::Group { members, .. } = &mut items[slot] { + members.push((index, tab)); + } + } + None => { + group_slots.insert(kind.clone(), items.len()); + items.push(StripItem::Group { + kind, + members: vec![(index, tab)], + }); + } + }, + None => items.push(StripItem::Single(index, tab)), + } + } + + items + } + + /// Renders a group chip labeled with the kind and its member count. + #[allow(clippy::too_many_arguments)] + fn render_group_tab( + tabs_id: &ElementId, + kind: SharedString, + members: Vec<(usize, Tab)>, + selected_index: usize, + variant: TabsVariant, + on_change: Option, + on_close: Option, + focus: &gpui::FocusHandle, + measure: Option<&MeasureFrame>, + window: &mut Window, + cx: &mut App, + ) -> AnyElement { + let tabs_id = tabs_id.clone(); + let focus = focus.clone(); + let count = members.len(); + let selected = members.iter().any(|(index, _)| *index == selected_index); + + let open = window + .use_keyed_state((group_key(&tabs_id, &kind), "open"), cx, |_, _| false) + .clone(); + + let theme = cx.theme(); + let metrics = theme.sizes.resolve(Size::default()); + let small = theme.sizes.small; + + let label_color = match variant { + TabsVariant::Underline => { + if selected { + theme.ramps.primary.base + } else { + theme.colors.foreground + } + } + TabsVariant::Pill => theme.colors.foreground, + }; + + let group_key = group_key(&tabs_id, &kind); + let chip = div() + .id((group_key.clone(), "group-tab")) + .debug_selector({ + let tabs_id = tabs_id.clone(); + let label = kind.clone(); + move || format!("{tabs_id}-group-{label}") + }) + .flex() + .items_center() + .gap_1p5() + .cursor_pointer() + .role(Role::Tab) + .aria_selected(selected) + .aria_label(SharedString::from(format!("{kind}, {count} tabs"))) + .text_color(label_color) + .when(!selected, |chip| { + chip.hover(|chip| chip.bg(theme.colors.muted)) + }) + .map(|chip| match variant { + TabsVariant::Underline => chip + .px_2() + .py_1() + .rounded_tl(theme.radius.sm) + .rounded_tr(theme.radius.sm) + .border_b_2() + .border_color(gpui::transparent_black()) + .when(selected, |chip| chip.border_color(theme.ramps.primary.base)), + TabsVariant::Pill => chip + .h(small.control_height + metrics.plate_inset * 2.0) + .px(metrics.dense_padding_x) + .pr(metrics.plate_inset) + .rounded(theme.radius.control) + .when(selected, |chip| { + chip.bg(theme.colors.background) + .shadow(theme.elevations.control.shadows()) + }), + }) + .child(SharedString::from(format!("{kind} ({count})"))) + .when(variant == TabsVariant::Pill, |chip| { + chip.child(div().flex_none().w(metrics.padding_x * 1.5)) + }) + .when_some(measure, |chip, measure| { + let key = measure.key.clone(); + let root_bounds = measure.root_bounds.clone(); + let item_key = group_key.to_string(); + chip.child( + canvas( + move |bounds, _, cx| { + let root = root_bounds.borrow(); + if let Some(root) = root.as_ref() { + cx.default_global::().record_tab( + &key, + item_key, + TabMeasure { + left: bounds.origin.x - root.origin.x, + width: bounds.size.width, + }, + ); + } + }, + |_, _, _, _| {}, + ) + .absolute() + .inset_0(), + ) + }); + + // Selecting a row also dismisses the popover, mirroring the overflow popover. + let row_change: Option = { + let open = open.clone(); + Some(Rc::new(move |index, window, cx| { + open.update(cx, |open, cx| { + *open = false; + cx.notify(); + }); + if let Some(on_change) = &on_change { + on_change(index, window, cx); + } + })) + }; + + Popover::new((group_key.clone(), "group-popover")) + .open(*open.read(cx)) + .on_change({ + let open = open.clone(); + move |next, _, cx| { + open.update(cx, |open, cx| { + *open = next; + cx.notify(); + }); + } + }) + .trigger(move |_, _| chip.into_any_element()) + .content(move |_, cx| { + let rows: Vec = members + .into_iter() + .map(|(index, tab)| { + tab.render_tab( + &tabs_id, + cx, + index, + selected_index, + variant, + &row_change, + &on_close, + &focus, + None, ) }) .collect(); - ScrollArea::new((id.clone(), "tabs-overflow-list")) + ScrollArea::new((group_key.clone(), "tabs-group-list")) .axes(ScrollAxes::Vertical) .max_h(POPUP_MAX_HEIGHT) .child(v_flex().gap_0p5().p_1().children(rows)) .into_any_element() }) + .into_any_element() } } impl RenderOnce for Tabs { fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement { - let mut tabs = match self.tabs { + let tabs = match self.tabs { Some(build) => build(window, cx), None => Vec::new(), }; + let mut items = Self::group_by_kind(tabs); - let selectable: Vec = tabs + let selectable: Vec = items .iter() - .enumerate() - .filter(|(_, tab)| !tab.disabled) - .map(|(index, _)| index) + .flat_map(|item| match item { + StripItem::Single(index, tab) => (!tab.disabled) + .then_some(*index) + .into_iter() + .collect::>(), + StripItem::Group { members, .. } => members + .iter() + .filter(|(_, tab)| !tab.disabled) + .map(|(index, _)| *index) + .collect::>(), + }) .collect(); let focus = gpui_native_utils::focus_handle(&self.id, window, cx); - let theme = cx.theme(); + // Theme reads end here, so the strip's group chips can take `cx` mutably. + let (medium_text_size, border_color) = { + let theme = cx.theme(); + (theme.sizes.medium.text_size, theme.colors.border) + }; let label = self .a11y_label @@ -407,20 +672,19 @@ impl RenderOnce for Tabs { let inline_count = measure .as_ref() - .map(|measure| Self::inline_count(&tabs, measure)) - .unwrap_or(tabs.len()); - let overflow_tabs = tabs.split_off(inline_count); + .map(|measure| Self::inline_count(&self.id, &items, measure)) + .unwrap_or(items.len()); + let overflow_items = items.split_off(inline_count); let measure_frame = self.overflow_popover.then(|| MeasureFrame { key: measure_key.clone(), root_bounds: Rc::new(RefCell::new(None)), }); - let strip: Vec = tabs + let strip: Vec = items .into_iter() - .enumerate() - .map(|(index, tab)| { - tab.render_tab( + .map(|item| match item { + StripItem::Single(index, tab) => tab.render_tab( &self.id, cx, index, @@ -430,16 +694,28 @@ impl RenderOnce for Tabs { &self.on_close, &focus, measure_frame.as_ref(), - ) + ), + StripItem::Group { kind, members } => Self::render_group_tab( + &self.id, + kind, + members, + self.selected, + self.variant, + self.on_change.clone(), + self.on_close.clone(), + &focus, + measure_frame.as_ref(), + window, + cx, + ), }) .collect(); - let popover = (self.overflow_popover && measure.is_some() && !overflow_tabs.is_empty()) + let popover = (self.overflow_popover && measure.is_some() && !overflow_items.is_empty()) .then(|| { Self::render_overflow_popover( &self.id, - overflow_tabs, - inline_count, + overflow_items, self.selected, self.variant, self.overflow_open, @@ -453,7 +729,7 @@ impl RenderOnce for Tabs { div() .id(self.id.clone()) .flex() - .text_size(theme.sizes.medium.text_size) + .text_size(medium_text_size) .track_focus(&focus) .focusable() .tab_stop(true) @@ -480,9 +756,7 @@ impl RenderOnce for Tabs { } }) .map(|root| match self.variant { - TabsVariant::Underline => { - root.gap_1().border_b_1().border_color(theme.colors.border) - } + TabsVariant::Underline => root.gap_1().border_b_1().border_color(border_color), TabsVariant::Pill => root.items_center().gap_1(), }) .map(|root| { @@ -629,10 +903,16 @@ impl Tab { .px(metrics.dense_padding_x) .pr(metrics.plate_inset) .rounded(theme.radius.control) - .when(selected, |strip_tab| strip_tab.bg(theme.colors.muted_hover)), + // The active tab is a small island: the panel's fill, with + // the platform's control shadow lifting it off the strip. + .when(selected, |strip_tab| { + strip_tab + .bg(theme.colors.background) + .shadow(theme.elevations.control.shadows()) + }), }) .when_some(self.lead.take(), |strip_tab, lead| strip_tab.child(lead)) - .child(self.label.clone()) + .child(div().flex_grow(1.0).child(self.label.clone())) .when(variant == TabsVariant::Pill, |strip_tab| { strip_tab.child(div().flex_none().w(metrics.padding_x * 1.5)) }) diff --git a/crates/data/tests/tabs.rs b/crates/data/tests/tabs.rs new file mode 100644 index 0000000..75b0184 --- /dev/null +++ b/crates/data/tests/tabs.rs @@ -0,0 +1,96 @@ +#![cfg(feature = "tabs")] + +//! Grouped tabs: same-kind tabs collapse into one chip that opens a popover +//! listing the members; picking one selects it by its original index. + +use std::cell::RefCell; +use std::rc::Rc; + +use gpui::{ + Context, IntoElement, Modifiers, ParentElement as _, Render, Styled as _, TestAppContext, + VisualTestContext, Window, div, px, size, +}; +use gpui_native_data::tabs::{Tab, Tabs, TabsVariant}; +use gpui_native_theme::Theme; + +struct StripHarness { + changed: Rc>>, +} + +impl Render for StripHarness { + fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { + let changed = self.changed.clone(); + div().size_full().child( + Tabs::new("strip") + .variant(TabsVariant::Pill) + .tabs(|_, _| { + vec![ + Tab::new("a", "Alpha").kind("Kind"), + Tab::new("b", "Beta").kind("Kind"), + Tab::new("c", "Gamma"), + Tab::new("d", "Delta").kind("Lone"), + ] + }) + .on_change(move |index, _, _| changed.borrow_mut().push(index)), + ) + } +} + +fn strip_window(cx: &mut TestAppContext, changed: Rc>>) -> VisualTestContext { + cx.update(Theme::init); + let window = cx.open_window(size(px(800.), px(600.)), |_, _| StripHarness { changed }); + let cx = VisualTestContext::from_window(window.into(), cx); + cx.run_until_parked(); + cx +} + +#[gpui::test] +fn same_kind_tabs_collapse_into_one_group(cx: &mut TestAppContext) { + let mut cx = strip_window(cx, Rc::new(RefCell::new(Vec::new()))); + + assert!( + cx.debug_bounds("strip-group-Kind").is_some(), + "two same-kind tabs draw one group chip" + ); + assert!( + cx.debug_bounds("strip-tab-Alpha").is_none(), + "grouped members do not draw inline" + ); + assert!(cx.debug_bounds("strip-tab-Beta").is_none()); + + // A tab outside any two-member kind group draws itself, kinded or not. + assert!(cx.debug_bounds("strip-tab-Gamma").is_some()); + assert!(cx.debug_bounds("strip-tab-Delta").is_some()); + assert!( + cx.debug_bounds("strip-group-Lone").is_none(), + "a lone kinded tab is not grouped" + ); +} + +#[gpui::test] +fn picking_a_group_member_selects_it(cx: &mut TestAppContext) { + let changed = Rc::new(RefCell::new(Vec::new())); + let mut cx = strip_window(cx, changed.clone()); + + let chip = cx + .debug_bounds("strip-group-Kind") + .expect("group chip drawn"); + cx.simulate_click(chip.center(), Modifiers::none()); + cx.run_until_parked(); + + let beta = cx + .debug_bounds("strip-tab-Beta") + .expect("the popover lists the members"); + cx.simulate_click(beta.center(), Modifiers::none()); + cx.run_until_parked(); + + assert_eq!( + changed.borrow().as_slice(), + &[1], + "picking a member reports its original index" + ); + assert!( + cx.debug_bounds("strip-tab-Beta").is_none(), + "a selection dismisses the popover" + ); +} diff --git a/crates/layout/src/panel.rs b/crates/layout/src/panel.rs index 94f9c1e..10dae46 100644 --- a/crates/layout/src/panel.rs +++ b/crates/layout/src/panel.rs @@ -7,30 +7,51 @@ use std::sync::Arc; use gpui::{ AnyElement, AnyView, App, Axis, Div, ElementId, Entity, IntoElement, ParentElement as _, - Render, RenderOnce, StyleRefinement, Styled as _, Window, div, rems, + Render, RenderOnce, SharedString, StyleRefinement, Styled as _, Window, div, rems, }; use gpui_native_theme::ActiveTheme as _; use crate::resizable::{Resizable, ResizableState}; -pub trait Panel: Render + 'static {} +/// A user-defined panel the row can show. +#[allow(unused_variables)] +pub trait Panel: Render + 'static { + /// The kind the panel belongs to; same-kind panels group in the tab bar. + fn kind(&self, cx: &App) -> Option { + None + } +} /// An object-safe handle to a panel, so apps can hold panels by kind. +#[allow(unused_variables)] pub trait PanelView: 'static { /// The panel's view. fn view(&self) -> AnyView; + + /// The panel's kind, read live from the panel. + fn kind(&self, cx: &App) -> Option { + None + } } impl PanelView for Entity { fn view(&self) -> AnyView { self.clone().into() } + + fn kind(&self, cx: &App) -> Option { + self.read(cx).kind(cx) + } } impl PanelView for Arc

{ fn view(&self) -> AnyView { (**self).view() } + + fn kind(&self, cx: &App) -> Option { + (**self).kind(cx) + } } /// The layout the cached panel content lays out with. @@ -131,14 +152,6 @@ impl RenderOnce for PanelRow { None => div().w_full().h_full().child(main), }; - div() - .flex_1() - .min_w_0() - .h_full() - // the titlebar's centered tabs leave slack above the strip's - // bottom edge, so the top gutter is narrower to even out. - .p_2() - .pt_1() - .child(row) + div().flex_1().min_w_0().h_full().p_2().pt_1().child(row) } } diff --git a/docs/CHECKLIST.md b/docs/CHECKLIST.md index 6d2e53c..f807742 100644 --- a/docs/CHECKLIST.md +++ b/docs/CHECKLIST.md @@ -199,6 +199,11 @@ Gaps surfaced by the signed comparison; ordered by signed's usage. - [x] List, Tree, Tabs (underline default + signed pill), Sidebar (scrolls internally) +- [x] Tab kind groups — tabs carrying the same `Tab::kind` (two or more) + collapse into one chip labeled with the kind and its member count; + clicking it opens a popover listing the members vertically, and picking + one reports its original index through `on_change`/`on_close`; lone + kinded tabs stay inline, and the chip composes with both overflow modes ### editor (`crates/editor`) diff --git a/examples/gallery/src/main.rs b/examples/gallery/src/main.rs index 1fd543b..c7e7616 100644 --- a/examples/gallery/src/main.rs +++ b/examples/gallery/src/main.rs @@ -290,9 +290,21 @@ impl Gallery { .selected(selected) .tabs({ let tabs = self.tabs.clone(); + let kinds: Vec> = self + .tabs + .iter() + .map(|id| self.views.get(id).and_then(|panel| panel.kind(cx))) + .collect(); move |_, _| { tabs.iter() - .map(|id| Tab::new(id.clone(), Self::label_of(id)).closeable(true)) + .zip(kinds.iter()) + .map(|(id, kind)| { + let tab = Tab::new(id.clone(), Self::label_of(id)).closeable(true); + match kind { + Some(kind) => tab.kind(kind.clone()), + None => tab, + } + }) .collect() } }) @@ -677,7 +689,11 @@ struct WelcomePanel { gallery: WeakEntity, } -impl Panel for WelcomePanel {} +impl Panel for WelcomePanel { + fn kind(&self, _: &App) -> Option { + Some("Layout".into()) + } +} impl Render for WelcomePanel { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -824,7 +840,11 @@ impl ButtonDemo { } } -impl Panel for ButtonDemo {} +impl Panel for ButtonDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for ButtonDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -990,7 +1010,11 @@ impl InputDemo { } } -impl Panel for InputDemo {} +impl Panel for InputDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for InputDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1076,7 +1100,11 @@ impl FieldDemo { } } -impl Panel for FieldDemo {} +impl Panel for FieldDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for FieldDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1150,7 +1178,11 @@ impl Render for FieldDemo { struct StatusDotDemo; -impl Panel for StatusDotDemo {} +impl Panel for StatusDotDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for StatusDotDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1320,7 +1352,11 @@ impl ComboboxDemo { } } -impl Panel for ComboboxDemo {} +impl Panel for ComboboxDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for ComboboxDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1391,7 +1427,11 @@ struct CheckboxDemo { checked: bool, } -impl Panel for CheckboxDemo {} +impl Panel for CheckboxDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for CheckboxDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1435,7 +1475,11 @@ struct RadioDemo { plan: SharedString, } -impl Panel for RadioDemo {} +impl Panel for RadioDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for RadioDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1473,7 +1517,11 @@ struct SwitchDemo { checked: bool, } -impl Panel for SwitchDemo {} +impl Panel for SwitchDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for SwitchDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1517,7 +1565,11 @@ struct ToggleDemo { pressed: bool, } -impl Panel for ToggleDemo {} +impl Panel for ToggleDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for ToggleDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1556,7 +1608,11 @@ struct SliderDemo { volume: f32, } -impl Panel for SliderDemo {} +impl Panel for SliderDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for SliderDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1595,7 +1651,11 @@ struct SegmentedDemo { filter: ExploreFilter, } -impl Panel for SegmentedDemo {} +impl Panel for SegmentedDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for SegmentedDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1679,7 +1739,11 @@ struct SelectDemo { strategy: Option, } -impl Panel for SelectDemo {} +impl Panel for SelectDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for SelectDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1729,7 +1793,11 @@ struct LinkDemo { clicks: usize, } -impl Panel for LinkDemo {} +impl Panel for LinkDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for LinkDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1779,7 +1847,11 @@ impl Render for LinkDemo { struct ClipboardDemo; -impl Panel for ClipboardDemo {} +impl Panel for ClipboardDemo { + fn kind(&self, _: &App) -> Option { + Some("Controls".into()) + } +} impl Render for ClipboardDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1815,7 +1887,11 @@ impl Render for ClipboardDemo { struct SeparatorDemo; -impl Panel for SeparatorDemo {} +impl Panel for SeparatorDemo { + fn kind(&self, _: &App) -> Option { + Some("Layout".into()) + } +} impl Render for SeparatorDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1869,7 +1945,11 @@ impl ResizableDemo { } } -impl Panel for ResizableDemo {} +impl Panel for ResizableDemo { + fn kind(&self, _: &App) -> Option { + Some("Layout".into()) + } +} impl Render for ResizableDemo { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1910,7 +1990,11 @@ impl Render for ResizableDemo { struct BadgeDemo; -impl Panel for BadgeDemo {} +impl Panel for BadgeDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for BadgeDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1949,7 +2033,11 @@ impl Render for BadgeDemo { struct AvatarDemo; -impl Panel for AvatarDemo {} +impl Panel for AvatarDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for AvatarDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -1986,7 +2074,11 @@ impl Render for AvatarDemo { struct ProgressDemo; -impl Panel for ProgressDemo {} +impl Panel for ProgressDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for ProgressDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2013,7 +2105,11 @@ impl Render for ProgressDemo { struct SpinnerDemo; -impl Panel for SpinnerDemo {} +impl Panel for SpinnerDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for SpinnerDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2057,7 +2153,11 @@ struct ListDemo { selected: Option, } -impl Panel for ListDemo {} +impl Panel for ListDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for ListDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2234,7 +2334,11 @@ impl TreeDemo { } } -impl Panel for TreeDemo {} +impl Panel for TreeDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for TreeDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2279,7 +2383,11 @@ struct TabsDemo { overflow_open: bool, } -impl Panel for TabsDemo {} +impl Panel for TabsDemo { + fn kind(&self, _: &App) -> Option { + Some("Data".into()) + } +} impl Render for TabsDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2456,7 +2564,11 @@ struct AlertDemo { dismissed: bool, } -impl Panel for AlertDemo {} +impl Panel for AlertDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for AlertDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2550,7 +2662,11 @@ struct ToastDemo { toasts: Entity, } -impl Panel for ToastDemo {} +impl Panel for ToastDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for ToastDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2622,7 +2738,11 @@ struct DialogDemo { gallery: WeakEntity, } -impl Panel for DialogDemo {} +impl Panel for DialogDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for DialogDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2690,7 +2810,11 @@ impl CommandPaletteDemo { } } -impl Panel for CommandPaletteDemo {} +impl Panel for CommandPaletteDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for CommandPaletteDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2758,7 +2882,11 @@ struct MenuDemo { open: bool, } -impl Panel for MenuDemo {} +impl Panel for MenuDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for MenuDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2831,7 +2959,11 @@ impl DropdownMenuDemo { } } -impl Panel for DropdownMenuDemo {} +impl Panel for DropdownMenuDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for DropdownMenuDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -2984,7 +3116,11 @@ struct ContextMenuDemo { action: SharedString, } -impl Panel for ContextMenuDemo {} +impl Panel for ContextMenuDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for ContextMenuDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3041,7 +3177,11 @@ struct PopoverDemo { open: bool, } -impl Panel for PopoverDemo {} +impl Panel for PopoverDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for PopoverDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3084,7 +3224,11 @@ impl Render for PopoverDemo { struct TooltipDemo; -impl Panel for TooltipDemo {} +impl Panel for TooltipDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for TooltipDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3131,7 +3275,11 @@ impl Render for TooltipDemo { struct EmptyStateDemo; -impl Panel for EmptyStateDemo {} +impl Panel for EmptyStateDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for EmptyStateDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3179,7 +3327,11 @@ impl Render for EmptyStateDemo { struct ScrollAreaDemo; -impl Panel for ScrollAreaDemo {} +impl Panel for ScrollAreaDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for ScrollAreaDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3263,7 +3415,11 @@ impl ScrollbarDemo { } } -impl Panel for ScrollbarDemo {} +impl Panel for ScrollbarDemo { + fn kind(&self, _: &App) -> Option { + Some("Feedback".into()) + } +} impl Render for ScrollbarDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3474,7 +3630,11 @@ impl CodeViewDemo { } } -impl Panel for CodeViewDemo {} +impl Panel for CodeViewDemo { + fn kind(&self, _: &App) -> Option { + Some("Editor".into()) + } +} impl Render for CodeViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3646,7 +3806,11 @@ impl DiffViewDemo { } } -impl Panel for DiffViewDemo {} +impl Panel for DiffViewDemo { + fn kind(&self, _: &App) -> Option { + Some("Editor".into()) + } +} impl Render for DiffViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3868,7 +4032,11 @@ impl MarkdownViewDemo { } } -impl Panel for MarkdownViewDemo {} +impl Panel for MarkdownViewDemo { + fn kind(&self, _: &App) -> Option { + Some("Editor".into()) + } +} impl Render for MarkdownViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3946,7 +4114,11 @@ impl TextViewDemo { } } -impl Panel for TextViewDemo {} +impl Panel for TextViewDemo { + fn kind(&self, _: &App) -> Option { + Some("Editor".into()) + } +} impl Render for TextViewDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -3995,7 +4167,11 @@ struct SidebarDemo { selected: Option, } -impl Panel for SidebarDemo {} +impl Panel for SidebarDemo { + fn kind(&self, _: &App) -> Option { + Some("Layout".into()) + } +} impl Render for SidebarDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -4165,7 +4341,11 @@ impl ResizeDemo { const WIDTH_MAX_REMS: f32 = 20.; } -impl Panel for ResizeDemo {} +impl Panel for ResizeDemo { + fn kind(&self, _: &App) -> Option { + Some("Layout".into()) + } +} impl Render for ResizeDemo { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { @@ -4245,7 +4425,11 @@ impl Render for ResizeDemo { struct ThemeDemo; -impl Panel for ThemeDemo {} +impl Panel for ThemeDemo { + fn kind(&self, _: &App) -> Option { + Some("Theme".into()) + } +} impl Render for ThemeDemo { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement {