1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00
serenity/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.h
Zaggy1024 7ce346e50e PixelPaint: Allow keydown events to bubble from ImageEditor
Previously, all keydown KeyEvents were accepted, causing parent widgets
not to receive them. With the addition of shortcut handling to keydown,
shortcuts were not called when the ImageEditor was focused.
2022-11-14 16:08:11 +00:00

41 lines
1.4 KiB
C++

/*
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "../Selection.h"
#include "Tool.h"
#include <AK/Vector.h>
#include <LibGUI/Widget.h>
namespace PixelPaint {
class PolygonalSelectTool final : public Tool {
public:
PolygonalSelectTool() = default;
virtual ~PolygonalSelectTool() = default;
virtual void on_doubleclick(Layer*, MouseEvent& event) override;
virtual void on_mousedown(Layer*, MouseEvent& event) override;
virtual void on_mousemove(Layer*, MouseEvent& event) override;
virtual bool on_keydown(GUI::KeyEvent const&) override;
virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override;
virtual GUI::Widget* get_properties_widget() override;
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
virtual Gfx::IntPoint point_position_to_preferred_cell(Gfx::FloatPoint const& position) const override;
private:
virtual void flood_polygon_selection(Gfx::Bitmap&, Gfx::IntPoint);
virtual void process_polygon();
virtual StringView tool_name() const override { return "Polygonal Select Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
Selection::MergeMode m_merge_mode { Selection::MergeMode::Set };
bool m_selecting { false };
Gfx::IntPoint m_last_selecting_cursor_position;
Vector<Gfx::IntPoint> m_polygon_points {};
};
}