mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
PixelPaint: Add actions to flip image vertically/horizontally
This commit is contained in:
parent
0c56f06994
commit
6a8c408856
3 changed files with 33 additions and 0 deletions
|
@ -573,4 +573,16 @@ void Image::set_path(String path)
|
||||||
set_title(LexicalPath::basename(m_path));
|
set_title(LexicalPath::basename(m_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Image::flip(Gfx::Orientation orientation)
|
||||||
|
{
|
||||||
|
for (auto& layer : m_layers) {
|
||||||
|
auto flipped = layer.bitmap().flipped(orientation);
|
||||||
|
VERIFY(flipped);
|
||||||
|
layer.set_bitmap(*flipped);
|
||||||
|
layer.did_modify_bitmap(rect());
|
||||||
|
}
|
||||||
|
|
||||||
|
did_change();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,8 @@ public:
|
||||||
String const& title() const { return m_title; }
|
String const& title() const { return m_title; }
|
||||||
void set_title(String);
|
void set_title(String);
|
||||||
|
|
||||||
|
void flip(Gfx::Orientation orientation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Image(Gfx::IntSize const&);
|
explicit Image(Gfx::IntSize const&);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -406,6 +407,24 @@ int main(int argc, char** argv)
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto& image_menu = window->add_menu("&Image");
|
||||||
|
image_menu.add_action(GUI::Action::create(
|
||||||
|
"Flip &Vertically", [&](auto&) {
|
||||||
|
auto* editor = current_image_editor();
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
editor->image().flip(Gfx::Orientation::Vertical);
|
||||||
|
},
|
||||||
|
window));
|
||||||
|
image_menu.add_action(GUI::Action::create(
|
||||||
|
"Flip &Horizontally", [&](auto&) {
|
||||||
|
auto* editor = current_image_editor();
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
editor->image().flip(Gfx::Orientation::Horizontal);
|
||||||
|
},
|
||||||
|
window));
|
||||||
|
|
||||||
auto& layer_menu = window->add_menu("&Layer");
|
auto& layer_menu = window->add_menu("&Layer");
|
||||||
layer_menu.add_action(GUI::Action::create(
|
layer_menu.add_action(GUI::Action::create(
|
||||||
"New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, [&](auto&) {
|
"New &Layer...", { Mod_Ctrl | Mod_Shift, Key_N }, [&](auto&) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue