1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-14 07:47:34 +00:00
serenity/Userland/Applications/PixelPaint/Tool.h
Marcus Nilsson b1b6a6d6e8 PixelPaint: Let Tools have different cursors
This adds support for the Tools in PixelPaint to use different cursors
within ImageEditor. For now most of them get the crosshair cursor since
it's the most fitting, but in the future we will want to add custom
cursors.
2021-08-09 00:57:44 +02:00

48 lines
1.3 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Event.h>
#include <LibGUI/Forward.h>
#include <LibGfx/StandardCursor.h>
namespace PixelPaint {
class ImageEditor;
class Layer;
class Tool {
public:
virtual ~Tool();
virtual void on_mousedown(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { }
virtual void on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { }
virtual void on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { }
virtual void on_context_menu(Layer&, GUI::ContextMenuEvent&) { }
virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) { }
virtual void on_second_paint(Layer const&, GUI::PaintEvent&) { }
virtual void on_keydown(GUI::KeyEvent&) { }
virtual void on_keyup(GUI::KeyEvent&) { }
virtual GUI::Widget* get_properties_widget() { return nullptr; }
virtual Gfx::StandardCursor cursor() { return Gfx::StandardCursor::None; }
void clear() { m_editor = nullptr; }
void setup(ImageEditor&);
ImageEditor const* editor() const { return m_editor; }
ImageEditor* editor() { return m_editor; }
GUI::Action* action() { return m_action; }
void set_action(GUI::Action*);
protected:
Tool();
WeakPtr<ImageEditor> m_editor;
RefPtr<GUI::Action> m_action;
};
}