mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 18:24:45 -05:00
111ef19114
Previously EraseTool would only let you have hard lines, similar to PenTool. After inheriting from BrushTool in previous commits, making the eraser (optionally) behave like a brush is much easier. We only need to change how the colors are handled for the hardness, which is why the `draw_point()` call is a bit more involved. Just blending the colors doesn't work here since we actually want to replace the previous color, unlike in BrushTool where we are just layering the color on top.
39 lines
898 B
C++
39 lines
898 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
* Copyright (c) 2021, Mustafa Quraish <mustafa@cs.toronto.edu>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BrushTool.h"
|
|
#include <LibGUI/ActionGroup.h>
|
|
#include <LibGfx/Forward.h>
|
|
#include <LibGfx/Point.h>
|
|
|
|
namespace PixelPaint {
|
|
|
|
class EraseTool final : public BrushTool {
|
|
public:
|
|
EraseTool();
|
|
virtual ~EraseTool() override;
|
|
|
|
virtual GUI::Widget* get_properties_widget() override;
|
|
|
|
protected:
|
|
virtual Color color_for(GUI::MouseEvent const& event) override;
|
|
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override;
|
|
|
|
private:
|
|
RefPtr<GUI::Widget> m_properties_widget;
|
|
|
|
enum class DrawMode {
|
|
Pencil,
|
|
Brush,
|
|
};
|
|
DrawMode m_draw_mode { DrawMode::Brush };
|
|
bool m_use_secondary_color { false };
|
|
};
|
|
|
|
}
|