From 8a7ce4eea37c64049d4bdbf39aa9f1e1bae070e2 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Tue, 31 Aug 2021 18:29:10 +0200 Subject: [PATCH] PixelPaint: Add "Change Offset" to the GuideTool This opens the EditGuideDialog with the values of the currently selected Guide and allows the user to change them to the desired values. :^) --- .../Applications/PixelPaint/GuideTool.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Userland/Applications/PixelPaint/GuideTool.cpp b/Userland/Applications/PixelPaint/GuideTool.cpp index d27f6ebada..6e851af457 100644 --- a/Userland/Applications/PixelPaint/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/GuideTool.cpp @@ -5,6 +5,7 @@ */ #include "GuideTool.h" +#include "EditGuideDialog.h" #include "ImageEditor.h" #include #include @@ -141,6 +142,24 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event) if (!m_context_menu) { m_context_menu = GUI::Menu::construct(); + m_context_menu->add_action(GUI::Action::create( + "Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png"), [this](auto&) { + if (!m_context_menu_guide) + return; + auto dialog = EditGuideDialog::construct( + editor()->window(), + String::formatted("{}", m_context_menu_guide->offset()), + m_context_menu_guide->orientation()); + if (dialog->exec() != GUI::Dialog::ExecOK) + return; + auto offset = dialog->offset_as_pixel(*editor()); + if (!offset.has_value()) + return; + m_context_menu_guide->set_offset(offset.release_value()); + m_context_menu_guide->set_orientation(dialog->orientation()); + editor()->layers_did_change(); + }, + editor())); m_context_menu->add_action(GUI::Action::create( "&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"), [this](auto&) { if (!m_context_menu_guide)