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