mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
Spreadsheet: Enable the ability to undo/redo changes in cell color
Cells can be updated with new background/foreground colors and then this action can be undone/redone.
This commit is contained in:
parent
7c204745ee
commit
8bc232e6be
Notes:
sideshowbarker
2024-07-16 23:57:20 +09:00
Author: https://github.com/huttongrabiel
Commit: 8bc232e6be
Pull-request: https://github.com/SerenityOS/serenity/pull/18159
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/alimpfard
1 changed files with 8 additions and 2 deletions
|
@ -485,12 +485,18 @@ void SpreadsheetWidget::change_cell_static_color_format(Spreadsheet::FormatType
|
|||
|
||||
auto dialog = GUI::ColorPicker::construct(Color::White, window(), "Select Color");
|
||||
if (dialog->exec() == GUI::Dialog::ExecResult::OK) {
|
||||
Vector<CellChange> cell_changes;
|
||||
for (auto& position : current_worksheet_if_available()->selected_cells()) {
|
||||
auto* cell = current_worksheet_if_available()->at(position);
|
||||
auto previous_type_metadata = cell->type_metadata();
|
||||
if (format_type == Spreadsheet::FormatType::Background)
|
||||
current_worksheet_if_available()->at(position)->type_metadata().static_format.background_color = dialog->color();
|
||||
cell->type_metadata().static_format.background_color = dialog->color();
|
||||
else
|
||||
current_worksheet_if_available()->at(position)->type_metadata().static_format.foreground_color = dialog->color();
|
||||
cell->type_metadata().static_format.foreground_color = dialog->color();
|
||||
cell_changes.append(CellChange(*cell, previous_type_metadata));
|
||||
}
|
||||
undo_stack().push(make<CellsUndoMetadataCommand>(move(cell_changes)));
|
||||
window()->set_modified(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue