Tab bar: the scrollbar-reachable test checks #849's scrollbar track; drop the unused Color32 import
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4536bc7fc8
commit
99f202b18a
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::sync::Arc;
|
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 gridcraft_engine::model::{Sheet, Visibility};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,26 +153,12 @@ fn new_sheet_button_stays_reachable_and_reveals_the_inserted_tab() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn overflow_leaves_the_worksheet_scrollbar_reachable() {
|
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] {
|
for width in [500.0, 700.0, 1200.0] {
|
||||||
let mut h = harness(width, 0);
|
let h = harness(width, 0);
|
||||||
let (bar, clip) = h
|
let track = h.state().grid.hscroll.expect("the tab bar has a horizontal scrollbar");
|
||||||
.output()
|
assert!(track.width() >= 100.0, "{width}: the scrollbar keeps a usable width: {track:?}");
|
||||||
.shapes
|
assert!(track.left() >= 0.0 && track.right() <= width + 0.5, "{width}: the scrollbar is offscreen: {track:?}");
|
||||||
.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");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue