settings_container.rs

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