diff options
author | faxe1008 <fabianblatz@gmail.com> | 2022-08-24 22:46:54 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-25 13:38:31 +0200 |
commit | 21358d8a5f7daf14b71e0f53a54c7e65db6d373e (patch) | |
tree | 20f80c0b24d35cbc287cb032655ba7442fcd0d8e /Userland/Applications/PixelPaint | |
parent | d5de9bcc516bced8539a3c71cf2350a090d1a998 (diff) | |
download | serenity-21358d8a5f7daf14b71e0f53a54c7e65db6d373e.zip |
PixelPaint: Reduce verbosity of crop to content feature
This patch reduces the repetitiveness of the crop to content feature
implementation.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r-- | Userland/Applications/PixelPaint/Image.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/Layer.cpp | 24 |
2 files changed, 5 insertions, 21 deletions
diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 98bc5760a2..9d5a04e290 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -540,7 +540,7 @@ Optional<Gfx::IntRect> Image::nonempty_content_bounding_rect() const auto layer_content_rect_in_layer_coordinates = layer.nonempty_content_bounding_rect(); if (!layer_content_rect_in_layer_coordinates.has_value()) continue; - auto layer_content_rect_in_image_coordinates = layer_content_rect_in_layer_coordinates.value().translated(layer.location()); + 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; else diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index 307d724a30..ef9d500585 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -281,26 +281,10 @@ Optional<Gfx::IntRect> Layer::nonempty_content_bounding_rect() const auto color = m_content_bitmap->get_pixel(x, y); if (color.alpha() == 0) continue; - - if (!min_content_x.has_value()) - min_content_x = x; - else - min_content_x = min(*min_content_x, x); - - if (!min_content_y.has_value()) - min_content_y = y; - else - min_content_y = min(*min_content_y, y); - - if (!max_content_x.has_value()) - max_content_x = x; - else - max_content_x = max(*max_content_x, x); - - if (!max_content_y.has_value()) - max_content_y = y; - else - max_content_y = max(*max_content_y, y); + min_content_x = min(min_content_x.value_or(x), x); + min_content_y = min(min_content_y.value_or(y), y); + max_content_x = max(max_content_x.value_or(x), x); + max_content_y = max(max_content_y.value_or(y), y); } } |