Repository navigation
Grid: an armed Format Painter pastes onto the next cells clicked or dragged - #1214
Conversation
|
Tested this branch (
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 |
|
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. |
|
@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. |
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.formatPainteronly 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 herecargo test -p gridcraft-ui-egui --test selection --test interaction --test selection_fill --test formula_point_headers --test keytips_generatedcargo clippy -p gridcraft-ui-egui --all-targets -- -D warnings,cargo fmt --all -- --checkHeader 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.boldonC:Cworks) 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.