summaryrefslogtreecommitdiff
path: root/Applications/PixelPaint/Image.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-25 22:38:27 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-26 10:18:03 +0200
commitde85cd09073034eb4e5df653b1cc17c5870c4afb (patch)
tree1b3e0ab6dc8165fa308601173affe30d85ba647c /Applications/PixelPaint/Image.cpp
parentd2b493b74ea78a71b0d7140edcf876ee28b8bf07 (diff)
downloadserenity-de85cd09073034eb4e5df653b1cc17c5870c4afb.zip
PixelPaint: Start working on a custom layer list widget
Instead of using a TableView to show the layer stack, let's build a new custom widget for this purpose and give it some neat features! This patch also introduces an ImageClient interface for Image to notify interested parties about things happening. The LayerListWidget is the first ImageClient and listens for "layer added" and "layer removed" notifications. :^)
Diffstat (limited to 'Applications/PixelPaint/Image.cpp')
-rw-r--r--Applications/PixelPaint/Image.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Applications/PixelPaint/Image.cpp b/Applications/PixelPaint/Image.cpp
index 1638369f09..e1a906df11 100644
--- a/Applications/PixelPaint/Image.cpp
+++ b/Applications/PixelPaint/Image.cpp
@@ -67,6 +67,9 @@ void Image::add_layer(NonnullRefPtr<Layer> layer)
ASSERT(&existing_layer != layer.ptr());
}
m_layers.append(move(layer));
+
+ for (auto* client : m_clients)
+ client->image_did_add_layer(m_layers.size() - 1);
}
GUI::Model& Image::layer_model()
@@ -126,6 +129,21 @@ void Image::remove_layer(Layer& layer)
NonnullRefPtr<Layer> protector(layer);
auto index = index_of(layer);
m_layers.remove(index);
+
+ for (auto* client : m_clients)
+ client->image_did_remove_layer(index);
+}
+
+void Image::add_client(ImageClient& client)
+{
+ ASSERT(!m_clients.contains(&client));
+ m_clients.set(&client);
+}
+
+void Image::remove_client(ImageClient& client)
+{
+ ASSERT(m_clients.contains(&client));
+ m_clients.remove(&client);
}
}