1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:57:44 +00:00

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. :^)
This commit is contained in:
Andreas Kling 2020-05-25 22:38:27 +02:00
parent d2b493b74e
commit de85cd0907
6 changed files with 326 additions and 47 deletions

View file

@ -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);
}
}