Skip to content

Grid: an armed Format Painter pastes onto the next cells clicked or dragged - #1214

Merged
aiongg merged 2 commits into
storytold:mainfrom
marcoarnulfo:fix/format-painter-armed-state
Oct 22, 2026
Merged

aiongg merged 2 commits into
storytold:mainfrom
marcoarnulfo:fix/format-painter-armed-state

Conversation

@marcoarnulfo

@marcoarnulfo marcoarnulfo commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1211, fixes #1355, fixes #1374.

The ribbon button was fine: a click picked up the selection's format and the button showed as pressed. The missing half was on the grid side. edit.formatPainter only pastes when it is called with {apply: range}, and nothing in the UI ever made that call, so the next click on a cell just selected it and the painter stayed armed with nothing happening. The grid now makes that call when a cell selection is released (click or drag), with the cells just selected as the target. A single-click painter turns itself off afterwards and a double-clicked one stays on, both handled by the existing command. Releases in formula point mode are skipped, because that mode also uses the Select drag. The button also gets an accessibility label and toggled state, like Paste and Borders already have, so the test can find it.

Clicks on row or column headers don't paint yet (they use a different drag). Happy to add that here or in a follow-up.

Validation:

  • format_painter::ribbon_button_picks_up_the_format_and_a_click_on_a_cell_pastes_it (kittest: bold + fill on A1, click the ribbon button, click C3): fails on main (C3 keeps the default style), passes here
  • cargo test -p gridcraft-ui-egui --test selection --test interaction --test selection_fill --test formula_point_headers --test keytips_generated
  • cargo clippy -p gridcraft-ui-egui --all-targets -- -D warnings, cargo fmt --all -- --check
  • (macOS, Apple silicon)

Header clicks now paint too (thanks @tisca26 for testing): with the painter armed, a click or drag on row or column headers pastes the format onto the whole rows/columns, with the same single-click/double-click behaviour. Dragging from the header of an already selected column now paints instead of moving the column. Whole lines take a row/column format (the same way home.bold on C:C works) from the first cell of the source pattern, and only cells already stored follow the pattern, so painting a column no longer stores a million cells. Cells of a painted column in rows that carry their own row format get the style explicitly, since a row format would otherwise hide it. Row heights and column widths are not copied: I couldn't confirm in Microsoft's documentation whether Excel's Format Painter carries them over.

Tests in format_painter.rs (header click on a row, drag over column headers with a kept painter, drag from the picked-up column, two-cell source on a column header with a formatted row) fail without the change and pass here.

@tisca26

tisca26 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Tested this branch (5e5e131) on macOS 27.0.1 (Apple silicon) with cargo run -p gridcraft, on a real workbook with mixed font sizes. Before this change, Format Painter had no effect in the v0.7.0 release.

  • Single click: picking up B500:I500 and dragging over B502:I502 pastes the format, and the painter turns itself off afterwards. ✅
  • Double click: the painter stays armed across two pastes in a row (rows 503 and 504). ✅
  • Row header: clicking the row number with the painter armed doesn't paint, as noted in the description. ❌ (expected)
  • cargo test -p gridcraft-ui-egui --test format_painter passes.

The row-header case is how many people paint whole rows, so it would be great to have it, here or in the follow-up.

This also fixes #1355 and #1374, which report the same bug as #1211. Adding Fixes #1355, fixes #1374 to the description would close all three on merge.

@marcoarnulfo

Copy link
Copy Markdown
Contributor Author

Thanks a lot for testing it on a real workbook, @tisca26, and sorry it took me a while to get back to you. I've added #1355 and #1374 to the description. Row headers are a fair point, since that's how most people paint whole rows: I'll add painting on row and column header clicks to this PR, with a test, rather than leave it for later.

@marcoarnulfo

Copy link
Copy Markdown
Contributor Author

@tisca26 row and column headers paint now: a click or drag on the headers with the painter armed formats the whole rows or columns, single-click and double-click work as before. I didn't copy row heights or column widths, since I couldn't confirm whether Excel's painter carries them over. If you get a chance to try it on your workbook again, that would be great.

@aiongg
aiongg merged commit 2c73c2b into storytold:main Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants