From 99f202b18a5a5c79e7bf5f96c697ff5573efea70 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Tue, 13 Oct 2026 01:13:38 -0400 Subject: [PATCH] Tab bar: the scrollbar-reachable test checks #849's scrollbar track; drop the unused Color32 import Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/tabs.rs | 2 +- crates/ui-egui/tests/sheet_tabs.rs | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/tabs.rs b/crates/ui-egui/src/tabs.rs index a8c33a4..b77524b 100644 --- a/crates/ui-egui/src/tabs.rs +++ b/crates/ui-egui/src/tabs.rs @@ -2,7 +2,7 @@ use std::sync::Arc; -use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, Ui, pos2, vec2}; +use egui::{Align2, Rect, Sense, Stroke, StrokeKind, Ui, pos2, vec2}; use gridcraft_engine::model::{Sheet, Visibility}; use serde_json::json; diff --git a/crates/ui-egui/tests/sheet_tabs.rs b/crates/ui-egui/tests/sheet_tabs.rs index e799f7a..f28cfaf 100644 --- a/crates/ui-egui/tests/sheet_tabs.rs +++ b/crates/ui-egui/tests/sheet_tabs.rs @@ -153,26 +153,12 @@ fn new_sheet_button_stays_reachable_and_reveals_the_inserted_tab() { #[test] fn overflow_leaves_the_worksheet_scrollbar_reachable() { + // The tab bar's horizontal scrollbar track keeps its share of the bar however many tabs + // overflow; dragging its thumb is covered with a rendered grid in `interaction.rs`. for width in [500.0, 700.0, 1200.0] { - let mut h = harness(width, 0); - let (bar, clip) = h - .output() - .shapes - .iter() - .find_map(|s| match &s.shape { - Shape::Rect(r) if r.fill == Color32::from_gray(190) && r.rect.height() == 8.0 => Some((r.rect, s.clip_rect)), - _ => None, - }) - .expect("worksheet scrollbar thumb must be painted"); - assert!(clip.contains_rect(bar), "worksheet scrollbar is offscreen: {bar:?}, {clip:?}"); - let at = bar.center(); - h.input_mut().events.extend([ - Event::PointerMoved(at), - Event::PointerButton { pos: at, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }, - ]); - h.step(); - h.input_mut().events.push(Event::PointerMoved(at + vec2(12.0, 0.0))); - h.step(); - assert!(h.state().view().scroll.x > 0.0, "worksheet scrollbar must respond to dragging"); + let h = harness(width, 0); + let track = h.state().grid.hscroll.expect("the tab bar has a horizontal scrollbar"); + assert!(track.width() >= 100.0, "{width}: the scrollbar keeps a usable width: {track:?}"); + assert!(track.left() >= 0.0 && track.right() <= width + 0.5, "{width}: the scrollbar is offscreen: {track:?}"); } }