title_bar.rs

 1use std::marker::PhantomData;
 2
 3use gpui2::elements::div;
 4use gpui2::style::StyleHelpers;
 5use gpui2::{Element, IntoElement, ParentElement, ViewContext};
 6
 7use crate::prelude::Shape;
 8use crate::{
 9    avatar, follow_group, icon_button, text_button, theme, tool_divider, traffic_lights, IconAsset,
10    IconColor,
11};
12
13#[derive(Element)]
14pub struct TitleBar<V: 'static> {
15    view_type: PhantomData<V>,
16}
17
18pub fn title_bar<V: 'static>() -> TitleBar<V> {
19    TitleBar {
20        view_type: PhantomData,
21    }
22}
23
24impl<V: 'static> TitleBar<V> {
25    fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
26        let theme = theme(cx);
27        let player_list = vec![
28            avatar("https://avatars.githubusercontent.com/u/1714999?v=4"),
29            avatar("https://avatars.githubusercontent.com/u/1714999?v=4"),
30        ];
31
32        div()
33            .flex()
34            .items_center()
35            .justify_between()
36            .w_full()
37            .h_8()
38            .fill(theme.lowest.base.default.background)
39            .child(
40                div()
41                    .flex()
42                    .items_center()
43                    .h_full()
44                    .gap_4()
45                    .px_2()
46                    .child(traffic_lights())
47                    // === Project Info === //
48                    .child(
49                        div()
50                            .flex()
51                            .items_center()
52                            .gap_1()
53                            .child(text_button("maxbrunsfeld"))
54                            .child(text_button("zed"))
55                            .child(text_button("nate/gpui2-ui-components")),
56                    )
57                    .child(follow_group(player_list.clone()).player(0))
58                    .child(follow_group(player_list.clone()).player(1))
59                    .child(follow_group(player_list.clone()).player(2)),
60            )
61            .child(
62                div()
63                    .flex()
64                    .items_center()
65                    .child(
66                        div()
67                            .px_2()
68                            .flex()
69                            .items_center()
70                            .gap_1()
71                            .child(icon_button().icon(IconAsset::FolderX))
72                            .child(icon_button().icon(IconAsset::Close)),
73                    )
74                    .child(tool_divider())
75                    .child(
76                        div()
77                            .px_2()
78                            .flex()
79                            .items_center()
80                            .gap_1()
81                            .child(icon_button().icon(IconAsset::Mic))
82                            .child(icon_button().icon(IconAsset::AudioOn))
83                            .child(
84                                icon_button()
85                                    .icon(IconAsset::Screen)
86                                    .color(IconColor::Accent),
87                            ),
88                    )
89                    .child(
90                        div().px_2().flex().items_center().child(
91                            avatar("https://avatars.githubusercontent.com/u/1714999?v=4")
92                                .shape(Shape::RoundedRectangle),
93                        ),
94                    ),
95            )
96    }
97}