1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:27:45 +00:00

PixelPaint: Add GuideTool for editing Guides

This patch adds the logic for the GuideTool. Pulling in from outside the
image creates a new Guide, moving a Guide outside of the image deletes
it and a Guide can be deleteted via the context menu.
A Guide is considered clicked when the cursor is less than 20 pixels
away from the line.
This commit is contained in:
Tobias Christiansen 2021-08-05 14:57:38 +02:00 committed by Ali Mohammad Pur
parent d4cf4b74c1
commit 7923929a4d
3 changed files with 171 additions and 0 deletions

View file

@ -0,0 +1,35 @@
/*
* Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Guide.h"
#include "Tool.h"
#include <AK/RefPtr.h>
namespace PixelPaint {
class GuideTool final : public Tool {
public:
GuideTool();
virtual ~GuideTool() override;
virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override;
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_context_menu(Layer&, GUI::ContextMenuEvent&) override;
private:
RefPtr<Guide> closest_guide(Gfx::IntPoint const&);
RefPtr<Guide> m_selected_guide;
RefPtr<Guide> m_context_menu_guide;
Gfx::IntPoint m_event_origin;
float m_guide_origin { 0 };
RefPtr<GUI::Menu> m_context_menu;
};
}