mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +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:
parent
9f6ceff7cf
commit
405187993a
19 changed files with 376 additions and 335 deletions
|
@ -107,8 +107,8 @@ void AutocompleteProvider::provide_completions(Function<void(Vector<CodeComprehe
|
|||
state = previous_states.take_last();
|
||||
}
|
||||
|
||||
auto& widget_class = *Core::ObjectClassRegistration::find("GUI::Widget"sv);
|
||||
auto& layout_class = *Core::ObjectClassRegistration::find("GUI::Layout"sv);
|
||||
auto& widget_class = *GUI::ObjectClassRegistration::find("GUI::Widget"sv);
|
||||
auto& layout_class = *GUI::ObjectClassRegistration::find("GUI::Layout"sv);
|
||||
|
||||
// FIXME: Can this be done without a StringBuilder?
|
||||
auto make_fuzzy = [](StringView str) {
|
||||
|
@ -124,14 +124,14 @@ void AutocompleteProvider::provide_completions(Function<void(Vector<CodeComprehe
|
|||
Vector<CodeComprehension::AutocompleteResultEntry> class_entries, identifier_entries;
|
||||
|
||||
auto register_layouts_matching_pattern = [&](DeprecatedString pattern, size_t partial_input_length) {
|
||||
Core::ObjectClassRegistration::for_each([&](const Core::ObjectClassRegistration& registration) {
|
||||
GUI::ObjectClassRegistration::for_each([&](const GUI::ObjectClassRegistration& registration) {
|
||||
if (registration.is_derived_from(layout_class) && ®istration != &layout_class && registration.class_name().matches(pattern))
|
||||
class_entries.empend(DeprecatedString::formatted("@{}", registration.class_name()), partial_input_length);
|
||||
});
|
||||
};
|
||||
|
||||
auto register_widgets_matching_pattern = [&](DeprecatedString pattern, size_t partial_input_length) {
|
||||
Core::ObjectClassRegistration::for_each([&](const Core::ObjectClassRegistration& registration) {
|
||||
GUI::ObjectClassRegistration::for_each([&](const GUI::ObjectClassRegistration& registration) {
|
||||
if (registration.is_derived_from(widget_class) && registration.class_name().matches(pattern))
|
||||
class_entries.empend(DeprecatedString::formatted("@{}", registration.class_name()), partial_input_length);
|
||||
});
|
||||
|
@ -141,7 +141,7 @@ void AutocompleteProvider::provide_completions(Function<void(Vector<CodeComprehe
|
|||
auto class_name = class_names.last();
|
||||
|
||||
// FIXME: Don't show properties that are already specified in the scope.
|
||||
auto registration = Core::ObjectClassRegistration::find(class_name);
|
||||
auto registration = GUI::ObjectClassRegistration::find(class_name);
|
||||
if (registration && (registration->is_derived_from(widget_class) || registration->is_derived_from(layout_class))) {
|
||||
if (auto instance = registration->construct(); !instance.is_error()) {
|
||||
for (auto& it : instance.value()->properties()) {
|
||||
|
@ -161,7 +161,7 @@ void AutocompleteProvider::provide_completions(Function<void(Vector<CodeComprehe
|
|||
if (!class_names.is_empty()) {
|
||||
register_class_properties_matching_pattern(pattern, partial_input_length);
|
||||
|
||||
auto parent_registration = Core::ObjectClassRegistration::find(class_names.last());
|
||||
auto parent_registration = GUI::ObjectClassRegistration::find(class_names.last());
|
||||
if (parent_registration && parent_registration->is_derived_from(layout_class)) {
|
||||
// Layouts can't have child classes, so why suggest them?
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue