From 9969caf5138e9616a0afa4a6877158af3af16b27 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Fri, 17 Nov 2023 23:39:40 -0500 Subject: [PATCH 1/6] Style empty diagnostics as an editor --- crates/diagnostics2/src/diagnostics.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/diagnostics2/src/diagnostics.rs b/crates/diagnostics2/src/diagnostics.rs index 672350ad9e3ee03173da60e27e8faf78cb0458f1..623b63631908dd65b7f4ca633677a6ae8da3136f 100644 --- a/crates/diagnostics2/src/diagnostics.rs +++ b/crates/diagnostics2/src/diagnostics.rs @@ -34,6 +34,7 @@ use std::{ path::PathBuf, sync::Arc, }; +use theme::ActiveTheme; pub use toolbar_controls::ToolbarControls; use ui::{h_stack, HighlightedLabel, Icon, IconElement, Label, TextColor}; use util::TryFutureExt; @@ -92,9 +93,10 @@ impl EventEmitter for ProjectDiagnosticsEditor {} impl Render for ProjectDiagnosticsEditor { type Element = Focusable>; - fn render(&mut self, _: &mut ViewContext) -> Self::Element { + fn render(&mut self, cx: &mut ViewContext) -> Self::Element { let child = if self.path_states.is_empty() { div() + .bg(cx.theme().colors().editor_background) .flex() .items_center() .justify_center() From 101fe7fbb509b18b8435fed4829809fbed38e8a2 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Sat, 18 Nov 2023 00:54:01 -0500 Subject: [PATCH 2/6] Update diagnostic status bar tool --- assets/icons/warning.svg | 7 +--- crates/diagnostics2/src/items.rs | 61 +++++++++++++---------------- crates/workspace2/src/status_bar.rs | 2 +- 3 files changed, 30 insertions(+), 40 deletions(-) diff --git a/assets/icons/warning.svg b/assets/icons/warning.svg index e581def0d050727647ccaf06a53406b389d57e71..c48a575a90dc224db13a4b7fda8629fb2cd464f4 100644 --- a/assets/icons/warning.svg +++ b/assets/icons/warning.svg @@ -1,6 +1 @@ - - - - - - + diff --git a/crates/diagnostics2/src/items.rs b/crates/diagnostics2/src/items.rs index 5e5a9f135e2d68c7f07895d05edcd493031560bd..72d4fe2ba7cebfb202f475f65e7f7b32b2ff4c9c 100644 --- a/crates/diagnostics2/src/items.rs +++ b/crates/diagnostics2/src/items.rs @@ -1,7 +1,7 @@ use collections::HashSet; use editor::{Editor, GoToDiagnostic}; use gpui::{ - div, Div, EventEmitter, InteractiveComponent, ParentComponent, Render, Stateful, + div, rems, Div, EventEmitter, InteractiveComponent, ParentComponent, Render, Stateful, StatefulInteractiveComponent, Styled, Subscription, View, ViewContext, WeakView, }; use language::Diagnostic; @@ -25,15 +25,35 @@ impl Render for DiagnosticIndicator { type Element = Stateful>; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { - let mut summary_row = h_stack() + let diagnostic_indicator = match (self.summary.error_count, self.summary.warning_count) { + (0, 0) => h_stack().child(IconElement::new(Icon::Check).color(TextColor::Success)), + (0, warning_count) => h_stack() + .gap_1() + .child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning)) + .child(Label::new(warning_count.to_string())), + (error_count, 0) => h_stack() + .gap_1() + .child(IconElement::new(Icon::XCircle).color(TextColor::Error)) + .child(Label::new(error_count.to_string())), + (error_count, warning_count) => h_stack() + .gap_1() + .child(IconElement::new(Icon::XCircle).color(TextColor::Error)) + .child(Label::new(error_count.to_string())) + .child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning)) + .child(Label::new(warning_count.to_string())), + }; + + h_stack() .id(cx.entity_id()) .on_action(Self::go_to_next_diagnostic) .rounded_md() - .p_1() + .flex_none() + .h(rems(1.375)) + .px_1() .cursor_pointer() - .bg(gpui::green()) - .hover(|style| style.bg(cx.theme().colors().element_hover)) - .active(|style| style.bg(cx.theme().colors().element_active)) + .bg(cx.theme().colors().ghost_element_background) + .hover(|style| style.bg(cx.theme().colors().ghost_element_hover)) + .active(|style| style.bg(cx.theme().colors().ghost_element_active)) .tooltip(|_, cx| Tooltip::text("Project Diagnostics", cx)) .on_click(|this, _, cx| { if let Some(workspace) = this.workspace.upgrade() { @@ -41,33 +61,8 @@ impl Render for DiagnosticIndicator { ProjectDiagnosticsEditor::deploy(workspace, &Default::default(), cx) }) } - }); - - if self.summary.error_count > 0 { - summary_row = summary_row.child( - div() - .child(IconElement::new(Icon::XCircle).color(TextColor::Error)) - .bg(gpui::red()), - ); - summary_row = summary_row.child( - div() - .child(Label::new(self.summary.error_count.to_string())) - .bg(gpui::yellow()), - ); - } - - if self.summary.warning_count > 0 { - summary_row = summary_row - .child(IconElement::new(Icon::ExclamationTriangle).color(TextColor::Warning)); - summary_row = summary_row.child(Label::new(self.summary.warning_count.to_string())); - } - - if self.summary.error_count == 0 && self.summary.warning_count == 0 { - summary_row = - summary_row.child(IconElement::new(Icon::Check).color(TextColor::Success)); - } - - summary_row + }) + .child(diagnostic_indicator) } } diff --git a/crates/workspace2/src/status_bar.rs b/crates/workspace2/src/status_bar.rs index 327e7c09ede63c1001369af9d31a64342e574d3b..2293b7475c60821d2e1f3b19af075e750f9e8160 100644 --- a/crates/workspace2/src/status_bar.rs +++ b/crates/workspace2/src/status_bar.rs @@ -56,7 +56,7 @@ impl StatusBar { fn render_left_tools(&self, cx: &mut ViewContext) -> impl Component { h_stack() .items_center() - .gap_1() + .gap_2() .children(self.left_items.iter().map(|item| item.to_any())) } From b218ab47550f8b1dee1fbcef8f051ae2c4b16a16 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Sat, 18 Nov 2023 01:02:21 -0500 Subject: [PATCH 3/6] Remove default hover state for icon buttons --- crates/ui2/src/components/icon_button.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui2/src/components/icon_button.rs b/crates/ui2/src/components/icon_button.rs index 9b8548e3f9c6cf092f08f41bbda3bfc25293bc98..23d920835e63a04a437e97f9d708264f767d5747 100644 --- a/crates/ui2/src/components/icon_button.rs +++ b/crates/ui2/src/components/icon_button.rs @@ -111,7 +111,10 @@ impl IconButton { .p_1() .bg(bg_color) .cursor_pointer() - .hover(|style| style.bg(bg_hover_color)) + // Nate: Trying to figure out the right places we want to show a + // hover state here. I think it is a bit heavy to have it on every + // place we use an icon button. + // .hover(|style| style.bg(bg_hover_color)) .active(|style| style.bg(bg_active_color)) .child(IconElement::new(self.icon).color(icon_color)); From d6f173866e2f89e2f4b63a747109f8756fbf912f Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Sat, 18 Nov 2023 01:02:40 -0500 Subject: [PATCH 4/6] Use muted color for fold indicators --- crates/editor2/src/editor.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index ee72f318ca620e38563c8c74ae0feaf8fa75e453..beed93e91761566400b8a3d8bb0ae92dd786ed4a 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -4401,6 +4401,7 @@ impl Editor { editor.fold_at(&FoldAt { buffer_row }, cx); } }) + .color(ui::TextColor::Muted) .render() }) }) From f9804feefae76f8d7fec77122edb8c17b544d6ab Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Sat, 18 Nov 2023 02:06:51 -0500 Subject: [PATCH 5/6] Remove flex_1 from bottom dock to fix pane group spacing --- crates/workspace2/src/pane.rs | 12 +++++------- crates/workspace2/src/workspace2.rs | 17 ++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index d44d3471146c7acbf8ad4ce9546e0d9f88167342..cd8f0851923af1266a1eb3d4b6e220bc1c691aab 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -24,6 +24,7 @@ use std::{ Arc, }, }; +use theme2::default_color_scales; use ui::v_stack; use ui::{prelude::*, Icon, IconButton, IconElement, TextColor, Tooltip}; use util::truncate_and_remove_front; @@ -1480,15 +1481,10 @@ impl Pane { // Right Side .child( div() - // We only use absolute here since we don't - // have opacity or `hidden()` yet - .absolute() - .neg_top_7() .px_1() .flex() .flex_none() .gap_2() - .group_hover("tab_bar", |this| this.top_0()) // Nav Buttons .child( div() @@ -1931,9 +1927,11 @@ impl Render for Pane { .map(|task| task.detach_and_log_err(cx)); }) .child(self.render_tab_bar(cx)) - .child(div() /* todo!(toolbar) */) + // .child( + // div() + // ) /* todo!(toolbar) */ .child(if let Some(item) = self.active_item() { - div().flex_1().child(item.to_any()) + div().flex().flex_1().child(item.to_any()) } else { // todo!() div().child("Empty Pane") diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index 0e88414bd5b53d3fbc1c0d408a680d1f6a5a5bc0..4f1c573d6c9f06f23cf150ff535a2fbc8dfd550b 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -63,7 +63,7 @@ use std::{ sync::{atomic::AtomicUsize, Arc}, time::Duration, }; -use theme2::{ActiveTheme, ThemeSettings}; +use theme2::{default_color_scales, ActiveTheme, ThemeSettings}; pub use toolbar::{ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView}; pub use ui; use util::ResultExt; @@ -3666,7 +3666,7 @@ impl Render for Workspace { &self.app_state, cx, )) - .child(div().flex().flex_1().child(self.bottom_dock.clone())), + .child(self.bottom_dock.clone()), ) // Right Dock .child( @@ -3679,19 +3679,6 @@ impl Render for Workspace { ), ) .child(self.status_bar.clone()) - .z_index(8) - // Debug - .child( - div() - .flex() - .flex_col() - .z_index(9) - .absolute() - .top_20() - .left_1_4() - .w_40() - .gap_2(), - ) } } From 55dbcf2039925895f1ce03e6b14d90fdc0688bb2 Mon Sep 17 00:00:00 2001 From: Mikayla Date: Fri, 17 Nov 2023 23:14:14 -0800 Subject: [PATCH 6/6] Remove unused imports --- crates/diagnostics2/src/items.rs | 2 +- crates/workspace2/src/pane.rs | 2 +- crates/workspace2/src/workspace2.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/diagnostics2/src/items.rs b/crates/diagnostics2/src/items.rs index 72d4fe2ba7cebfb202f475f65e7f7b32b2ff4c9c..dd1b7d98cf627c95d904a9483d56b6dcd55df35e 100644 --- a/crates/diagnostics2/src/items.rs +++ b/crates/diagnostics2/src/items.rs @@ -1,7 +1,7 @@ use collections::HashSet; use editor::{Editor, GoToDiagnostic}; use gpui::{ - div, rems, Div, EventEmitter, InteractiveComponent, ParentComponent, Render, Stateful, + rems, Div, EventEmitter, InteractiveComponent, ParentComponent, Render, Stateful, StatefulInteractiveComponent, Styled, Subscription, View, ViewContext, WeakView, }; use language::Diagnostic; diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index cd8f0851923af1266a1eb3d4b6e220bc1c691aab..d67422c32aa513e0c55b5cec5668b96fa5c3e303 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -24,7 +24,7 @@ use std::{ Arc, }, }; -use theme2::default_color_scales; + use ui::v_stack; use ui::{prelude::*, Icon, IconButton, IconElement, TextColor, Tooltip}; use util::truncate_and_remove_front; diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index 4f1c573d6c9f06f23cf150ff535a2fbc8dfd550b..78499a9d227311e9110fbedffc88b2a2ad0bdb69 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -63,7 +63,7 @@ use std::{ sync::{atomic::AtomicUsize, Arc}, time::Duration, }; -use theme2::{default_color_scales, ActiveTheme, ThemeSettings}; +use theme2::{ActiveTheme, ThemeSettings}; pub use toolbar::{ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView}; pub use ui; use util::ResultExt;