1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 04:44:58 +00:00
serenity/Userland/Applications/PixelPaint/Tools/LassoSelectTool.h
Tim Ledbetter f34b1c7a7e PixelPaint: Make tool properties widget construction non-fallible
`Tool::get_properties_widget()` now also returns a NNRP to a widget
rather than a raw pointer.
2023-09-25 10:58:31 +02:00

48 lines
1.4 KiB
C++

/*
* Copyright (c) 2022, Timothy Slater <tslater2006@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "../Selection.h"
#include "Tool.h"
#include <AK/Vector.h>
#include <LibGUI/Widget.h>
#include <LibGfx/Path.h>
namespace PixelPaint {
class LassoSelectTool final : public Tool {
public:
LassoSelectTool() = default;
virtual ~LassoSelectTool() = default;
virtual void on_mousedown(Layer*, MouseEvent& event) override;
virtual void on_mouseup(Layer*, MouseEvent& event) override;
virtual void on_mousemove(Layer*, MouseEvent& event) override;
virtual bool on_keydown(GUI::KeyEvent&) override;
virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override;
virtual NonnullRefPtr<GUI::Widget> get_properties_widget() override;
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; }
private:
virtual StringView tool_name() const override { return "Lasso Select Tool"sv; }
void flood_lasso_selection(Gfx::Bitmap&);
RefPtr<GUI::Widget> m_properties_widget;
Selection::MergeMode m_merge_mode { Selection::MergeMode::Set };
Gfx::IntPoint m_start_position;
Gfx::IntPoint m_most_recent_position;
Vector<Gfx::IntPoint> m_path_points;
Gfx::IntPoint m_top_left;
Gfx::IntPoint m_bottom_right;
bool m_selecting { false };
};
}