1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-07 05:07:35 +00:00
serenity/Userland/Applications/PixelPaint/Tools/LassoSelectTool.h
MacDue 458ca83d8c PixelPaint: Fix lasso tool preview when zoomed in
Previously only part of the preview would be visible when zoomed in,
with less visible the more you zoomed. This also now doesn't scale
the preview line thickness, similar to other image editing programs.
2022-11-27 20:35:22 +01:00

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 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;
Gfx::Path m_preview_path;
Gfx::IntPoint m_top_left;
Gfx::IntPoint m_bottom_right;
bool m_selecting { false };
};
}