summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint/Tools/LassoSelectTool.h
blob: af2730571f71be7db5d96afbd53420e5912575c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * 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>

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 const&) override;
    virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override;
    virtual 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;
    RefPtr<Gfx::Bitmap> m_preview_bitmap;

    Gfx::IntPoint m_top_left;
    Gfx::IntPoint m_bottom_right;

    bool m_selecting { false };
};

}