1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:37:35 +00:00

PixelPaint: Restrict "crop to selection" to image boundaries

This commit is contained in:
Mateusz Krajewski 2022-01-14 18:51:33 +00:00 committed by Linus Groh
parent a610d9a3d1
commit ae71d2b70e

View file

@ -26,6 +26,7 @@
#include <LibGUI/Toolbar.h> #include <LibGUI/Toolbar.h>
#include <LibGUI/Window.h> #include <LibGUI/Window.h>
#include <LibGfx/Bitmap.h> #include <LibGfx/Bitmap.h>
#include <LibGfx/Rect.h>
namespace PixelPaint { namespace PixelPaint {
@ -467,7 +468,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
// FIXME: disable this action if there is no selection // FIXME: disable this action if there is no selection
if (editor->selection().is_empty()) if (editor->selection().is_empty())
return; return;
auto crop_rect = editor->selection().bounding_rect(); auto crop_rect = editor->image().rect().intersected(editor->selection().bounding_rect());
editor->image().crop(crop_rect); editor->image().crop(crop_rect);
editor->selection().clear(); editor->selection().clear();
})); }));