1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 19:47:42 +00:00
serenity/Userland/DevTools/HackStudio/Tool.h
Tom 3aaffa2c47 LibGUI: Move widget registration to LibCore
This also moves Widget::load_from_json into Core::Object as a virtual
function in order to allow loading non-widget objects in GML (e.g.
BoxLayout).

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-06 08:50:39 +02:00

44 lines
894 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Noncopyable.h>
#include <LibCore/Forward.h>
#include <LibGUI/Forward.h>
namespace HackStudio {
class FormEditorWidget;
class Tool {
AK_MAKE_NONCOPYABLE(Tool);
AK_MAKE_NONMOVABLE(Tool);
public:
virtual ~Tool() { }
virtual void on_mousedown(GUI::MouseEvent&) = 0;
virtual void on_mouseup(GUI::MouseEvent&) = 0;
virtual void on_mousemove(GUI::MouseEvent&) = 0;
virtual void on_keydown(GUI::KeyEvent&) = 0;
virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) { }
virtual const char* class_name() const = 0;
virtual void attach() { }
virtual void detach() { }
protected:
explicit Tool(FormEditorWidget& editor)
: m_editor(editor)
{
}
FormEditorWidget& m_editor;
};
}