Merge branch 'gpui2-ui' into gpui2

This commit is contained in:
Marshall Bowers 2023-10-16 16:54:40 -04:00
commit c8b452d411
2 changed files with 43 additions and 51 deletions

View file

@ -99,7 +99,7 @@ impl<S: 'static + Send + Sync + Clone> ListHeader<S> {
let color = ThemeColor::new(cx); let color = ThemeColor::new(cx);
let is_toggleable = self.toggleable != Toggleable::NotToggleable; 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(); let disclosure_control = self.disclosure_control();

View file

@ -1,22 +1,22 @@
use chrono::DateTime; 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::prelude::*;
use crate::{ use crate::{
theme, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label, theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label,
LanguageSelector, NotificationToast, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel,
ProjectPanel, SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin, SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin,
}; };
#[derive(Clone)] #[derive(Clone)]
pub struct Workspace { pub struct Workspace {
title_bar: View<TitleBar>, title_bar: View<TitleBar>,
editor_1: View<EditorPane>, editor_1: View<EditorPane>,
editor_2: View<EditorPane>,
show_project_panel: bool, show_project_panel: bool,
show_collab_panel: bool, show_collab_panel: bool,
show_chat_panel: bool, show_chat_panel: bool,
show_assistant_panel: bool, show_assistant_panel: bool,
show_notifications_panel: bool,
show_terminal: bool, show_terminal: bool,
show_language_selector: bool, show_language_selector: bool,
left_panel_scroll_state: ScrollState, left_panel_scroll_state: ScrollState,
@ -30,13 +30,13 @@ impl Workspace {
Self { Self {
title_bar: TitleBar::view(cx), title_bar: TitleBar::view(cx),
editor_1: EditorPane::view(cx), editor_1: EditorPane::view(cx),
editor_2: EditorPane::view(cx),
show_project_panel: true, show_project_panel: true,
show_collab_panel: false, show_collab_panel: false,
show_chat_panel: true, show_chat_panel: false,
show_assistant_panel: false, show_assistant_panel: false,
show_terminal: true, show_terminal: true,
show_language_selector: false, show_language_selector: false,
show_notifications_panel: true,
left_panel_scroll_state: ScrollState::default(), left_panel_scroll_state: ScrollState::default(),
right_panel_scroll_state: ScrollState::default(), right_panel_scroll_state: ScrollState::default(),
tab_bar_scroll_state: ScrollState::default(), tab_bar_scroll_state: ScrollState::default(),
@ -88,6 +88,18 @@ impl Workspace {
cx.notify(); 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>) {
self.show_notifications_panel = !self.show_notifications_panel;
self.show_notifications_panel = false;
cx.notify();
}
pub fn is_assistant_panel_open(&self) -> bool { pub fn is_assistant_panel_open(&self) -> bool {
self.show_assistant_panel self.show_assistant_panel
} }
@ -117,43 +129,15 @@ impl Workspace {
pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> { pub fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<ViewState = Self> {
let theme = theme(cx).clone(); let theme = theme(cx).clone();
let temp_size = rems(36.).into(); let root_group = PaneGroup::new_panes(
vec![Pane::new(
let root_group = PaneGroup::new_groups( ScrollState::default(),
vec![ Size {
PaneGroup::new_panes( width: relative(1.).into(),
vec![ height: relative(1.).into(),
Pane::new( },
ScrollState::default(), )
Size { .child(self.editor_1.clone())],
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,
),
],
SplitDirection::Horizontal, SplitDirection::Horizontal,
); );
@ -243,6 +227,14 @@ impl Workspace {
) )
.filter(|_| self.is_chat_panel_open()), .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( .children(
Some( Some(
Panel::new(self.right_panel_scroll_state.clone()) Panel::new(self.right_panel_scroll_state.clone())
@ -264,12 +256,12 @@ impl Workspace {
.filter(|_| self.is_language_selector_open()), .filter(|_| self.is_language_selector_open()),
) )
.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast"))) .child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
// .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast"))) // .child(Toast::new(ToastOrigin::BottomRight).child(Label::new("Another toast")))
.child(NotificationToast::new( // .child(NotificationToast::new(
"Can't pull changes from origin", // "Can't pull changes from origin",
"Your local branch is behind the remote branch. Please pull the latest changes before pushing.", // "Your local branch is behind the remote branch. Please pull the latest changes before pushing.",
Button::new("Stash & Switch").variant(ButtonVariant::Filled), // Button::new("Stash & Switch").variant(ButtonVariant::Filled),
).secondary_action(Button::new("Cancel"))) // ).secondary_action(Button::new("Cancel")))
} }
} }