diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-02-24 06:12:49 +0000 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-06-04 21:06:28 +0200 |
commit | 55e103deb5e3396dc63ee0cf8ad426e248b50f00 (patch) | |
tree | 9413e7983c365ce1fc6e7055e87ab0de9144f328 /Userland/Applications | |
parent | c98ec85fb55ed0d3cef063c0b6e6aaa48aa25da5 (diff) | |
download | serenity-55e103deb5e3396dc63ee0cf8ad426e248b50f00.zip |
PixelPaint: Make "Crop Image to Content" work with disjoint layers
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/PixelPaint/Image.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 3929197cc0..09dd480d8d 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -665,7 +665,8 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const for (auto const& layer : m_layers) { auto layer_content_rect_in_layer_coordinates = layer->nonempty_content_bounding_rect(); if (!layer_content_rect_in_layer_coordinates.has_value()) - continue; + layer_content_rect_in_layer_coordinates = layer->rect(); + auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates->translated(layer->location()); if (!bounding_rect.has_value()) bounding_rect = layer_content_rect_in_image_coordinates; @@ -673,6 +674,10 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const bounding_rect = bounding_rect->united(layer_content_rect_in_image_coordinates); } + bounding_rect->intersect(rect()); + if (bounding_rect == rect()) + return OptionalNone {}; + return bounding_rect; } |