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