From e984c18257c4a495be1626e00d26e2344f8a92c5 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Tue, 4 Nov 2025 16:13:15 -0800 Subject: [PATCH] Render the panelet --- crates/ui/src/components/tab_bar.rs | 2 + crates/workspace/src/pane.rs | 31 +++++++------- crates/workspace/src/panelet.rs | 63 +++++++++++++++++++++++++++++ crates/workspace/src/workspace.rs | 27 +++++++------ 4 files changed, 96 insertions(+), 27 deletions(-) create mode 100644 crates/workspace/src/panelet.rs diff --git a/crates/ui/src/components/tab_bar.rs b/crates/ui/src/components/tab_bar.rs index ca196ed3b4f7c31eb18a14d9cb7dfb032cb07ee5..9cab9aef0037e325491e67df51818ccf35495ad2 100644 --- a/crates/ui/src/components/tab_bar.rs +++ b/crates/ui/src/components/tab_bar.rs @@ -10,6 +10,7 @@ pub struct TabBar { start_children: SmallVec<[AnyElement; 2]>, children: SmallVec<[AnyElement; 2]>, end_children: SmallVec<[AnyElement; 2]>, + pre_end_children: SmallVec<[AnyElement; 2]>, scroll_handle: Option, } @@ -20,6 +21,7 @@ impl TabBar { start_children: SmallVec::new(), children: SmallVec::new(), end_children: SmallVec::new(), + pre_end_children: SmallVec::new(), scroll_handle: None, } } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index b772776bc7d3f2aca35df0a82624b1545eb8cd4c..28e71b26f4c1d1617aa4b23b0df6bb9b6de6efd9 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -3040,20 +3040,16 @@ impl Pane { move |_window, cx| Tooltip::for_action_in("Go Back", &GoBack, &focus_handle, cx) }); - let open_aside = IconButton::new("open_aside", IconName::Thread).icon_size(IconSize::Small); - // .on_click({ - // let entity = cx.entity(); - // move |_, window, cx| { - // entity.update(cx, |pane, cx| { - // pane.navigate_backward(&Default::default(), window, cx) - // }) - // } - // }) - // .disabled(!self.can_navigate_backward()) - // .tooltip({ - // let focus_handle = focus_handle.clone(); - // move |_window, cx| Tooltip::for_action_in("Go Back", &GoBack, &focus_handle, cx) - // }); + let open_aside = IconButton::new("open_aside", IconName::Thread) + .icon_size(IconSize::Small) + .on_click({ + let workspace = self.workspace.clone(); + move |_, window, cx| { + workspace + .update(cx, |workspace, cx| workspace.toggle_panelet(window, cx)) + .ok(); + } + }); let navigate_forward = IconButton::new("navigate_forward", IconName::ArrowRight) .icon_size(IconSize::Small) @@ -3096,7 +3092,12 @@ impl Pane { let unpinned_tabs = tab_items.split_off(self.pinned_tab_count); let pinned_tabs = tab_items; - let render_aside_toggle = true; + let render_aside_toggle = self + .workspace + .upgrade() + .map(|entity| !entity.read(cx).panelet) + .unwrap_or(false); + TabBar::new("tab_bar") .when(render_aside_toggle, |tab_bar| { tab_bar.start_child(open_aside) diff --git a/crates/workspace/src/panelet.rs b/crates/workspace/src/panelet.rs new file mode 100644 index 0000000000000000000000000000000000000000..ea6484e549a459e5dfd5f26e22972df803920124 --- /dev/null +++ b/crates/workspace/src/panelet.rs @@ -0,0 +1,63 @@ +use gpui::WeakEntity; +use ui::{ + ActiveTheme as _, Clickable, Context, DynamicSpacing, IconButton, IconName, IconSize, + InteractiveElement as _, IntoElement, ParentElement as _, RenderOnce, Styled as _, Tab, Window, + div, px, +}; + +use crate::Workspace; + +impl Workspace { + pub fn toggle_panelet(&mut self, _window: &mut Window, _cx: &mut Context) { + self.panelet = !self.panelet; + // self. + } +} + +#[derive(IntoElement)] +pub struct Panelet { + workspace: WeakEntity, +} + +impl Panelet { + pub fn new(cx: &mut Context) -> Self { + let workspace = cx.weak_entity(); + Self { workspace } + } +} + +impl RenderOnce for Panelet { + fn render(self, _window: &mut Window, cx: &mut ui::App) -> impl IntoElement { + div() + .h_full() + .bg(cx.theme().colors().tab_bar_background) + .w(px(400.0)) + .border_color(cx.theme().colors().border) + .border_r_1() + .child( + div() + .pt_1() + .id("panelet") + .flex() + .flex_none() + .w_full() + .h(Tab::container_height(cx)) + .child( + div().px(DynamicSpacing::Base06.rems(cx)).child( + IconButton::new("open_panelet", IconName::Thread) + .icon_size(IconSize::Small) + .on_click(move |_, window, cx| { + self.workspace + .update(cx, |workspace, cx| { + workspace.toggle_panelet(window, cx) + }) + .ok(); + }), + ), + ), + ) + // .child( + // // todo!(put content here) + // ) + } +} diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index ef0e9c79e2eb8b332e66583f7dd29ae29bb05134..3958148dac88235e4921e4917b75cbf38d41a4ed 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -6,6 +6,7 @@ mod modal_layer; pub mod notifications; pub mod pane; pub mod pane_group; +mod panelet; mod path_list; mod persistence; pub mod searchable; @@ -126,11 +127,14 @@ pub use workspace_settings::{ }; use zed_actions::{Spawn, feedback::FileBugReport}; -use crate::persistence::{ - SerializedAxis, - model::{DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup}, -}; use crate::{item::ItemBufferKind, notifications::NotificationId}; +use crate::{ + panelet::Panelet, + persistence::{ + SerializedAxis, + model::{DockData, DockStructure, SerializedItem, SerializedPane, SerializedPaneGroup}, + }, +}; pub const SERIALIZATION_THROTTLE_TIME: Duration = Duration::from_millis(200); @@ -1180,6 +1184,7 @@ pub struct Workspace { scheduled_tasks: Vec>, last_open_dock_positions: Vec, removing: bool, + panelet: bool, } impl EventEmitter for Workspace {} @@ -1524,6 +1529,7 @@ impl Workspace { scheduled_tasks: Vec::new(), last_open_dock_positions: Vec::new(), removing: false, + panelet: false, } } @@ -6698,14 +6704,11 @@ impl Render for Workspace { window, cx, )) - // .child( - // TODO! - // Render "aside pane" child - // div() - // .h_full() - // .w_3() - // .bg(gpui::red()) - // ) + .when(self.panelet, |this| { + this.child( + Panelet::new(cx) + ) + }) .child( div() .flex()