mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-05 01:58:58 +00:00
Options: keep the active row's band visible on a faded page
In Page Layout view the "Click to add data" pages are faded after their cells are painted, which all but hid the band on them. The band goes on again over the fade. Tests also cover Page Layout view and frozen panes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
38a7067ca2
commit
ee6b9fdcee
2 files changed
+30
No files matched your search
@@ -178,6 +178,10 @@ pub(crate) fn paint_pages(input: PagePaintInput<'_>, cf: &mut CfCache) -> Vec<gr
|
||||
if !pg.is_data_page(i, j) {
|
||||
// "Click to add data" pages: faded until something is typed there.
|
||||
pc.rect_filled(clip, 0.0, t.grid_bg.gamma_multiply(0.75));
|
||||
// The fade would all but hide the active row's band: it goes on again.
|
||||
if let Some(band) = active_row.and_then(|row| grid::active_row_band(geo, sh, row, rows, cols)) {
|
||||
pc.rect_filled(band, 0.0, t.active_row);
|
||||
}
|
||||
let size = (14.0 * geo.z / DISPLAY_SCALE).clamp(8.0, 22.0);
|
||||
pc.text(clip.center(), Align2::CENTER_CENTER, tr(app, "Click to add data"), theme::ui_font(size), Color32::from_gray(150));
|
||||
}
|
||||
|
||||
@@ -122,3 +122,29 @@ fn a_hidden_row_or_a_row_outside_the_quadrant_has_no_band() {
|
||||
assert_eq!(active_row_band(&geo, sheet, 30, (0, 20), (0, 5)), None, "outside");
|
||||
assert!(active_row_band(&geo, sheet, 6, (0, 20), (0, 5)).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_page_layout_the_band_shows_on_a_click_to_add_data_page_too() {
|
||||
let mut h = harness(book("C5"));
|
||||
h.state_mut().run("options.highlightActiveRow", json!({"on": true})).unwrap();
|
||||
h.state_mut().session.execute("view.pageLayout", json!({})).unwrap();
|
||||
h.run_steps(3);
|
||||
let bands = tinted(&h);
|
||||
// Each page paints its own part of the row; the faded page paints it again over the fade.
|
||||
let repeated = bands.iter().filter(|b| bands.iter().filter(|o| o == b).count() == 2).count();
|
||||
assert_eq!(repeated, 2, "{bands:?}");
|
||||
assert!(bands.iter().all(|b| b.top() == bands[0].top()), "one row: {bands:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_frozen_panes_the_band_crosses_the_frozen_columns() {
|
||||
let mut h = harness(book("C5"));
|
||||
h.state_mut().session.execute("selection.set", json!({"range": "C3"})).unwrap();
|
||||
h.state_mut().session.execute("view.freezePanes", json!({})).unwrap();
|
||||
h.state_mut().session.execute("selection.set", json!({"range": "E7"})).unwrap();
|
||||
h.state_mut().run("options.highlightActiveRow", json!({"on": true})).unwrap();
|
||||
h.run_steps(2);
|
||||
let bands = tinted(&h);
|
||||
assert_eq!(bands.len(), 2, "the frozen columns' pane and the scrolling one: {bands:?}");
|
||||
assert_eq!(bands[0].top(), bands[1].top());
|
||||
}
|
||||
Reference in new issue
Block a user