Sync drop target border with new design

This commit is contained in:
Gaauwe Rombouts 2025-08-26 21:05:44 +02:00
parent b1d244c6c6
commit 222809b027
No known key found for this signature in database
GPG key ID: 777FCA1154EC0951

View file

@ -28,6 +28,7 @@ actions!(
#[derive(Clone)] #[derive(Clone)]
pub struct DraggedWindowTab { pub struct DraggedWindowTab {
pub id: WindowId, pub id: WindowId,
pub ix: usize,
pub handle: AnyWindowHandle, pub handle: AnyWindowHandle,
pub title: String, pub title: String,
pub width: Pixels, pub width: Pixels,
@ -142,6 +143,7 @@ impl SystemWindowTabs {
.on_drag( .on_drag(
DraggedWindowTab { DraggedWindowTab {
id: item.id, id: item.id,
ix,
handle: item.handle, handle: item.handle,
title: item.title.to_string(), title: item.title.to_string(),
width, width,
@ -156,15 +158,30 @@ impl SystemWindowTabs {
cx.new(|_| tab.clone()) cx.new(|_| tab.clone())
}, },
) )
.drag_over::<DraggedWindowTab>(|element, _, _, cx| { .drag_over::<DraggedWindowTab>({
element.bg(cx.theme().colors().drop_target_background) let tab_ix = ix;
move |element, dragged_tab: &DraggedWindowTab, _, cx| {
let mut styled_tab = element
.bg(cx.theme().colors().drop_target_background)
.border_color(cx.theme().colors().drop_target_border)
.border_0();
if tab_ix < dragged_tab.ix {
styled_tab = styled_tab.border_l_2();
} else if tab_ix > dragged_tab.ix {
styled_tab = styled_tab.border_r_2();
}
styled_tab
}
}) })
.on_drop( .on_drop({
let tab_ix = ix;
cx.listener(move |this, dragged_tab: &DraggedWindowTab, _window, cx| { cx.listener(move |this, dragged_tab: &DraggedWindowTab, _window, cx| {
this.last_dragged_tab = None; this.last_dragged_tab = None;
Self::handle_tab_drop(dragged_tab, ix, cx); Self::handle_tab_drop(dragged_tab, tab_ix, cx);
}), })
) })
.on_click(move |_, _, cx| { .on_click(move |_, _, cx| {
let _ = item.handle.update(cx, |_, window, _| { let _ = item.handle.update(cx, |_, window, _| {
window.activate_window(); window.activate_window();