1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

PixelPaint: Ensure the selection is always within image bounds

This commit is contained in:
Tim Ledbetter 2023-03-29 18:00:59 +01:00 committed by Sam Atkins
parent fc137a7827
commit f132751fae
8 changed files with 97 additions and 55 deletions

View file

@ -418,7 +418,8 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
VERIFY(editor);
if (!editor->active_layer())
return;
editor->image().selection().merge(editor->active_layer()->relative_rect(), PixelPaint::Selection::MergeMode::Set);
auto layer_rect = editor->active_layer()->relative_rect();
editor->image().selection().merge(layer_rect.intersected(editor->image().rect()), PixelPaint::Selection::MergeMode::Set);
editor->did_complete_action("Select All"sv);
})));
TRY(m_edit_menu->try_add_action(GUI::Action::create(
@ -660,6 +661,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
GUI::MessageBox::show_error(&window, MUST(String::formatted("Failed to resize image: {}", image_resize_or_error.release_error())));
return;
}
// FIXME: We should ensure the selection is within the bounds of the image here.
editor->did_complete_action("Resize Image"sv);
}
})));