diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp index dc66a37..05dd415 100644 --- a/src/GUIStuff/GUIManager.cpp +++ b/src/GUIStuff/GUIManager.cpp @@ -379,8 +379,10 @@ void GUIManager::mouse_callback(const Vector2f& mousePos, const std::functionelem->mouseHovering = true; Element* nextParent = e->elem->parent; - while(nextParent) + while(nextParent) { nextParent->childMouseHovering |= true; + nextParent = nextParent->parent; + } } else e->elem->mouseHovering = false; diff --git a/src/GUIStuff/GUIManager.hpp b/src/GUIStuff/GUIManager.hpp index d01896a..d7223f2 100644 --- a/src/GUIStuff/GUIManager.hpp +++ b/src/GUIStuff/GUIManager.hpp @@ -37,24 +37,31 @@ class GUIManager { template ElementType* element(const char* id, const Args&... a) { push_id(id); + Element* oldParent = parentElement; ElementType* elem = insert_element(); elem->parent = parentElement; - Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack); + parentElement = elem; + elem->set_parent_clipping_region(clippingRegion); + Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack); elem->layout(clayId, a...); elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId)); // Setting bounding box after layout ensures that the element will have its bounding box set if it's set to be drawn. + parentElement = oldParent; + pop_id(); return elem; } template ElementType* clipping_element(const char* id, const Args&... a) { push_id(id); + Element* oldParent = parentElement; ElementType* elem = insert_element(); elem->parent = parentElement; - Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack); + parentElement = elem; + elem->set_parent_clipping_region(clippingRegion); auto oldClippingRegion = clippingRegion; if(elem->get_bb().has_value()) { @@ -63,10 +70,15 @@ class GUIManager { else clippingRegion = elem->get_bb(); } + + Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack); elem->layout(clayId, a...); elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId)); + clippingRegion = oldClippingRegion; + parentElement = oldParent; + pop_id(); return elem; }