mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +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:
parent
d2b493b74e
commit
de85cd0907
6 changed files with 326 additions and 47 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
|
@ -39,6 +40,13 @@ namespace PixelPaint {
|
|||
|
||||
class Layer;
|
||||
|
||||
class ImageClient {
|
||||
public:
|
||||
virtual void image_did_add_layer(size_t) { }
|
||||
virtual void image_did_remove_layer(size_t) { }
|
||||
virtual void image_did_update_layer(size_t) { }
|
||||
};
|
||||
|
||||
class Image : public RefCounted<Image> {
|
||||
public:
|
||||
static RefPtr<Image> create_with_size(const Gfx::Size&);
|
||||
|
@ -61,6 +69,9 @@ public:
|
|||
void move_layer_down(Layer&);
|
||||
void remove_layer(Layer&);
|
||||
|
||||
void add_client(ImageClient&);
|
||||
void remove_client(ImageClient&);
|
||||
|
||||
private:
|
||||
explicit Image(const Gfx::Size&);
|
||||
|
||||
|
@ -69,6 +80,8 @@ private:
|
|||
Gfx::Size m_size;
|
||||
NonnullRefPtrVector<Layer> m_layers;
|
||||
RefPtr<GUI::Model> m_layer_model;
|
||||
|
||||
HashTable<ImageClient*> m_clients;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue