mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
PixelPaint: Add actions to rotate image left/right
This also required adding a new hook to `ImageClient`, since there wasn't a way of telling the ImageEditor that the full rect of the image has changed (as when we rotate).
This commit is contained in:
parent
6a8c408856
commit
ca6c9be94c
5 changed files with 46 additions and 0 deletions
|
@ -544,6 +544,12 @@ void Image::did_change(Gfx::IntRect const& a_modified_rect)
|
|||
client->image_did_change(modified_rect);
|
||||
}
|
||||
|
||||
void Image::did_change_rect()
|
||||
{
|
||||
for (auto* client : m_clients)
|
||||
client->image_did_change_rect(rect());
|
||||
}
|
||||
|
||||
ImageUndoCommand::ImageUndoCommand(Image& image)
|
||||
: m_snapshot(image.take_snapshot())
|
||||
, m_image(image)
|
||||
|
@ -585,4 +591,17 @@ void Image::flip(Gfx::Orientation orientation)
|
|||
did_change();
|
||||
}
|
||||
|
||||
void Image::rotate(Gfx::RotationDirection direction)
|
||||
{
|
||||
for (auto& layer : m_layers) {
|
||||
auto rotated = layer.bitmap().rotated(direction);
|
||||
VERIFY(rotated);
|
||||
layer.set_bitmap(*rotated);
|
||||
layer.did_modify_bitmap(rect());
|
||||
}
|
||||
|
||||
m_size = { m_size.height(), m_size.width() };
|
||||
did_change_rect();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue