1use crate::devtools::Probed;
4use gpui::prelude::*;
5use gpui::{div, px, AnyElement, App, IntoElement, Window};
6
7#[derive(IntoElement)]
9pub struct Wrap {
10 children: Vec<AnyElement>,
11 spacing: f32,
12}
13
14impl Wrap {
15 pub fn new() -> Self {
16 Wrap {
17 children: Vec::new(),
18 spacing: 8.0,
19 }
20 }
21
22 pub fn spacing(mut self, spacing: f32) -> Self {
24 self.spacing = spacing;
25 self
26 }
27}
28
29impl Default for Wrap {
30 fn default() -> Self {
31 Wrap::new()
32 }
33}
34
35impl ParentElement for Wrap {
36 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
37 self.children.extend(elements);
38 }
39}
40
41impl RenderOnce for Wrap {
42 fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
43 div()
44 .flex()
45 .flex_row()
46 .flex_wrap()
47 .gap(px(self.spacing))
48 .children(self.children)
49 .probe("Wrap")
50 }
51}