Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
workspace: Highlight where dragged tab will be dropped (#34740)
Daniel Sauble708c434bd4c2
diff --git a/crates/theme/src/default_colors.rs b/crates/theme/src/default_colors.rsindex 1c3f48b548d..051b7acf102 100644--- a/crates/theme/src/default_colors.rs+++ b/crates/theme/src/default_colors.rs@@ -54,6 +54,7 @@ impl ThemeColors {element_disabled: neutral().light_alpha().step_3(),element_selection_background: blue().light().step_3().alpha(0.25),drop_target_background: blue().light_alpha().step_2(),+ drop_target_border: neutral().light().step_12(),ghost_element_background: system.transparent,ghost_element_hover: neutral().light_alpha().step_3(),ghost_element_active: neutral().light_alpha().step_4(),@@ -179,6 +180,7 @@ impl ThemeColors {element_disabled: neutral().dark_alpha().step_3(),element_selection_background: blue().dark().step_3().alpha(0.25),drop_target_background: blue().dark_alpha().step_2(),+ drop_target_border: neutral().dark().step_12(),ghost_element_background: system.transparent,ghost_element_hover: neutral().dark_alpha().step_4(),ghost_element_active: neutral().dark_alpha().step_5(),diff --git a/crates/theme/src/fallback_themes.rs b/crates/theme/src/fallback_themes.rsindex 4d77dd5d81d..e9e8e2d0db9 100644--- a/crates/theme/src/fallback_themes.rs+++ b/crates/theme/src/fallback_themes.rs@@ -115,6 +115,7 @@ pub(crate) fn zed_default_dark() -> Theme {element_disabled: SystemColors::default().transparent,element_selection_background: player.local().selection.alpha(0.25),drop_target_background: hsla(220.0 / 360., 8.3 / 100., 21.4 / 100., 1.0),+ drop_target_border: hsla(221. / 360., 11. / 100., 86. / 100., 1.0),ghost_element_background: SystemColors::default().transparent,ghost_element_hover: hover,ghost_element_active: hsla(220.0 / 360., 11.8 / 100., 20.0 / 100., 1.0),diff --git a/crates/theme/src/schema.rs b/crates/theme/src/schema.rsindex bfa2adcedf7..425fedbc717 100644--- a/crates/theme/src/schema.rs+++ b/crates/theme/src/schema.rs@@ -225,6 +225,10 @@ pub struct ThemeColorsContent {#[serde(rename = "drop_target.background")]pub drop_target_background: Option<String>,+ /// Border Color. Used for the border that shows where a dragged element will be dropped.+ #[serde(rename = "drop_target.border")]+ pub drop_target_border: Option<String>,+/// Used for the background of a ghost element that should have the same background as the surface it's on.////// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...@@ -747,6 +751,10 @@ impl ThemeColorsContent {.drop_target_background.as_ref().and_then(|color| try_parse_color(color).ok()),+ drop_target_border: self+ .drop_target_border+ .as_ref()+ .and_then(|color| try_parse_color(color).ok()),ghost_element_background: self.ghost_element_background.as_ref()diff --git a/crates/theme/src/styles/colors.rs b/crates/theme/src/styles/colors.rsindex aab11803f4d..198ad97adb5 100644--- a/crates/theme/src/styles/colors.rs+++ b/crates/theme/src/styles/colors.rs@@ -59,6 +59,8 @@ pub struct ThemeColors {pub element_disabled: Hsla,/// Background Color. Used for the area that shows where a dragged element will be dropped.pub drop_target_background: Hsla,+ /// Border Color. Used for the border that shows where a dragged element will be dropped.+ pub drop_target_border: Hsla,/// Used for the background of a ghost element that should have the same background as the surface it's on.////// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...@@ -304,6 +306,7 @@ pub enum ThemeColorField {ElementSelected,ElementDisabled,DropTargetBackground,+ DropTargetBorder,GhostElementBackground,GhostElementHover,GhostElementActive,@@ -418,6 +421,7 @@ impl ThemeColors {ThemeColorField::ElementSelected => self.element_selected,ThemeColorField::ElementDisabled => self.element_disabled,ThemeColorField::DropTargetBackground => self.drop_target_background,+ ThemeColorField::DropTargetBorder => self.drop_target_border,ThemeColorField::GhostElementBackground => self.ghost_element_background,ThemeColorField::GhostElementHover => self.ghost_element_hover,ThemeColorField::GhostElementActive => self.ghost_element_active,diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex cffeea0a8d4..45bd497705c 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -2478,8 +2478,19 @@ impl Pane {},|tab, _, _, cx| cx.new(|_| tab.clone()),)- .drag_over::<DraggedTab>(|tab, _, _, cx| {- tab.bg(cx.theme().colors().drop_target_background)+ .drag_over::<DraggedTab>(move |tab, dragged_tab: &DraggedTab, _, cx| {+ let mut styled_tab = tab+ .bg(cx.theme().colors().drop_target_background)+ .border_color(cx.theme().colors().drop_target_border)+ .border_0();++ if ix < dragged_tab.ix {+ styled_tab = styled_tab.border_l_2();+ } else if ix > dragged_tab.ix {+ styled_tab = styled_tab.border_r_2();+ }++ styled_tab}).drag_over::<DraggedSelection>(|tab, _, _, cx| {tab.bg(cx.theme().colors().drop_target_background)