Merge branch '1.21' into new-container-api

This commit is contained in:
DBotThePony 2025-03-21 10:46:03 +07:00
commit 70ed0cfcba
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -847,6 +847,12 @@ open class EditablePanel<out S : Screen>(
childrenSortingInvalidated = true
}
protected open fun onChildrenAdded(child: EditablePanel<*>) {}
protected open fun onChildrenRemoved(child: EditablePanel<*>) {}
protected open fun onParented(parent: EditablePanel<*>) {}
protected open fun onUnParented(parent: EditablePanel<*>) {}
private fun onParent(child: EditablePanel<*>) {
if (childrenInternal.contains(child)) throw IllegalStateException("Already containing $child")
childrenInternal.add(child)
@ -864,11 +870,15 @@ open class EditablePanel<out S : Screen>(
else
updateVisibility = true
}
onChildrenAdded(child)
child.onParented(this)
}
private fun onUnParent(child: EditablePanel<*>) {
val indexOf = childrenInternal.indexOf(child)
if (indexOf == -1) throw IllegalStateException("Already not containing $child")
child.onUnParented(this)
childrenInternal.removeAt(indexOf)
invalidateChildrenSorting()
@ -880,6 +890,8 @@ open class EditablePanel<out S : Screen>(
if (child.isVisible() != isVisible()) {
updateVisible()
}
onChildrenRemoved(child)
}
private fun sortChildren() {