From 47519e81bac6a8518889c91cecabc7a39a10f801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 20 Aug 2026 00:14:31 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore(app):=20the=20compiler=20h?= =?UTF-8?q?as=20nothing=20left=20to=20say?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The uniform lanes_shown/rows_below pair went with their last caller (the mixed math is the render's), their pins moved onto the mixed variants, and the escape rule's re-export is the tests' alone. --- crates/app/src/layout.rs | 21 --------------------- crates/app/src/main.rs | 2 ++ crates/app/src/tests/layout.rs | 34 ++++++++++++---------------------- crates/app/src/tests/mod.rs | 4 ++-- 4 files changed, 16 insertions(+), 45 deletions(-) diff --git a/crates/app/src/layout.rs b/crates/app/src/layout.rs index 03f398c..41d7641 100644 --- a/crates/app/src/layout.rs +++ b/crates/app/src/layout.rs @@ -216,27 +216,6 @@ pub(crate) fn lanes_h(lanes: usize) -> f32 { } } -/// How many whole lane rows a box this tall shows. At least one: a box too -/// short for a single lane still shows part of one, and "0 shown" would count -/// every lane there is as hidden. -pub(crate) fn lanes_shown(box_h: f32) -> usize { - (((box_h + 8.) / (LANE_H + 8.)).floor() as usize).max(1) -} - -/// How many rows are still below the fold *now*: the count the affordance says -/// out loud, and the reason it is a function of the scroll rather than of the -/// lane count alone. A line that keeps saying "2 more tracks below" after the -/// user has scrolled to the last one is a line that has stopped being true, and -/// an affordance nobody can make go away is read as a bug rather than as an -/// instruction. -/// -/// `scrolled` is how far down the column has been taken, in pixels. Rounded to -/// the nearest row: a half-scrolled row is showing, so it is not below. -pub(crate) fn rows_below(total: usize, box_h: f32, scrolled: f32) -> usize { - let past = ((scrolled / (LANE_H + 8.)).round().max(0.)) as usize; - total.saturating_sub(past + lanes_shown(box_h)) -} - /// How tall one lane row is: [`LANE_H`] for a media track, [`SUB_LANE_H`] for /// a caption one -- the one place that answer is decided, since /// [`lanes_h_mixed`], [`lanes_shown_mixed`] and [`rows_below_mixed`] all walk diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 7578afe..f8a016f 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -30,6 +30,8 @@ pub(crate) use interact::*; pub(crate) use layout::*; pub(crate) use library_meta::*; pub(crate) use menus::*; +// The tests' door to the escape rule; render.rs calls it by its own name. +#[cfg(test)] pub(crate) use render::escape_leaves_player_fullscreen; pub(crate) use notices::*; pub(crate) use oracle::*; diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index b7cea15..6459e5a 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -74,31 +74,15 @@ fn the_line_about_what_is_below_the_fold_counts_what_is_still_below_it() { "{} px of chrome and a lane will not fit {floor} px", timeline_fixed_h(true) ); - // What is left over is measured in whole lanes, at least one. - assert_eq!(lanes_shown(LANE_H), 1); - assert_eq!(lanes_shown(LANE_H - 10.), 1); - assert_eq!(lanes_shown(2. * LANE_H + 8.), 2); - - // Four tracks in a two-lane box: two are below, and each row scrolled - // past takes one off that count until none is left. This is the bug the - // graft fixes -- the count used to be `total - shown` forever, so the - // line still said "2 more below" with the last track on screen. - let box_h = 2. * LANE_H + 8.; - assert_eq!(rows_below(4, box_h, 0.), 2); - assert_eq!(rows_below(4, box_h, LANE_H + 8.), 1); - assert_eq!(rows_below(4, box_h, 2. * (LANE_H + 8.)), 0); - // Past the end (gpui clamps, but the arithmetic must not wrap). - assert_eq!(rows_below(4, box_h, 900.), 0); - // A project that fits says nothing at all. - assert_eq!(rows_below(2, box_h, 0.), 0); - - // The same three questions once a lane in the stack is a thinner + // The lane questions, asked of the mixed math the render actually walks + // (the uniform lanes_shown/rows_below pair went with their last caller; + // a lane in the stack may be a thinner // caption one: a uniform stack answers exactly what the plain // functions above do, and a mixed one answers off the real heights, // never the media one alone. let uniform = [LaneKind::Video, LaneKind::Audio]; assert_eq!(lanes_h_mixed(&uniform), lanes_h(2)); - assert_eq!(lanes_shown_mixed(&uniform, LANE_H), lanes_shown(LANE_H)); + assert_eq!(lanes_shown_mixed(&uniform, LANE_H), 1); let mixed = [LaneKind::Video, LaneKind::Audio, LaneKind::Subtitle]; assert_eq!( lanes_h_mixed(&mixed), @@ -411,7 +395,10 @@ fn the_scroll_strip_row_comes_and_goes_with_the_zoom() { // either face of the zoom boundary. let floor = split_size(Split::Timeline, Some(0.), 2, window, scroll); let box_h = floor - timeline_fixed_h(scroll); - assert!(2 > lanes_shown(box_h), "no line to pay for at the floor"); + assert!( + 2 > lanes_shown_mixed(&[LaneKind::Video, LaneKind::Audio], box_h), + "no line to pay for at the floor" + ); assert!( box_h - LABEL_H - 8. >= LANE_H, "the floor leaves {} px for a {LANE_H} px lane", @@ -1637,7 +1624,10 @@ fn a_dragged_divider_stops_before_either_panel_disappears() { // ([`Player::timeline`]): what the affordance costs comes off the box, and // a whole lane is still standing under it. let lanes_box = floor - timeline_fixed_h(true); - assert!(2 > lanes_shown(lanes_box), "no line to pay for at the floor"); + assert!( + 2 > lanes_shown_mixed(&[LaneKind::Video, LaneKind::Audio], lanes_box), + "no line to pay for at the floor" + ); assert!( lanes_box - LABEL_H - 8. >= LANE_H, "the floor leaves {} px for a {LANE_H} px lane", diff --git a/crates/app/src/tests/mod.rs b/crates/app/src/tests/mod.rs index 72eabe4..b94c805 100644 --- a/crates/app/src/tests/mod.rs +++ b/crates/app/src/tests/mod.rs @@ -34,8 +34,8 @@ use super::{ LATE_RESYNC, RESYNC_GAP, should_resync, retarget, row_enable, row_items, scrub_due, secs_label, show_label, silence_rate, size_label, snap_cue, snap_marks, snapped, SUB_PLAN_CHARS, source_tint, span_partner, speed_at, sub_pick_after_removal, subtitle_plan, summary_head, summary_tail, timecode, transport, - EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_SHARE, lanes_shown, timeline_fixed_h, - px_below, rows_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone, + EXPORT_DONE, NOTICES_MAX, STATUS_ERROR, TIMELINE_SHARE, timeline_fixed_h, + px_below, STATUS_SUCCESS, STATUS_WARNING, notice_tone, proxies_to_start, push_notice, typed, unseen_paths, unseen_sources, whole_take, window_title, };