mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +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:
parent
d7be3faab5
commit
b560445c84
8 changed files with 191 additions and 13 deletions
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace PixelPaint {
|
||||
|
||||
RefPtr<Layer> Layer::create_with_size(const Gfx::IntSize& size, const String& name)
|
||||
RefPtr<Layer> Layer::create_with_size(Image& image, const Gfx::IntSize& size, const String& name)
|
||||
{
|
||||
if (size.is_empty())
|
||||
return nullptr;
|
||||
|
@ -38,11 +38,12 @@ RefPtr<Layer> Layer::create_with_size(const Gfx::IntSize& size, const String& na
|
|||
if (size.width() > 16384 || size.height() > 16384)
|
||||
return nullptr;
|
||||
|
||||
return adopt(*new Layer(size, name));
|
||||
return adopt(*new Layer(image, size, name));
|
||||
}
|
||||
|
||||
Layer::Layer(const Gfx::IntSize& size, const String& name)
|
||||
: m_name(name)
|
||||
Layer::Layer(Image& image, const Gfx::IntSize& size, const String& name)
|
||||
: m_image(image)
|
||||
, m_name(name)
|
||||
{
|
||||
m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::RGBA32, size);
|
||||
}
|
||||
|
@ -52,4 +53,20 @@ void Layer::did_modify_bitmap(Image& image)
|
|||
image.layer_did_modify_bitmap({}, *this);
|
||||
}
|
||||
|
||||
void Layer::set_visible(bool visible)
|
||||
{
|
||||
if (m_visible == visible)
|
||||
return;
|
||||
m_visible = visible;
|
||||
m_image.layer_did_modify_properties({}, *this);
|
||||
}
|
||||
|
||||
void Layer::set_opacity_percent(int opacity_percent)
|
||||
{
|
||||
if (m_opacity_percent == opacity_percent)
|
||||
return;
|
||||
m_opacity_percent = opacity_percent;
|
||||
m_image.layer_did_modify_properties({}, *this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue