settings_container.rs

 1use gpui::AnyElement;
 2use smallvec::SmallVec;
 3
 4use crate::prelude::*;
 5
 6#[derive(IntoElement)]
 7pub struct SettingsContainer {
 8    children: SmallVec<[AnyElement; 2]>,
 9}
10
11impl Default for SettingsContainer {
12    fn default() -> Self {
13        Self::new()
14    }
15}
16
17impl SettingsContainer {
18    pub fn new() -> Self {
19        Self {
20            children: SmallVec::new(),
21        }
22    }
23}
24
25impl ParentElement for SettingsContainer {
26    fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
27        self.children.extend(elements)
28    }
29}
30
31impl RenderOnce for SettingsContainer {
32    fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
33        v_flex().px_2().gap_1().children(self.children)
34    }
35}