1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

PixelPaint: Add a GUI for editing opacity and visibility of layers

Also, make the layer stack rendering respect opacity and visibility.
This commit is contained in:
Andreas Kling 2020-07-23 20:33:38 +02:00
parent d7be3faab5
commit b560445c84
8 changed files with 191 additions and 13 deletions

View file

@ -54,9 +54,11 @@ void Image::paint_into(GUI::Painter& painter, const Gfx::IntRect& dest_rect)
Gfx::PainterStateSaver saver(painter);
painter.add_clip_rect(dest_rect);
for (auto& layer : m_layers) {
if (!layer.is_visible())
continue;
auto target = dest_rect.translated(layer.location().x() * scale, layer.location().y() * scale);
target.set_size(layer.size().width() * scale, layer.size().height() * scale);
painter.draw_scaled_bitmap(target, layer.bitmap(), layer.rect());
painter.draw_scaled_bitmap(target, layer.bitmap(), layer.rect(), (float)layer.opacity_percent() / 100.0f);
}
}
@ -174,6 +176,15 @@ void Image::layer_did_modify_bitmap(Badge<Layer>, const Layer& layer)
did_change();
}
void Image::layer_did_modify_properties(Badge<Layer>, const Layer& layer)
{
auto layer_index = index_of(layer);
for (auto* client : m_clients)
client->image_did_modify_layer(layer_index);
did_change();
}
void Image::did_change()
{
for (auto* client : m_clients)