From fd898be51ad821113f5762a134a568f315588f94 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 9 Jul 2021 21:33:30 +0200 Subject: PixelPaint: Only update the layer thumbnail on layer bitmap changes When a layer bitmap is modified, we don't have to repaint the whole layer gadget in the layer list, only the little thumbnail. :^) --- Userland/Applications/PixelPaint/Image.cpp | 4 ++-- Userland/Applications/PixelPaint/Image.h | 3 ++- Userland/Applications/PixelPaint/LayerListWidget.cpp | 11 ++++++++++- Userland/Applications/PixelPaint/LayerListWidget.h | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'Userland/Applications') diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index fff196c25f..0e01f45b3b 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -434,7 +434,7 @@ void Image::layer_did_modify_bitmap(Badge, Layer const& layer, Gfx::IntRe { auto layer_index = index_of(layer); for (auto* client : m_clients) - client->image_did_modify_layer(layer_index); + client->image_did_modify_layer_bitmap(layer_index); did_change(modified_layer_rect.translated(layer.location())); } @@ -443,7 +443,7 @@ void Image::layer_did_modify_properties(Badge, Layer const& layer) { auto layer_index = index_of(layer); for (auto* client : m_clients) - client->image_did_modify_layer(layer_index); + client->image_did_modify_layer_properties(layer_index); did_change(); } diff --git a/Userland/Applications/PixelPaint/Image.h b/Userland/Applications/PixelPaint/Image.h index f24cbf75e2..8371feca9a 100644 --- a/Userland/Applications/PixelPaint/Image.h +++ b/Userland/Applications/PixelPaint/Image.h @@ -26,7 +26,8 @@ class ImageClient { public: virtual void image_did_add_layer(size_t) { } virtual void image_did_remove_layer(size_t) { } - virtual void image_did_modify_layer(size_t) { } + virtual void image_did_modify_layer_properties(size_t) { } + virtual void image_did_modify_layer_bitmap(size_t) { } virtual void image_did_modify_layer_stack() { } virtual void image_did_change(Gfx::IntRect const&) { } virtual void image_select_layer(Layer*) { } diff --git a/Userland/Applications/PixelPaint/LayerListWidget.cpp b/Userland/Applications/PixelPaint/LayerListWidget.cpp index 6ffddc9e34..83ca9305f5 100644 --- a/Userland/Applications/PixelPaint/LayerListWidget.cpp +++ b/Userland/Applications/PixelPaint/LayerListWidget.cpp @@ -231,11 +231,20 @@ void LayerListWidget::image_did_remove_layer(size_t layer_index) relayout_gadgets(); } -void LayerListWidget::image_did_modify_layer(size_t layer_index) +void LayerListWidget::image_did_modify_layer_properties(size_t layer_index) { update(m_gadgets[layer_index].rect); } +void LayerListWidget::image_did_modify_layer_bitmap(size_t layer_index) +{ + Gfx::IntRect adjusted_rect; + Gfx::IntRect thumbnail_rect; + Gfx::IntRect text_rect; + get_gadget_rects(m_gadgets[layer_index], adjusted_rect, thumbnail_rect, text_rect); + update(thumbnail_rect); +} + void LayerListWidget::image_did_modify_layer_stack() { rebuild_gadgets(); diff --git a/Userland/Applications/PixelPaint/LayerListWidget.h b/Userland/Applications/PixelPaint/LayerListWidget.h index dcc00b8ac5..9907d24fd7 100644 --- a/Userland/Applications/PixelPaint/LayerListWidget.h +++ b/Userland/Applications/PixelPaint/LayerListWidget.h @@ -41,7 +41,8 @@ private: virtual void image_did_add_layer(size_t) override; virtual void image_did_remove_layer(size_t) override; - virtual void image_did_modify_layer(size_t) override; + virtual void image_did_modify_layer_properties(size_t) override; + virtual void image_did_modify_layer_bitmap(size_t) override; virtual void image_did_modify_layer_stack() override; void rebuild_gadgets(); -- cgit v1.2.3