From f14ef40a132e09324a92c7118f299b14f23c44ff Mon Sep 17 00:00:00 2001 From: Kevin Sweet Date: Sun, 2 Feb 2025 21:13:40 -0700 Subject: [PATCH] Conditionally render divider between button groups in the status bar (#24114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the left hand status bar, there are two groups of buttons. There was a border between the two hardcoded on the first button of the second group, however, if all buttons in the first group are hidden, the border doesn't need to be rendered. (Not handled in this PR) A potentially better approach would be to change StatusBar's definition from `left_items` and `right_items` to `left_groups` and `right_groups`, and render dividers between each group of items. That seemed like a bigger refactor than I wanted to handle for now, but is an option for the future. If you use these settings on `main`, the border will show, but with nothing to the left of it. ```json { "collaboration_panel": { "button": false }, "outline_panel": { "button": false }, "project_panel": { "button": false, }, } ``` Screenshots: Before: Screenshot 2025-02-02 at 6 19 24 PM Screenshot 2025-02-02 at 6 20 12 PM After: Screenshot 2025-02-02 at 6 19 58 PM Screenshot 2025-02-02 at 6 20 20 PM Release Notes: - Conditionally render divider in status bar --------- Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> --- crates/diagnostics/src/items.rs | 3 --- crates/workspace/src/dock.rs | 15 +++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/crates/diagnostics/src/items.rs b/crates/diagnostics/src/items.rs index bf3e1c7595..2fa593e6ea 100644 --- a/crates/diagnostics/src/items.rs +++ b/crates/diagnostics/src/items.rs @@ -86,9 +86,6 @@ impl Render for DiagnosticIndicator { h_flex() .gap_2() - .pl_1() - .border_l_1() - .border_color(cx.theme().colors().border) .child( ButtonLike::new("diagnostic-indicator") .child(diagnostic_indicator) diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 2d1e555383..bf6d65c03e 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -11,7 +11,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use settings::SettingsStore; use std::sync::Arc; -use ui::{h_flex, ContextMenu, IconButton, Tooltip}; +use ui::{h_flex, ContextMenu, Divider, DividerColor, IconButton, Tooltip}; use ui::{prelude::*, right_click_menu}; pub(crate) const RESIZE_HANDLE_SIZE: Pixels = Pixels(6.); @@ -801,7 +801,7 @@ impl Render for PanelButtons { DockPosition::Bottom | DockPosition::Right => (Corner::BottomRight, Corner::TopRight), }; - let buttons = dock + let buttons: Vec<_> = dock .panel_entries .iter() .enumerate() @@ -869,9 +869,16 @@ impl Render for PanelButtons { }), ), ) - }); + }) + .collect(); - h_flex().gap_0p5().children(buttons) + let has_buttons = !buttons.is_empty(); + h_flex() + .gap_1() + .children(buttons) + .when(has_buttons, |this| { + this.child(Divider::vertical().color(DividerColor::Border)) + }) } }