mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user