mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 12:08:14 +00:00

This commit adds a Tool::MouseEvent struct, which contains events that may be needed by tools: layer-relative, image-relative and raw (editor- relative) event. The raw event is used by ZoomTool to properly pan the view. This fixes a bug which caused image to snap out of sight.
35 lines
993 B
C++
35 lines
993 B
C++
/*
|
|
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Tool.h"
|
|
|
|
namespace PixelPaint {
|
|
|
|
class BrushTool final : public Tool {
|
|
public:
|
|
BrushTool();
|
|
virtual ~BrushTool() override;
|
|
|
|
virtual void on_mousedown(Layer&, MouseEvent&) override;
|
|
virtual void on_mousemove(Layer&, MouseEvent&) override;
|
|
virtual void on_mouseup(Layer&, MouseEvent&) override;
|
|
virtual GUI::Widget* get_properties_widget() override;
|
|
virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; }
|
|
|
|
private:
|
|
RefPtr<GUI::Widget> m_properties_widget;
|
|
int m_size { 20 };
|
|
int m_hardness { 80 };
|
|
bool m_was_drawing { false };
|
|
Gfx::IntPoint m_last_position;
|
|
|
|
void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end);
|
|
void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point);
|
|
};
|
|
|
|
}
|