[ui] Implement View_Delete

As per the pre-ECS view code, the entire sub-hierarchy of views is
deleted along with the parent view.
This commit is contained in:
Bill Currie 2022-11-08 00:20:02 +09:00
parent 24d8d864a2
commit 9bf506fec6

View file

@ -124,6 +124,7 @@ typedef void (*view_move_f) (view_t view, view_pos_t abs);
#define VIEWINLINE GNU89INLINE inline
view_t View_New (ecs_registry_t *reg, view_t parent);
VIEWINLINE void View_Delete (view_t view);
void View_SetParent (view_t view, view_t parent);
void View_UpdateHierarchy (view_t view);
@ -179,6 +180,17 @@ View_Valid (view_t view)
return view.reg && ECS_EntValid (view.id, view.reg);
}
VIEWINLINE
void
View_Delete (view_t view)
{
__auto_type ref = *View_GetRef (view);
Hierarchy_RemoveHierarchy (ref.hierarchy, ref.index, 1);
if (!ref.hierarchy->num_objects) {
Hierarchy_Delete (ref.hierarchy);
}
}
VIEWINLINE
view_t
View_GetParent (view_t view)