Add pre-sort signal and notification in Container

Allows processing before children are sorted, useful for custom
containers inherited from existing ones like BoxContainer.
This commit is contained in:
PouleyKetchoupp
2021-10-05 13:09:01 -07:00
parent 198b49d8b5
commit 1c0ebc85dd
5 changed files with 19 additions and 2 deletions

View File

@@ -87,6 +87,9 @@ void Container::_sort_children() {
return;
}
notification(NOTIFICATION_PRE_SORT_CHILDREN);
emit_signal(SceneStringNames::get_singleton()->pre_sort_children);
notification(NOTIFICATION_SORT_CHILDREN);
emit_signal(SceneStringNames::get_singleton()->sort_children);
pending_sort = false;
@@ -174,7 +177,10 @@ void Container::_bind_methods() {
ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort);
ClassDB::bind_method(D_METHOD("fit_child_in_rect", "child", "rect"), &Container::fit_child_in_rect);
BIND_CONSTANT(NOTIFICATION_PRE_SORT_CHILDREN);
BIND_CONSTANT(NOTIFICATION_SORT_CHILDREN);
ADD_SIGNAL(MethodInfo("pre_sort_children"));
ADD_SIGNAL(MethodInfo("sort_children"));
}