From 97d77440e7c967d3bafcf851cea7f870ced871f3 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 16 Oct 2023 13:07:15 -0400 Subject: [PATCH 1/3] Simplify static panes for now --- crates/ui2/src/components/workspace.rs | 48 +++++--------------------- 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs index 0df024d4538f63da65bd8d873abdf5d9f5299ea4..cca2efe7d09a5fa5f9a89fbbe2c1b5ebe20462d1 100644 --- a/crates/ui2/src/components/workspace.rs +++ b/crates/ui2/src/components/workspace.rs @@ -12,7 +12,6 @@ use crate::{ pub struct Workspace { title_bar: View, editor_1: View, - editor_2: View, show_project_panel: bool, show_collab_panel: bool, show_chat_panel: bool, @@ -30,7 +29,6 @@ impl Workspace { Self { title_bar: TitleBar::view(cx), editor_1: EditorPane::view(cx), - editor_2: EditorPane::view(cx), show_project_panel: true, show_collab_panel: false, show_chat_panel: true, @@ -117,43 +115,15 @@ impl Workspace { pub fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = theme(cx).clone(); - let temp_size = rems(36.).into(); - - let root_group = PaneGroup::new_groups( - vec![ - PaneGroup::new_panes( - vec![ - Pane::new( - ScrollState::default(), - Size { - width: relative(1.).into(), - height: temp_size, - }, - ) - .child(self.editor_1.clone()), - Pane::new( - ScrollState::default(), - Size { - width: relative(1.).into(), - height: temp_size, - }, - ) - .child(Terminal::new()), - ], - SplitDirection::Vertical, - ), - PaneGroup::new_panes( - vec![Pane::new( - ScrollState::default(), - Size { - width: relative(1.).into(), - height: relative(1.).into(), - }, - ) - .child(self.editor_2.clone())], - SplitDirection::Vertical, - ), - ], + let root_group = PaneGroup::new_panes( + vec![Pane::new( + ScrollState::default(), + Size { + width: relative(1.).into(), + height: relative(1.).into(), + }, + ) + .child(self.editor_1.clone())], SplitDirection::Horizontal, ); From 129273036a28692ba2693c0e4485c28989882dd0 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Mon, 16 Oct 2023 13:11:52 -0400 Subject: [PATCH 2/3] Add notifications panel to workspace UI structure --- crates/ui2/src/components/workspace.rs | 44 +++++++++++++++++++------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/crates/ui2/src/components/workspace.rs b/crates/ui2/src/components/workspace.rs index cca2efe7d09a5fa5f9a89fbbe2c1b5ebe20462d1..c58f83596c8b5fdc99fdb887a40c10b927d332b4 100644 --- a/crates/ui2/src/components/workspace.rs +++ b/crates/ui2/src/components/workspace.rs @@ -1,11 +1,11 @@ use chrono::DateTime; -use gpui3::{px, relative, rems, view, Context, Size, View}; +use gpui3::{px, relative, view, Context, Size, View}; use crate::prelude::*; use crate::{ - theme, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label, - LanguageSelector, NotificationToast, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, - ProjectPanel, SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin, + theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label, + LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel, + SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin, }; #[derive(Clone)] @@ -16,6 +16,7 @@ pub struct Workspace { show_collab_panel: bool, show_chat_panel: bool, show_assistant_panel: bool, + show_notifications_panel: bool, show_terminal: bool, show_language_selector: bool, left_panel_scroll_state: ScrollState, @@ -31,10 +32,11 @@ impl Workspace { editor_1: EditorPane::view(cx), show_project_panel: true, show_collab_panel: false, - show_chat_panel: true, + show_chat_panel: false, show_assistant_panel: false, show_terminal: true, show_language_selector: false, + show_notifications_panel: true, left_panel_scroll_state: ScrollState::default(), right_panel_scroll_state: ScrollState::default(), tab_bar_scroll_state: ScrollState::default(), @@ -86,6 +88,18 @@ impl Workspace { cx.notify(); } + pub fn is_notifications_panel_open(&self) -> bool { + self.show_notifications_panel + } + + pub fn toggle_notifications_panel(&mut self, cx: &mut ViewContext) { + self.show_notifications_panel = !self.show_notifications_panel; + + self.show_notifications_panel = false; + + cx.notify(); + } + pub fn is_assistant_panel_open(&self) -> bool { self.show_assistant_panel } @@ -213,6 +227,14 @@ impl Workspace { ) .filter(|_| self.is_chat_panel_open()), ) + .children( + Some( + Panel::new(self.right_panel_scroll_state.clone()) + .side(PanelSide::Right) + .child(div().w_96().h_full().child("Notifications")), + ) + .filter(|_| self.is_notifications_panel_open()), + ) .children( Some( Panel::new(self.right_panel_scroll_state.clone()) @@ -234,12 +256,12 @@ impl Workspace { .filter(|_| self.is_language_selector_open()), ) .child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast"))) - // .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast"))) - .child(NotificationToast::new( - "Can't pull changes from origin", - "Your local branch is behind the remote branch. Please pull the latest changes before pushing.", - Button::new("Stash & Switch").variant(ButtonVariant::Filled), - ).secondary_action(Button::new("Cancel"))) + // .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast"))) + // .child(NotificationToast::new( + // "Can't pull changes from origin", + // "Your local branch is behind the remote branch. Please pull the latest changes before pushing.", + // Button::new("Stash & Switch").variant(ButtonVariant::Filled), + // ).secondary_action(Button::new("Cancel"))) } } From 708034d1d3e295e94050fc7dc7a26f4d7535fe04 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 16 Oct 2023 15:55:43 -0400 Subject: [PATCH 3/3] Call `is_toggled` as a method --- crates/ui2/src/components/list.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rs index 9bdffa991c4a5378fbe1134b90e265f2d50e2615..8c6cfa160566ac7c9e57f11876261460623d88be 100644 --- a/crates/ui2/src/components/list.rs +++ b/crates/ui2/src/components/list.rs @@ -99,7 +99,7 @@ impl ListHeader { let color = ThemeColor::new(cx); let is_toggleable = self.toggleable != Toggleable::NotToggleable; - let is_toggled = Toggleable::is_toggled(&self.toggleable); + let is_toggled = self.toggleable.is_toggled(); let disclosure_control = self.disclosure_control();