mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-14 01:04:38 +03:00
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. :^)
This commit is contained in:
parent
e9595dcb79
commit
8a7ce4eea3
Notes:
sideshowbarker
2024-07-18 04:58:09 +09:00
Author: https://github.com/TobyAsE Commit: https://github.com/SerenityOS/serenity/commit/8a7ce4eea37 Pull-request: https://github.com/SerenityOS/serenity/pull/9706 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/mustafaquraish
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "GuideTool.h"
|
||||
#include "EditGuideDialog.h"
|
||||
#include "ImageEditor.h"
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user