summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorMarcus Nilsson <brainbomb@gmail.com>2021-08-02 22:38:47 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-03 09:04:57 +0200
commit3392c66c94a7227ca45e3b173c270b067fcd456f (patch)
treeb2d6b144ae79c0a7bf5e10eae8c53f6b0beb5e50 /Userland/Applications
parent15e9d0b4d897ebcc6bf43ba83c81fddc839c327d (diff)
downloadserenity-3392c66c94a7227ca45e3b173c270b067fcd456f.zip
PixelPaint: Remove context menu for MoveTool
Remove the context menu for MoveTool and move the actions to the layer menu instead.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/PixelPaint/MoveTool.cpp31
-rw-r--r--Userland/Applications/PixelPaint/MoveTool.h3
-rw-r--r--Userland/Applications/PixelPaint/main.cpp27
3 files changed, 26 insertions, 35 deletions
diff --git a/Userland/Applications/PixelPaint/MoveTool.cpp b/Userland/Applications/PixelPaint/MoveTool.cpp
index b93e02cfcd..16dc056316 100644
--- a/Userland/Applications/PixelPaint/MoveTool.cpp
+++ b/Userland/Applications/PixelPaint/MoveTool.cpp
@@ -85,35 +85,4 @@ void MoveTool::on_keydown(GUI::KeyEvent& event)
m_editor->layers_did_change();
}
-void MoveTool::on_context_menu(Layer& layer, GUI::ContextMenuEvent& event)
-{
- if (!m_context_menu) {
- m_context_menu = GUI::Menu::construct();
- m_context_menu->add_action(GUI::CommonActions::make_move_to_front_action(
- [this](auto&) {
- m_editor->image().move_layer_to_front(*m_context_menu_layer);
- m_editor->layers_did_change();
- },
- m_editor));
- m_context_menu->add_action(GUI::CommonActions::make_move_to_back_action(
- [this](auto&) {
- m_editor->image().move_layer_to_back(*m_context_menu_layer);
- m_editor->layers_did_change();
- },
- m_editor));
- m_context_menu->add_separator();
- m_context_menu->add_action(GUI::Action::create(
- "&Delete Layer", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [this](auto&) {
- m_editor->image().remove_layer(*m_context_menu_layer);
- // FIXME: This should not be done imperatively here. Perhaps a Image::Client interface that ImageEditor can implement?
- if (m_editor->active_layer() == m_context_menu_layer)
- m_editor->set_active_layer(nullptr);
- m_editor->layers_did_change();
- },
- m_editor));
- }
- m_context_menu_layer = layer;
- m_context_menu->popup(event.screen_position());
-}
-
}
diff --git a/Userland/Applications/PixelPaint/MoveTool.h b/Userland/Applications/PixelPaint/MoveTool.h
index 379b623a39..a0ac9c1115 100644
--- a/Userland/Applications/PixelPaint/MoveTool.h
+++ b/Userland/Applications/PixelPaint/MoveTool.h
@@ -19,14 +19,11 @@ public:
virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override;
virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override;
virtual void on_keydown(GUI::KeyEvent&) override;
- virtual void on_context_menu(Layer&, GUI::ContextMenuEvent&) override;
private:
RefPtr<Layer> m_layer_being_moved;
Gfx::IntPoint m_event_origin;
Gfx::IntPoint m_layer_origin;
- RefPtr<GUI::Menu> m_context_menu;
- RefPtr<Layer> m_context_menu_layer;
};
}
diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp
index d89ece8596..fae1dc4f30 100644
--- a/Userland/Applications/PixelPaint/main.cpp
+++ b/Userland/Applications/PixelPaint/main.cpp
@@ -369,6 +369,31 @@ int main(int argc, char** argv)
},
window));
layer_menu.add_separator();
+ layer_menu.add_action(GUI::CommonActions::make_move_to_front_action(
+ [&](auto&) {
+ auto* editor = current_image_editor();
+ if (!editor)
+ return;
+ auto active_layer = editor->active_layer();
+ if (!active_layer)
+ return;
+ editor->image().move_layer_to_front(*active_layer);
+ editor->layers_did_change();
+ },
+ window));
+ layer_menu.add_action(GUI::CommonActions::make_move_to_back_action(
+ [&](auto&) {
+ auto* editor = current_image_editor();
+ if (!editor)
+ return;
+ auto active_layer = editor->active_layer();
+ if (!active_layer)
+ return;
+ editor->image().move_layer_to_back(*active_layer);
+ editor->layers_did_change();
+ },
+ window));
+ layer_menu.add_separator();
layer_menu.add_action(GUI::Action::create(
"Move Active Layer &Up", { Mod_Ctrl, Key_PageUp }, [&](auto&) {
auto* editor = current_image_editor();
@@ -393,7 +418,7 @@ int main(int argc, char** argv)
window));
layer_menu.add_separator();
layer_menu.add_action(GUI::Action::create(
- "&Remove Active Layer", { Mod_Ctrl, Key_D }, [&](auto&) {
+ "&Remove Active Layer", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [&](auto&) {
auto* editor = current_image_editor();
if (!editor)
return;