diff --git a/crates/layout/src/dock.rs b/crates/layout/src/dock.rs index 6bf38bf..d4de65d 100644 --- a/crates/layout/src/dock.rs +++ b/crates/layout/src/dock.rs @@ -1085,18 +1085,19 @@ fn render_pane( }) .pr(padding_x) .child(tabs) + .child(titlebar_strip( + div() + .id(SharedString::from(format!( + "{dock_id}-pane-{}-strip", + pane.key + ))) + .flex_1() + .self_stretch(), + window, + cx, + )) .when(titlebar.window_controls, |bar| { - bar.child(titlebar_strip( - div() - .id(SharedString::from(format!( - "{dock_id}-pane-{}-strip", - pane.key - ))) - .flex_1(), - window, - cx, - )) - .child(WindowControls::new(SharedString::from(format!( + bar.child(WindowControls::new(SharedString::from(format!( "{dock_id}-pane-{}-controls", pane.key )))) diff --git a/crates/layout/src/shell.rs b/crates/layout/src/shell.rs index 6d0471b..1eb232b 100644 --- a/crates/layout/src/shell.rs +++ b/crates/layout/src/shell.rs @@ -286,36 +286,43 @@ fn sidebar_region( .h(strip_height) .bg(strip_background) .items_center() - .justify_end() - .map(|strip| titlebar_strip(strip, window, cx)) .map(|strip| match side { Side::Left => strip.when(cfg!(target_os = "macos"), |strip| { strip.pl(px(TRAFFIC_LIGHT_PAD)) }), - Side::Right => strip.child(WindowControls::new("sidebar-window-controls")), + Side::Right => strip, }) .px(padding_x) - .child( - Button::new(SharedString::from(format!( - "sidebar-toggle-{}", - side.name() - ))) - .icon(side.toggle_icon()) - .variant(ButtonVariant::Ghost) - .small() - .accessibility_label(side.toggle_label()) - .on_click({ - let state = state.clone(); - move |_, _, cx| match side { - Side::Left => { + .child(titlebar_strip( + div() + .id(SharedString::from(format!( + "sidebar-strip-drag-{}", + side.name() + ))) + .flex_1() + .self_stretch(), + window, + cx, + )) + .map(|strip| match side { + Side::Left => strip.child( + Button::new(SharedString::from(format!( + "sidebar-toggle-{}", + side.name() + ))) + .icon(side.toggle_icon()) + .variant(ButtonVariant::Ghost) + .small() + .accessibility_label(side.toggle_label()) + .on_click({ + let state = state.clone(); + move |_, _, cx| { state.update(cx, |state, cx| state.set_left_sidebar_visible(false, cx)) } - Side::Right => { - state.update(cx, |state, cx| state.set_right_sidebar_visible(false, cx)) - } - } - }), - ); + }), + ), + Side::Right => strip.child(WindowControls::new("sidebar-window-controls")), + }); v_flex() .w(width) diff --git a/crates/layout/src/window_controls.rs b/crates/layout/src/window_controls.rs index 355bcf2..d4deaae 100644 --- a/crates/layout/src/window_controls.rs +++ b/crates/layout/src/window_controls.rs @@ -166,9 +166,7 @@ pub fn maximize_on_double_click() -> impl Fn(&ClickEvent, &mut Window, &mut App) } } -/// Makes an element a titlebar strip: pressing and dragging it moves the -/// window, double-clicking maximizes, and Windows keeps its native caption -/// behavior through the `Drag` control area. +/// Makes an element a titlebar strip. pub fn titlebar_strip(this: Stateful