1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +00:00

PixelPaint: Make image flattening actions work with disjoint layers

The "Flatten Image" and "Merge Visible" actions now work with layers
of different sizes. These actions now expand the bounding rect of the
newly merged layer to contain all layers being merged.
This commit is contained in:
Tim Ledbetter 2023-02-11 15:03:42 +00:00 committed by Sam Atkins
parent 2bec236ea6
commit 74dff6250c
3 changed files with 62 additions and 39 deletions

View file

@ -845,7 +845,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
"Fl&atten Image", { Mod_Ctrl, Key_F }, g_icon_bag.flatten_image, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->image().flatten_all_layers();
if (auto maybe_error = editor->image().flatten_all_layers(); maybe_error.is_error()) {
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Failed to flatten all layers: {}", maybe_error.release_error()));
return;
}
editor->did_complete_action("Flatten Image"sv);
}));
@ -853,7 +856,10 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
"&Merge Visible", { Mod_Ctrl, Key_M }, g_icon_bag.merge_visible, [&](auto&) {
auto* editor = current_image_editor();
VERIFY(editor);
editor->image().merge_visible_layers();
if (auto maybe_error = editor->image().merge_visible_layers(); maybe_error.is_error()) {
GUI::MessageBox::show_error(&window, DeprecatedString::formatted("Failed to merge visible layers: {}", maybe_error.release_error()));
return;
}
editor->did_complete_action("Merge Visible"sv);
}));