mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
PixelPaint: Add a Duplicate Layer action
The "Duplicate Layer" action inserts a copy of the selected layer into the layer stack. The new layer is placed above the selected layer.
This commit is contained in:
parent
55feecee36
commit
3faf089be5
7 changed files with 83 additions and 3 deletions
|
@ -200,19 +200,30 @@ ErrorOr<void> Image::export_qoi_to_file(NonnullOwnPtr<Stream> stream) const
|
|||
return {};
|
||||
}
|
||||
|
||||
void Image::add_layer(NonnullRefPtr<Layer> layer)
|
||||
void Image::insert_layer(NonnullRefPtr<Layer> layer, size_t index)
|
||||
{
|
||||
VERIFY(index <= m_layers.size());
|
||||
|
||||
for (auto& existing_layer : m_layers) {
|
||||
VERIFY(existing_layer != layer);
|
||||
}
|
||||
m_layers.append(move(layer));
|
||||
|
||||
if (index == m_layers.size())
|
||||
m_layers.append(move(layer));
|
||||
else
|
||||
m_layers.insert(index, move(layer));
|
||||
|
||||
for (auto* client : m_clients)
|
||||
client->image_did_add_layer(m_layers.size() - 1);
|
||||
client->image_did_add_layer(index);
|
||||
|
||||
did_modify_layer_stack();
|
||||
}
|
||||
|
||||
void Image::add_layer(NonnullRefPtr<Layer> layer)
|
||||
{
|
||||
insert_layer(move(layer), m_layers.size());
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Image>> Image::take_snapshot() const
|
||||
{
|
||||
auto snapshot = TRY(create_with_size(m_size));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue