gpui_component/dialog/
content.rs1use gpui::{
2 AnyElement, App, IntoElement, ParentElement, RenderOnce, StyleRefinement, Styled, Window,
3};
4
5use crate::{ActiveTheme as _, StyledExt as _, v_flex};
6
7#[derive(IntoElement)]
9pub struct DialogContent {
10 style: StyleRefinement,
11 children: Vec<AnyElement>,
12}
13
14impl DialogContent {
15 pub fn new() -> Self {
16 Self {
17 style: StyleRefinement::default(),
18 children: Vec::new(),
19 }
20 }
21}
22
23impl ParentElement for DialogContent {
24 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
25 self.children.extend(elements);
26 }
27}
28
29impl Styled for DialogContent {
30 fn style(&mut self) -> &mut StyleRefinement {
31 &mut self.style
32 }
33}
34
35impl RenderOnce for DialogContent {
36 fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
37 v_flex()
38 .w_full()
39 .flex_1()
40 .rounded(cx.theme().radius_lg)
41 .refine_style(&self.style)
42 .children(self.children)
43 }
44}