Skip to main content

gpui_component/list/
separator_item.rs

1use gpui::{AnyElement, ParentElement, RenderOnce, StyleRefinement};
2use smallvec::SmallVec;
3
4use crate::{Selectable, StyledExt, list::ListItem};
5
6pub struct ListSeparatorItem {
7    style: StyleRefinement,
8    children: SmallVec<[AnyElement; 2]>,
9}
10
11impl ListSeparatorItem {
12    pub fn new() -> Self {
13        Self {
14            style: StyleRefinement::default(),
15            children: SmallVec::new(),
16        }
17    }
18}
19
20impl ParentElement for ListSeparatorItem {
21    fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
22        self.children.extend(elements);
23    }
24}
25
26impl Selectable for ListSeparatorItem {
27    fn selected(self, _: bool) -> Self {
28        self
29    }
30
31    fn is_selected(&self) -> bool {
32        false
33    }
34}
35
36impl RenderOnce for ListSeparatorItem {
37    fn render(self, _: &mut gpui::Window, _: &mut gpui::App) -> impl gpui::IntoElement {
38        ListItem::new("separator")
39            .refine_style(&self.style)
40            .children(self.children)
41            .disabled(true)
42    }
43}