forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'worktree-agent-a3c7e2b85886de2fb'

Browse files at this commit

9c4d7ce087cec6f6c5caed8b2718acd24580c7f1Ahmet Kaan GümüşParent: 701700f373d93f
# Conflicts:
#	crates/app/src/tests/layout.rs
crates/app/src/interact.rsmodified+39 -7
@@ -238,20 +238,52 @@ pub(crate) fn drag_scrim(cx: &mut Context<Player>) -> Div {
238 /// where the pointer stays, and a divider whose own listeners tracked it would238 /// where the pointer stays, and a divider whose own listeners tracked it would
239 /// stop following the hand on the first move. `stop_propagation` so the press239 /// stop following the hand on the first move. `stop_propagation` so the press
240 /// never reaches the region under it -- a seam over the timeline must not scrub.240 /// never reaches the region under it -- a seam over the timeline must not scrub.
241-pub(crate) fn divider(split: Split, cx: &mut Context<Player>) -> Div {241+///
242+/// Drawn to the ghost grammar (DESIGN §11.2): nothing at rest -- a room whose
243+/// every seam is inked is the "crowded" the user named -- then one hairline of
244+/// dim ink under the pointer, and the same line one step brighter while the
245+/// hand is actually holding it. The 6 px strip is the *hit* area throughout;
246+/// only its 1 px edge is ever painted. `held` is the seam this window is
247+/// dragging right now ([`Player::split_drag`]), which the pointer leaves on the
248+/// first move -- so the lit line has to come from the model, not from `hover`.
249+///
250+/// A double press resets the seam to the window's own share
251+/// ([`Splits::clear`]): the cheap way back from a layout dragged somewhere
252+/// unusable, and the one every editor's dividers answer to.
253+pub(crate) fn divider(split: Split, held: bool, cx: &mut Context<Player>) -> Div {
242 let across = matches!(split, Split::Timeline | Split::Bench);254 let across = matches!(split, Split::Timeline | Split::Bench);
243 div()255 div()
244 .flex_none()256 .flex_none()
245- .when(across, |d| d.h(px(SPLIT_W)).w_full().cursor_row_resize())257+ .when(across, |d| {
246- .when(!across, |d| d.w(px(SPLIT_W)).h_full().cursor_col_resize())258+ d.h(px(SPLIT_W)).w_full().cursor_row_resize().border_t_1()
247- .bg(rgb(STROKE_DIVIDER()))259+ })
260+ .when(!across, |d| {
261+ d.w(px(SPLIT_W)).h_full().cursor_col_resize().border_l_1()
262+ })
263+ .border_color(match held {
264+ true => gpui::Hsla::from(rgb(INK3())),
265+ false => gpui::transparent_black(),
266+ })
248 // Lit under the pointer: the second half of "this can be dragged", said267 // Lit under the pointer: the second half of "this can be dragged", said
249 // before the button goes down rather than after.268 // before the button goes down rather than after.
250- .hover(|s| s.bg(rgb(ACCENT_PRIMARY())))269+ .when(!held, |d| {
270+ d.hover(|s| s.border_color(rgb(STROKE_DIVIDER())))
271+ })
251 .on_mouse_down(272 .on_mouse_down(
252 MouseButton::Left,273 MouseButton::Left,
253- cx.listener(move |this, _: &MouseDownEvent, _, cx| {274+ cx.listener(move |this, event: &MouseDownEvent, _, cx| {
254- this.split_drag = Some(split);275+ match event.click_count >= 2 {
276+ // The reset is written where a release would have written
277+ // the drag, the same small round trip: a seam put back by
278+ // hand must not come back on the next launch.
279+ true => {
280+ this.split_drag = None;
281+ this.splits.clear(split);
282+ crate::layout::save_stance_splits(&this.splits);
283+ }
284+ false => this.split_drag = Some(split),
285+ }
286+ cx.notify();
255 cx.stop_propagation();287 cx.stop_propagation();
256 }),288 }),
257 )289 )
crates/app/src/layout.rsmodified+14 -2
@@ -373,14 +373,26 @@ impl Splits {
373 }373 }
374 }374 }
375 375
376+ /// Forgets a seam's dragged size, which is exactly what
377+ /// [`split_size`] reads as "the window's own share answers again" --
378+ /// the double-click reset, one field rather than a second table of
379+ /// defaults that could disagree with the one already there.
380+ pub(crate) fn clear(&mut self, split: Split) {
381+ *self.slot(split) = None;
382+ }
383+
376 pub(crate) fn set(&mut self, split: Split, size: f32) {384 pub(crate) fn set(&mut self, split: Split, size: f32) {
377- *match split {385+ *self.slot(split) = Some(size);
386+ }
387+
388+ fn slot(&mut self, split: Split) -> &mut Option<f32> {
389+ match split {
378 Split::Library => &mut self.library,390 Split::Library => &mut self.library,
379 Split::Inspector => &mut self.inspector,391 Split::Inspector => &mut self.inspector,
380 Split::Timeline => &mut self.timeline,392 Split::Timeline => &mut self.timeline,
381 Split::Dock => &mut self.dock,393 Split::Dock => &mut self.dock,
382 Split::Bench => &mut self.bench,394 Split::Bench => &mut self.bench,
383- } = Some(size);395+ }
384 }396 }
385 }397 }
386 398
crates/app/src/tests/layout.rsmodified+56 -0
@@ -2739,3 +2739,59 @@ fn the_bench_answers_a_wheel_notch_anywhere_over_it() {
2739 "the ruler answers the wheel on its own again -- one notch, two scrolls"2739 "the ruler answers the wheel on its own again -- one notch, two scrolls"
2740 );2740 );
2741 }2741 }
2742+
2743+/// The way back from a layout dragged somewhere unusable: a double press on
2744+/// the seam forgets the size, and the region is the window's own share again
2745+/// -- the *same* share an untouched window gives it, not a second default
2746+/// kept beside the first ([`Splits::clear`]).
2747+#[test]
2748+fn a_double_pressed_divider_forgets_the_size_it_was_dragged_to() {
2749+ use crate::layout::{Split, Splits, split_size};
2750+ use gpui::{px, size};
2751+
2752+ let window = size(px(1280.), px(720.));
2753+ let mut splits = Splits::default();
2754+ for split in Split::PERSISTED {
2755+ let default = split_size(split, None, 2, window, false);
2756+ // A hand takes the seam somewhere else...
2757+ splits.set(split, split_size(split, Some(300.), 2, window, false));
2758+ assert_ne!(
2759+ splits.get(split),
2760+ None,
2761+ "{split:?} kept nothing of the drag"
2762+ );
2763+ // ...and the double press puts it back where an untouched window
2764+ // would have drawn it.
2765+ splits.clear(split);
2766+ assert_eq!(splits.get(split), None, "{split:?} still holds a size");
2767+ assert_eq!(
2768+ split_size(split, splits.get(split), 2, window, false),
2769+ default,
2770+ "{split:?} came back to something other than its own share"
2771+ );
2772+ }
2773+}
2774+
2775+/// The seam is a ghost (DESIGN §11.2): 6 px of hit area with *nothing* painted
2776+/// at rest, one hairline of dim ink under the pointer, the same line one step
2777+/// brighter while it is held. The scan is the guard because the failure it
2778+/// catches -- a `bg` on the strip, which is what the divider shipped with --
2779+/// draws a 6 px band of colour down the room at rest and reads as the chrome
2780+/// the user called crowded.
2781+#[test]
2782+fn the_seam_paints_nothing_until_a_pointer_finds_it() {
2783+ let src = src_text("interact.rs");
2784+ let start = src.find("pub(crate) fn divider(").expect("the divider");
2785+ let body = &src[start..start + src[start..].find("\n}\n").expect("its end")];
2786+ assert!(
2787+ !body.contains(".bg("),
2788+ "the divider fills its strip at rest: {body}"
2789+ );
2790+ assert!(
2791+ body.contains("gpui::transparent_black()"),
2792+ "the divider's line is inked at rest: {body}"
2793+ );
2794+ for step in [".hover(", "STROKE_DIVIDER()", "INK3()", "border_t_1()", "border_l_1()"] {
2795+ assert!(body.contains(step), "the divider is missing {step}");
2796+ }
2797+}
crates/app/src/ui/stance.rsmodified+2 -2
@@ -1093,7 +1093,7 @@ pub(crate) fn render(
1093 .flex_col()1093 .flex_col()
1094 .child(screen(player, position, window, cx))1094 .child(screen(player, position, window, cx))
1095 .child(time_band(player, position, cx))1095 .child(time_band(player, position, cx))
1096- .child(divider(Split::Bench, cx))1096+ .child(divider(Split::Bench, player.split_drag == Some(Split::Bench), cx))
1097 .child(bench(player, bench_h, window, cx))1097 .child(bench(player, bench_h, window, cx))
1098 .child(ledger(player, position))1098 .child(ledger(player, position))
1099 .when(player.keys_open, |el| {1099 .when(player.keys_open, |el| {
@@ -1143,7 +1143,7 @@ pub(crate) fn render(
1143 .children(player.subtitle_style_card(window_size, cx))1143 .children(player.subtitle_style_card(window_size, cx))
1144 }),1144 }),
1145 )1145 )
1146- .child(divider(Split::Dock, cx))1146+ .child(divider(Split::Dock, player.split_drag == Some(Split::Dock), cx))
1147 .child(dock(player, dock_w, window_size, window, cx))1147 .child(dock(player, dock_w, window_size, window, cx))
1148 // The library row menu mounts on the ROOT, not inside1148 // The library row menu mounts on the ROOT, not inside
1149 // `stance-centre` like the clip menu beside it: it is opened from a1149 // `stance-centre` like the clip menu beside it: it is opened from a