1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00
serenity/Userland/Applications/PixelPaint/GuideTool.h
Tobias Christiansen 7923929a4d 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.
2021-08-07 02:52:47 +04:30

35 lines
960 B
C++

/*
* 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;
};
}