Detailed changes
@@ -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<ScrollHandle>,
}
@@ -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,
}
}
@@ -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)
@@ -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>) {
+ self.panelet = !self.panelet;
+ // self.
+ }
+}
+
+#[derive(IntoElement)]
+pub struct Panelet {
+ workspace: WeakEntity<Workspace>,
+}
+
+impl Panelet {
+ pub fn new(cx: &mut Context<Workspace>) -> 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)
+ // )
+ }
+}
@@ -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<Task<()>>,
last_open_dock_positions: Vec<DockPosition>,
removing: bool,
+ panelet: bool,
}
impl EventEmitter<Event> 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()