From 13dd9128170b70e95d0d163f06b6bcd8a9013425 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 13 Nov 2023 10:47:15 -0800 Subject: [PATCH] Get left, right, and bottom docks rendering in the right places in the workspace Co-authored-by: Julia Co-authored-by: Marshall --- crates/gpui2/src/color.rs | 18 +++++++ crates/project_panel2/src/project_panel.rs | 6 ++- crates/workspace2/src/dock.rs | 8 ++- crates/workspace2/src/workspace2.rs | 61 ++++++++-------------- 4 files changed, 51 insertions(+), 42 deletions(-) diff --git a/crates/gpui2/src/color.rs b/crates/gpui2/src/color.rs index 6fcb12e178991d2afb36b3f5d7e342abdd85550a..d8989878de771b53bc6aea13320c1ebcfec39d3f 100644 --- a/crates/gpui2/src/color.rs +++ b/crates/gpui2/src/color.rs @@ -238,6 +238,24 @@ pub fn blue() -> Hsla { } } +pub fn green() -> Hsla { + Hsla { + h: 0.33, + s: 1., + l: 0.5, + a: 1., + } +} + +pub fn yellow() -> Hsla { + Hsla { + h: 0.16, + s: 1., + l: 0.5, + a: 1., + } +} + impl Hsla { /// Returns true if the HSLA color is fully transparent, false otherwise. pub fn is_transparent(&self) -> bool { diff --git a/crates/project_panel2/src/project_panel.rs b/crates/project_panel2/src/project_panel.rs index e3e04f5254f84009b86d02f59f9ce9894a3ab8b7..fec44e3d689901419c7bc39d2bb3ff8f18c1753b 100644 --- a/crates/project_panel2/src/project_panel.rs +++ b/crates/project_panel2/src/project_panel.rs @@ -31,7 +31,7 @@ use std::{ sync::Arc, }; use theme::ActiveTheme as _; -use ui::{h_stack, v_stack}; +use ui::{h_stack, v_stack, Label}; use unicase::UniCase; use util::TryFutureExt; use workspace::{ @@ -1382,7 +1382,7 @@ impl ProjectPanel { if let (Some(editor), true) = (editor, show_editor) { div().child(editor.clone()) } else { - div().child(details.filename.clone()) + div().child(Label::new(details.filename.clone())) } .ml_1(), ) @@ -1449,6 +1449,7 @@ impl Render for ProjectPanel { if has_worktree { div() + .size_full() .id("project-panel") .track_focus(&self.focus_handle) .child( @@ -1472,6 +1473,7 @@ impl Render for ProjectPanel { items }, ) + .size_full() .track_scroll(self.list.clone()), ) } else { diff --git a/crates/workspace2/src/dock.rs b/crates/workspace2/src/dock.rs index c8ff58f42d50b4989157b88a82f00a7255d9da20..9a614bc92ee696a6c7ff14dbe3ded90b3184d102 100644 --- a/crates/workspace2/src/dock.rs +++ b/crates/workspace2/src/dock.rs @@ -1,7 +1,7 @@ use crate::{status_bar::StatusItemView, Axis, Workspace}; use gpui::{ div, Action, AnyView, AppContext, Div, Entity, EntityId, EventEmitter, FocusHandle, - ParentElement, Render, Subscription, View, ViewContext, WeakView, WindowContext, + ParentElement, Render, Styled, Subscription, View, ViewContext, WeakView, WindowContext, }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -428,7 +428,11 @@ impl Render for Dock { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - todo!() + if let Some(entry) = self.visible_entry() { + div().size_full().child(entry.panel.to_any()) + } else { + div() + } } } diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index c9fd322ed387a0882b5f00d3e44b286edfddae96..8c1c5d9a0234e2778431b671274bfe02d63c19cb 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -3642,45 +3642,30 @@ impl Render for Workspace { .border_t() .border_b() .border_color(cx.theme().colors().border) - // .children( - // Some( - // Panel::new("project-panel-outer", cx) - // .side(PanelSide::Left) - // .child(ProjectPanel::new("project-panel-inner")), - // ) - // .filter(|_| self.is_project_panel_open()), - // ) - // .children( - // Some( - // Panel::new("collab-panel-outer", cx) - // .child(CollabPanel::new("collab-panel-inner")) - // .side(PanelSide::Left), - // ) - // .filter(|_| self.is_collab_panel_open()), - // ) - // .child(NotificationToast::new( - // "maxbrunsfeld has requested to add you as a contact.".into(), - // )) .child( - div().flex().flex_col().flex_1().h_full().child( - div().flex().flex_1().child(self.center.render( - &self.project, - &self.follower_states, - self.active_call(), - &self.active_pane, - self.zoomed.as_ref(), - &self.app_state, - cx, - )), - ), // .children( - // Some( - // Panel::new("terminal-panel", cx) - // .child(Terminal::new()) - // .allowed_sides(PanelAllowedSides::BottomOnly) - // .side(PanelSide::Bottom), - // ) - // .filter(|_| self.is_terminal_open()), - // ), + div() + .flex() + .flex_row() + .flex_1() + .h_full() + .child(div().flex().flex_1().child(self.left_dock.clone())) + .child( + div() + .flex() + .flex_col() + .flex_1() + .child(self.center.render( + &self.project, + &self.follower_states, + self.active_call(), + &self.active_pane, + self.zoomed.as_ref(), + &self.app_state, + cx, + )) + .child(div().flex().flex_1().child(self.bottom_dock.clone())), + ) + .child(div().flex().flex_1().child(self.right_dock.clone())), ), // .children( // Some( // Panel::new("chat-panel-outer", cx)