mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:47:44 +00:00
PixelPaint: Relate cursor to brush tool size
This patch changes the cursor for the brush tool to a circle of dynamic size to indicate the region where the tool will apply color changes.
This commit is contained in:
parent
e9ca641d45
commit
e520b9c3a3
6 changed files with 87 additions and 6 deletions
|
@ -2,12 +2,14 @@
|
|||
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
|
||||
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
* Copyright (c) 2022, Torsten Engelmann <engelTorsten@gmx.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../ImageEditor.h"
|
||||
#include "Tool.h"
|
||||
|
||||
namespace PixelPaint {
|
||||
|
@ -21,9 +23,14 @@ public:
|
|||
virtual void on_mousemove(Layer*, MouseEvent&) override;
|
||||
virtual void on_mouseup(Layer*, MouseEvent&) override;
|
||||
virtual GUI::Widget* get_properties_widget() override;
|
||||
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
|
||||
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override
|
||||
{
|
||||
if (m_editor && m_editor->scale() != m_scale_last_created_cursor)
|
||||
refresh_editor_cursor();
|
||||
return m_cursor;
|
||||
}
|
||||
|
||||
void set_size(int size) { m_size = size; }
|
||||
void set_size(int size);
|
||||
int size() const { return m_size; }
|
||||
|
||||
void set_hardness(int hardness) { m_hardness = hardness; }
|
||||
|
@ -41,6 +48,9 @@ protected:
|
|||
virtual Color color_for(GUI::MouseEvent const& event);
|
||||
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point);
|
||||
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end);
|
||||
virtual NonnullRefPtr<Gfx::Bitmap> build_cursor();
|
||||
void refresh_editor_cursor();
|
||||
float m_scale_last_created_cursor = 0;
|
||||
|
||||
private:
|
||||
RefPtr<GUI::Widget> m_properties_widget;
|
||||
|
@ -49,6 +59,7 @@ private:
|
|||
bool m_was_drawing { false };
|
||||
bool m_has_clicked { false };
|
||||
Gfx::IntPoint m_last_position;
|
||||
NonnullRefPtr<Gfx::Bitmap> m_cursor = build_cursor();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue