panelet.rs

 1use gpui::WeakEntity;
 2use ui::{
 3    ActiveTheme as _, Clickable, Context, DynamicSpacing, IconButton, IconName, IconSize,
 4    InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Styled as _, Tab, Window,
 5    div, px,
 6};
 7
 8use crate::Workspace;
 9
10impl Workspace {
11    pub fn toggle_panelet(&mut self, _window: &mut Window, _cx: &mut Context<Self>) {
12        self.panelet = !self.panelet;
13        // self.
14    }
15}
16
17#[derive(IntoElement)]
18pub struct Panelet {
19    workspace: WeakEntity<Workspace>,
20}
21
22impl Panelet {
23    pub fn new(cx: &mut Context<Workspace>) -> Self {
24        let workspace = cx.weak_entity();
25        Self { workspace }
26    }
27}
28
29impl RenderOnce for Panelet {
30    fn render(self, _window: &mut Window, cx: &mut ui::App) -> impl IntoElement {
31        div()
32            .h_full()
33            .bg(cx.theme().colors().tab_bar_background)
34            .w(px(400.0))
35            .border_color(cx.theme().colors().border)
36            .border_r_1()
37            .child(
38                div()
39                    .pt_1()
40                    .id("panelet")
41                    .flex()
42                    .flex_none()
43                    .w_full()
44                    .h(Tab::container_height(cx))
45                    .child(
46                        div().px(DynamicSpacing::Base06.rems(cx)).child(
47                            IconButton::new("open_panelet", IconName::Thread)
48                                .icon_size(IconSize::Small)
49                                .on_click(move |_, window, cx| {
50                                    self.workspace
51                                        .update(cx, |workspace, cx| {
52                                            workspace.toggle_panelet(window, cx)
53                                        })
54                                        .ok();
55                                }),
56                        ),
57                    ),
58            )
59        // .child(
60        //     // todo!(put content here)
61        // )
62    }
63}