mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-10 12:29:58 -06:00
#3101: clear the tab bar's cached rectangles when a control is hidden
Addresses review comment 4453674677: after a frame drew both controls, turning off the horizontal scroll bar or the sheet tabs left app.grid.hscroll / app.grid.tab_split holding the old rectangles. sheet_tabs now clears both before any visibility return. Test: tab_split::hiding_the_controls_clears_their_cached_rectangles toggles both options on one live harness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
846cc09d67
commit
fe6ab7c5c0
@@ -100,6 +100,9 @@ fn tab_split_handle(app: &mut SheetApp, ui: &mut Ui, split: Rect, bar: (f32, f32
|
||||
/// Draws the worksheet tab strip: navigation, scroll/reveal, rename/drag/move with optional copy, context menu, new-sheet button, split handle and grid scrollbar.
|
||||
pub fn sheet_tabs(app: &mut SheetApp, ui: &mut Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
// Only the controls drawn this frame have a rectangle: a hidden one keeps no stale geometry.
|
||||
app.grid.hscroll = None;
|
||||
app.grid.tab_split = None;
|
||||
// File › Options › Advanced › Display options for this workbook (#3101): with neither the
|
||||
// sheet tabs nor the horizontal scroll bar, the bar isn't there at all.
|
||||
let view = app.session.active().map(|d| d.wb.view).unwrap_or_default();
|
||||
|
||||
@@ -197,3 +197,24 @@ fn display_options_hide_the_sheet_tabs_and_the_horizontal_scroll_bar() {
|
||||
h.run_steps(5);
|
||||
assert!(!shows_tab_name(&h) && h.state().grid.hscroll.is_none() && h.state().grid.tab_split.is_none(), "no bar at all");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hiding_the_controls_clears_their_cached_rectangles() {
|
||||
// Turned off on a live window, the controls drop the rectangles of the frame that drew them.
|
||||
let mut h = harness(900.0, 1);
|
||||
assert!(h.state().grid.tab_split.is_some() && h.state().grid.hscroll.is_some(), "both controls drawn first");
|
||||
|
||||
h.state_mut().run("view.showSheetTabs", json!({"on": false})).unwrap();
|
||||
h.run_steps(5);
|
||||
assert!(h.state().grid.tab_split.is_none(), "no split handle once the tabs are hidden");
|
||||
assert!(h.state().grid.hscroll.is_some(), "the scroll bar stays");
|
||||
|
||||
h.state_mut().run("view.showSheetTabs", json!({"on": true})).unwrap();
|
||||
h.state_mut().run("view.showHorizontalScrollBar", json!({"on": false})).unwrap();
|
||||
h.run_steps(5);
|
||||
assert!(h.state().grid.hscroll.is_none() && h.state().grid.tab_split.is_none(), "no scroll bar and no split handle");
|
||||
|
||||
h.state_mut().run("view.showSheetTabs", json!({"on": false})).unwrap();
|
||||
h.run_steps(5);
|
||||
assert!(h.state().grid.hscroll.is_none() && h.state().grid.tab_split.is_none(), "no bar at all");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user