workspace.rs

 1use crate::{chat_panel, collab_panel, project_panel, status_bar, tab_bar, theme, title_bar};
 2
 3use gpui2::{
 4    elements::{div, div::ScrollState},
 5    style::StyleHelpers,
 6    Element, IntoElement, ParentElement, ViewContext,
 7};
 8
 9#[derive(Element, Default)]
10struct WorkspaceElement {
11    project_panel_scroll_state: ScrollState,
12    collab_panel_scroll_state: ScrollState,
13    right_scroll_state: ScrollState,
14    tab_bar_scroll_state: ScrollState,
15    palette_scroll_state: ScrollState,
16}
17
18pub fn workspace<V: 'static>() -> impl Element<V> {
19    WorkspaceElement::default()
20}
21
22impl WorkspaceElement {
23    fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
24        let theme = theme(cx);
25
26        div()
27            // Elevation Level 0
28            .size_full()
29            .flex()
30            .flex_col()
31            .font("Zed Sans Extended")
32            .gap_0()
33            .justify_start()
34            .items_start()
35            .text_color(theme.lowest.base.default.foreground)
36            .fill(theme.lowest.base.default.background)
37            .relative()
38            // Elevation Level 1
39            .child(title_bar())
40            .child(
41                div()
42                    .flex_1()
43                    .w_full()
44                    .flex()
45                    .flex_row()
46                    .overflow_hidden()
47                    .child(project_panel(self.project_panel_scroll_state.clone()))
48                    .child(collab_panel(self.collab_panel_scroll_state.clone()))
49                    .child(
50                        div()
51                            .h_full()
52                            .flex_1()
53                            .fill(theme.highest.base.default.background)
54                            .child(
55                                div()
56                                    .flex()
57                                    .flex_col()
58                                    .flex_1()
59                                    .child(tab_bar(self.tab_bar_scroll_state.clone())),
60                            ),
61                    )
62                    .child(chat_panel(self.right_scroll_state.clone())),
63            )
64            .child(status_bar())
65        // Elevation Level 3
66        // .child(
67        //     div()
68        //         .absolute()
69        //         .top_0()
70        //         .left_0()
71        //         .size_full()
72        //         .flex()
73        //         .justify_center()
74        //         .items_center()
75        //         // .fill(theme.lowest.base.default.background)
76        //         // Elevation Level 4
77        //         .child(command_palette(self.palette_scroll_state.clone())),
78        // )
79    }
80}