1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:57:46 +00:00

LibGUI+LibCore: Move GML property system from LibCore to LibGUI

Since Core::Object properties are really only used by GML now that the
Inspector is long gone, there's no need for these to pollute
Core::Object.

This patch adds a new GUI::Object class to hold properties, and makes
it the new base class of GUI::Window, GUI::Widget and GUI::Layout.
The "instantiate an object by name" mechanism that GML uses is also
hoisted into GUI::Object as well.
This commit is contained in:
Andreas Kling 2023-08-06 15:14:59 +02:00
parent 9f6ceff7cf
commit 405187993a
19 changed files with 376 additions and 335 deletions

View file

@ -13,13 +13,14 @@
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Variant.h>
#include <LibCore/Object.h>
#include <LibCore/Timer.h>
#include <LibGUI/Event.h>
#include <LibGUI/FocusPolicy.h>
#include <LibGUI/Forward.h>
#include <LibGUI/GML/AST.h>
#include <LibGUI/Margins.h>
#include <LibGUI/Object.h>
#include <LibGUI/Property.h>
#include <LibGUI/UIDimensions.h>
#include <LibGfx/Color.h>
#include <LibGfx/Forward.h>
@ -27,14 +28,14 @@
#include <LibGfx/Rect.h>
#include <LibGfx/StandardCursor.h>
namespace Core::Registration {
extern Core::ObjectClassRegistration registration_Widget;
namespace GUI::Registration {
extern GUI::ObjectClassRegistration registration_Widget;
}
#define REGISTER_WIDGET(namespace_, class_name) \
namespace Core::Registration { \
Core::ObjectClassRegistration registration_##class_name( \
#namespace_ "::" #class_name##sv, []() -> ErrorOr<NonnullRefPtr<Core::Object>> { return static_ptr_cast<Core::Object>(TRY(namespace_::class_name::try_create())); }, &registration_Widget); \
#define REGISTER_WIDGET(namespace_, class_name) \
namespace GUI::Registration { \
GUI::ObjectClassRegistration registration_##class_name( \
#namespace_ "::" #class_name##sv, []() -> ErrorOr<NonnullRefPtr<GUI::Object>> { return static_ptr_cast<GUI::Object>(TRY(namespace_::class_name::try_create())); }, &registration_Widget); \
}
namespace GUI {
@ -70,7 +71,7 @@ enum class AllowCallback {
Yes
};
class Widget : public Core::Object {
class Widget : public GUI::Object {
C_OBJECT(Widget)
public:
virtual ~Widget() override;