mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 22:35:09 +00:00
48 lines
1.3 KiB
C++
48 lines
1.3 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 ErrorOr<GUI::Widget*> get_properties_widget() override;
|
|
|
|
private:
|
|
virtual StringView tool_name() const override { return "Lasso Select Tool"sv; }
|
|
void flood_lasso_selection(Gfx::Bitmap&, Gfx::IntPoint);
|
|
|
|
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;
|
|
RefPtr<Gfx::Bitmap> m_selection_bitmap;
|
|
Vector<Gfx::IntPoint> m_preview_coords;
|
|
|
|
Gfx::IntPoint m_top_left;
|
|
Gfx::IntPoint m_bottom_right;
|
|
|
|
bool m_selecting { false };
|
|
};
|
|
|
|
}
|