1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:37:43 +00:00

LibGUI: Register layouts with inheritance

This commit is contained in:
thislooksfun 2021-10-25 20:23:26 -05:00 committed by Andreas Kling
parent 6dc2749795
commit 416988cc7f
2 changed files with 16 additions and 2 deletions

View file

@ -10,8 +10,8 @@
#include <LibGfx/Orientation.h> #include <LibGfx/Orientation.h>
#include <stdio.h> #include <stdio.h>
REGISTER_CORE_OBJECT(GUI, HorizontalBoxLayout) REGISTER_LAYOUT(GUI, HorizontalBoxLayout)
REGISTER_CORE_OBJECT(GUI, VerticalBoxLayout) REGISTER_LAYOUT(GUI, VerticalBoxLayout)
namespace GUI { namespace GUI {

View file

@ -14,6 +14,20 @@
#include <LibGUI/Margins.h> #include <LibGUI/Margins.h>
#include <LibGfx/Forward.h> #include <LibGfx/Forward.h>
namespace Core {
namespace Registration {
extern Core::ObjectClassRegistration registration_Layout;
}
}
#define REGISTER_LAYOUT(namespace_, class_name) \
namespace Core { \
namespace Registration { \
Core::ObjectClassRegistration registration_##class_name( \
#namespace_ "::" #class_name, []() { return static_ptr_cast<Core::Object>(namespace_::class_name::construct()); }, &registration_Layout); \
} \
}
namespace GUI { namespace GUI {
class Layout : public Core::Object { class Layout : public Core::Object {