mirror of
				https://github.com/nicbarker/clay.git
				synced 2025-11-04 08:36:17 +00:00 
			
		
		
		
	[Bug Fix] Multiple Floating Elements Cannot Use Clay_Hovered() (#461)
				
					
				
			Co-authored-by: Nic Barker <contact+github@nicbarker.com>
This commit is contained in:
		
							parent
							
								
									7874cdb085
								
							
						
					
					
						commit
						c6442bd192
					
				
							
								
								
									
										12
									
								
								clay.h
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								clay.h
									
									
									
									
									
								
							| 
						 | 
					@ -1146,6 +1146,7 @@ typedef struct {
 | 
				
			||||||
    Clay_LayoutConfig *layoutConfig;
 | 
					    Clay_LayoutConfig *layoutConfig;
 | 
				
			||||||
    Clay__ElementConfigArraySlice elementConfigs;
 | 
					    Clay__ElementConfigArraySlice elementConfigs;
 | 
				
			||||||
    uint32_t id;
 | 
					    uint32_t id;
 | 
				
			||||||
 | 
					    uint16_t floatingChildrenCount;
 | 
				
			||||||
} Clay_LayoutElement;
 | 
					} Clay_LayoutElement;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CLAY__ARRAY_DEFINE(Clay_LayoutElement, Clay_LayoutElementArray)
 | 
					CLAY__ARRAY_DEFINE(Clay_LayoutElement, Clay_LayoutElementArray)
 | 
				
			||||||
| 
						 | 
					@ -1776,7 +1777,8 @@ Clay_LayoutElementHashMapItem *Clay__GetHashMapItem(uint32_t id) {
 | 
				
			||||||
Clay_ElementId Clay__GenerateIdForAnonymousElement(Clay_LayoutElement *openLayoutElement) {
 | 
					Clay_ElementId Clay__GenerateIdForAnonymousElement(Clay_LayoutElement *openLayoutElement) {
 | 
				
			||||||
    Clay_Context* context = Clay_GetCurrentContext();
 | 
					    Clay_Context* context = Clay_GetCurrentContext();
 | 
				
			||||||
    Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 2));
 | 
					    Clay_LayoutElement *parentElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&context->openLayoutElementStack, context->openLayoutElementStack.length - 2));
 | 
				
			||||||
    Clay_ElementId elementId = Clay__HashNumber(parentElement->childrenOrTextContent.children.length, parentElement->id);
 | 
					    uint32_t offset = parentElement->childrenOrTextContent.children.length + parentElement->floatingChildrenCount;
 | 
				
			||||||
 | 
					    Clay_ElementId elementId = Clay__HashNumber(offset, parentElement->id);
 | 
				
			||||||
    openLayoutElement->id = elementId.id;
 | 
					    openLayoutElement->id = elementId.id;
 | 
				
			||||||
    Clay__AddHashMapItem(elementId, openLayoutElement);
 | 
					    Clay__AddHashMapItem(elementId, openLayoutElement);
 | 
				
			||||||
    Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
 | 
					    Clay__StringArray_Add(&context->layoutElementIdStrings, elementId.stringId);
 | 
				
			||||||
| 
						 | 
					@ -1917,9 +1919,15 @@ void Clay__CloseElement(void) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Close the currently open element
 | 
					    // Close the currently open element
 | 
				
			||||||
    int32_t closingElementIndex = Clay__int32_tArray_RemoveSwapback(&context->openLayoutElementStack, (int)context->openLayoutElementStack.length - 1);
 | 
					    int32_t closingElementIndex = Clay__int32_tArray_RemoveSwapback(&context->openLayoutElementStack, (int)context->openLayoutElementStack.length - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Get the currently open parent
 | 
				
			||||||
    openLayoutElement = Clay__GetOpenLayoutElement();
 | 
					    openLayoutElement = Clay__GetOpenLayoutElement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!elementIsFloating && context->openLayoutElementStack.length > 1) {
 | 
					    if (context->openLayoutElementStack.length > 1) {
 | 
				
			||||||
 | 
					        if(elementIsFloating) {
 | 
				
			||||||
 | 
					            openLayoutElement->floatingChildrenCount++;
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        openLayoutElement->childrenOrTextContent.children.length++;
 | 
					        openLayoutElement->childrenOrTextContent.children.length++;
 | 
				
			||||||
        Clay__int32_tArray_Add(&context->layoutElementChildrenBuffer, closingElementIndex);
 | 
					        Clay__int32_tArray_Add(&context->layoutElementChildrenBuffer, closingElementIndex);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue