summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-09 21:33:30 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-09 22:07:00 +0200
commitfd898be51ad821113f5762a134a568f315588f94 (patch)
tree97adad2f1426febd4667a0f340e47f2e7ecc2d16 /Userland/Applications
parent285f0383d410a3f63da850a3eecdd2e401ddaf34 (diff)
downloadserenity-fd898be51ad821113f5762a134a568f315588f94.zip
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. :^)
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/PixelPaint/Image.cpp4
-rw-r--r--Userland/Applications/PixelPaint/Image.h3
-rw-r--r--Userland/Applications/PixelPaint/LayerListWidget.cpp11
-rw-r--r--Userland/Applications/PixelPaint/LayerListWidget.h3
4 files changed, 16 insertions, 5 deletions
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>, 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>, 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();