mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
PixelPaint: Add copy action (copies the selection from active layer)
You can now select a part of a layer, copy it, and then paste it as a new layer. Very cool :^)
This commit is contained in:
parent
4cecd79000
commit
765286f691
4 changed files with 29 additions and 0 deletions
|
@ -160,6 +160,21 @@ int main(int argc, char** argv)
|
|||
}));
|
||||
|
||||
auto& edit_menu = menubar->add_menu("&Edit");
|
||||
|
||||
auto copy_action = GUI::CommonActions::make_copy_action([&](auto&) {
|
||||
VERIFY(image_editor.image());
|
||||
if (!image_editor.active_layer()) {
|
||||
dbgln("Cannot copy with no active layer selected");
|
||||
return;
|
||||
}
|
||||
auto bitmap = image_editor.active_layer()->try_copy_bitmap(image_editor.selection());
|
||||
if (!bitmap) {
|
||||
dbgln("try_copy() from Layer failed");
|
||||
return;
|
||||
}
|
||||
GUI::Clipboard::the().set_bitmap(*bitmap);
|
||||
});
|
||||
|
||||
auto paste_action = GUI::CommonActions::make_paste_action([&](auto&) {
|
||||
VERIFY(image_editor.image());
|
||||
auto bitmap = GUI::Clipboard::the().bitmap();
|
||||
|
@ -175,6 +190,7 @@ int main(int argc, char** argv)
|
|||
};
|
||||
paste_action->set_enabled(GUI::Clipboard::the().mime_type() == "image/x-serenityos");
|
||||
|
||||
edit_menu.add_action(copy_action);
|
||||
edit_menu.add_action(paste_action);
|
||||
|
||||
auto undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
|
@ -375,6 +391,7 @@ int main(int argc, char** argv)
|
|||
toolbar.add_action(open_image_action);
|
||||
toolbar.add_action(save_image_as_action);
|
||||
toolbar.add_separator();
|
||||
toolbar.add_action(copy_action);
|
||||
toolbar.add_action(paste_action);
|
||||
toolbar.add_action(undo_action);
|
||||
toolbar.add_action(redo_action);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue