mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-31 14:17:12 -06:00
Merge PR #949: Sheet tabs: New sheet (+) right after the last tab, the strip capped at 60%
Conflicts: docs/ui-parity.md (header change text, sheet tabs row and change log: union of both sides)
This commit is contained in:
@@ -69,7 +69,8 @@ pub fn sheet_tabs(app: &mut SheetApp, ui: &mut Ui) {
|
||||
.map(|(i, s)| (i, s.name.clone(), s.tab_color.and_then(|c| c.resolve(&d.wb.theme)), i == d.wb.active_sheet))
|
||||
.collect();
|
||||
// Keep worksheet tabs in their own horizontally scrollable viewport. As in Excel, the
|
||||
// tabs get 60% of the bar and the grid's horizontal scrollbar the rest.
|
||||
// tabs get up to 60% of the bar and the grid's horizontal scrollbar the rest; a strip
|
||||
// that needs less shrinks to its tabs, so New sheet (+) sits right after the last one.
|
||||
let tabs_width = (ui.available_width() * 0.6).max(100.0);
|
||||
// Reveal the selected sheet after navigation or layout changes, but
|
||||
// allow browsing other tabs without snapping back on every frame.
|
||||
@@ -94,7 +95,7 @@ pub fn sheet_tabs(app: &mut SheetApp, ui: &mut Ui) {
|
||||
|
||||
egui::ScrollArea::horizontal()
|
||||
.id_salt("worksheet_tabs_horizontal")
|
||||
.auto_shrink([false, false])
|
||||
.auto_shrink([true, false])
|
||||
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysHidden)
|
||||
.show(ui, |ui| {
|
||||
if wheel_scroll.abs() > 0.0 {
|
||||
|
||||
@@ -7,10 +7,14 @@ use serde_json::json;
|
||||
type Harness = egui_kittest::Harness<'static, SheetApp>;
|
||||
|
||||
fn harness(width: f32, active: usize) -> Harness {
|
||||
harness_with(width, 30, active)
|
||||
}
|
||||
|
||||
fn harness_with(width: f32, sheets: usize, active: usize) -> Harness {
|
||||
let mut s = Session::new();
|
||||
s.new_workbook();
|
||||
s.execute("sheet.rename", json!({"sheet":0,"name":"Tab00"})).unwrap();
|
||||
for i in 1..30 {
|
||||
for i in 1..sheets {
|
||||
s.execute("home.insertSheet", json!({"name":format!("Tab{i:02}")})).unwrap();
|
||||
}
|
||||
s.execute("sheet.activate", json!({"sheet":active})).unwrap();
|
||||
@@ -162,3 +166,43 @@ fn overflow_leaves_the_worksheet_scrollbar_reachable() {
|
||||
assert!(track.left() >= 0.0 && track.right() <= width + 0.5, "{width}: the scrollbar is offscreen: {track:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The New sheet button's left edge. The scrollbar track starts 8 px after the 26 px button.
|
||||
fn new_sheet_left(h: &Harness) -> f32 {
|
||||
h.state().grid.hscroll.expect("the tab bar has a horizontal scrollbar").left() - 8.0 - 26.0
|
||||
}
|
||||
|
||||
/// The painted background of the active tab: the smallest fill enclosing its name (the bar's own fill encloses it too).
|
||||
fn active_tab_rect(h: &Harness, name: &str) -> Rect {
|
||||
let (text, _) = tab(h, name).unwrap();
|
||||
h.output()
|
||||
.shapes
|
||||
.iter()
|
||||
.filter_map(|s| match &s.shape {
|
||||
Shape::Rect(r) if r.rect.contains_rect(text) => Some(r.rect),
|
||||
_ => None,
|
||||
})
|
||||
.min_by(|a, b| a.area().total_cmp(&b.area()))
|
||||
.unwrap_or_else(|| panic!("{name} has no painted tab background"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_sheet_button_follows_the_last_tab() {
|
||||
for width in [700.0, 1200.0] {
|
||||
let h = harness_with(width, 2, 1);
|
||||
let last = active_tab_rect(&h, "Tab01");
|
||||
let plus = new_sheet_left(&h);
|
||||
assert!(plus >= last.right() && plus - last.right() <= 12.0, "{width}: + at {plus}, last tab ends at {}", last.right());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overflowing_tabs_keep_their_share_and_the_new_sheet_button_after_it() {
|
||||
for width in [700.0, 1200.0] {
|
||||
let h = harness(width, 0);
|
||||
let (_, viewport) = tab(&h, "Tab00").unwrap();
|
||||
assert!(viewport.width() <= width * 0.6, "{width}: the tab strip grew past its share: {viewport:?}");
|
||||
let plus = new_sheet_left(&h);
|
||||
assert!(plus >= viewport.right() && plus - viewport.right() <= 12.0, "{width}: + at {plus}, strip ends at {}", viewport.right());
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
# UI parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-19 · **Change:** minor (next/previous sheet navigation stops at visible-sheet boundaries; Ctrl+Enter fill gives each cell the automatic number format typing gives it; keytip letters typed with Alt held, #1846) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-19 · **Change:** minor (New sheet (+) right after the last sheet tab, #943; next/previous sheet navigation stops at visible-sheet boundaries; Ctrl+Enter fill gives each cell the automatic number format typing gives it; keytip letters typed with Alt held, #1846) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4
|
||||
|
||||
Interaction, controls and feel, against Excel. Part of [target-app-parity.md](target-app-parity.md).
|
||||
**UI/UX fidelity: ~55% ready, 50–80 h** (estimated). Ribbon command coverage is measured
|
||||
@@ -21,7 +21,7 @@ Sources: `crates/ui-egui/src` (ribbon, grid, editor, formula bar, dialogs, panes
|
||||
| Ribbon collapse, simplified ribbon, customize ribbon/QAT | yes | partial | customization missing |
|
||||
| Key tips (Alt / F10 then letters) | yes, every ribbon control | **initial** (#43, 10-10): Alt or F10 shows key tips on Home for alignment, Paste Special and AutoFit plus legacy Alt sequences; other tabs and controls not yet (#33, #49) | 3–5 h |
|
||||
| Formula bar with Name Box, expand, function hints | yes | yes | done |
|
||||
| Sheet tabs: rename, reorder, colour, hide, scroll | yes | yes | active tab revealed on navigation and resize (#681); manual wheel/trackpad browsing preserved; next/previous skips Hidden and VeryHidden sheets and retains the current sheet and selection when no visible destination exists; rename focus bug on macOS (#145) |
|
||||
| Sheet tabs: rename, reorder, colour, hide, scroll | yes | yes | active tab revealed on navigation and resize (#681); New sheet (+) right after the last tab, the strip capped at 60% of the bar (#943); manual wheel/trackpad browsing preserved; next/previous skips Hidden and VeryHidden sheets and retains the current sheet and selection when no visible destination exists; rename focus bug on macOS (#145) |
|
||||
| Status bar: Sum/Count/Average and more, view buttons, zoom | yes | yes | customizable statistics partial |
|
||||
| Task panes (Format Chart, Comments, Watch, Selection, PivotTable fields) | yes | yes | element-level Format pane for shapes and pictures missing |
|
||||
| Backstage (File) view: Info, New with templates, Open recent, Export, Options | yes | partial | Options dialog and template gallery missing |
|
||||
@@ -164,6 +164,7 @@ scrollbar bugs 2–4 · pixel/feel pass against observed Excel 7–12.
|
||||
| 2026-10-19 | minor | Ctrl+Enter (`range.fill`) gives each cell what typing the input there gives: a General cell gets the automatic number format (`5%`, `$5`, `3/4/2026`, `=TODAY()`) even when it already held a value, and a cell with its own format, a formatted row or column, or Text keeps it. Cells that held a value used to keep General (`5%` showed 0.05), and empty cells took the active cell's format |
|
||||
| 2026-10-18 | minor | Keytip letters typed with left Alt held continue the sequence (Alt+H, O, A / Alt+H, O, I ran nothing before: Alt+letter cancelled keytips); other Alt combinations, AltGr and macOS Option are unchanged (#1846) |
|
||||
| 2026-10-12 | minor | Next/previous sheet navigation no longer activates hidden worksheets at either workbook boundary; command tests cover Hidden, VeryHidden and selection retention |
|
||||
| 2026-10-13 | minor | Sheet tab bar: the tab strip shrinks to its tabs, up to 60% of the bar, so New sheet (+) sits right after the last tab and the horizontal scrollbar takes the rest (part of #943) |
|
||||
| 2026-10-12 | minor | The File view's recent list tells when each workbook was last changed, read off the UI thread |
|
||||
| 2026-10-13 | minor | Horizontal scrollbar in the sheet tab bar: drag, track click pages, frozen columns excluded from the page (#840) |
|
||||
| 2026-10-12 | minor | Ctrl+wheel zoom steps along a ladder of percentages about 20% apart that never skips 100%, gliding to each step with animations on, so a notch out undoes a notch in (it drifted: 100 → 122 → 101); Excel steps 15 points, see decisions.md |
|
||||
|
||||
Reference in New Issue
Block a user