mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	TreeNode: Added ImGuiTreeNodeFlags_FramePadding flag
This commit is contained in:
		
							
								
								
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -6104,14 +6104,14 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     const ImGuiStyle& style = g.Style; | ||||
|     const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0; | ||||
|     const ImVec2 padding = display_frame ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f); | ||||
|     const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, 0.0f); | ||||
|  | ||||
|     if (!label_end) | ||||
|         label_end = FindRenderedTextEnd(label); | ||||
|     const ImVec2 label_size = CalcTextSize(label, label_end, false); | ||||
|  | ||||
|     // We vertically grow up to current line height up the typical widget height. | ||||
|     const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset - padding.y); // Latch before ItemSize changes it | ||||
|     const float text_base_offset_y = ImMax(padding.y, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it | ||||
|     const float frame_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2); | ||||
|     ImRect bb = ImRect(window->DC.CursorPos, ImVec2(window->Pos.x + GetContentRegionMax().x, window->DC.CursorPos.y + frame_height)); | ||||
|     if (display_frame) | ||||
| @@ -6126,7 +6126,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l | ||||
|     ItemSize(ImVec2(text_width, frame_height), text_base_offset_y); | ||||
|  | ||||
|     // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing | ||||
|     // (Ideally we'd want to add a flag for the user to specify we want want the hit test to be done up to the right side of the content or not) | ||||
|     // (Ideally we'd want to add a flag for the user to specify if we want the hit test to be done up to the right side of the content or not) | ||||
|     const ImRect interact_bb = display_frame ? bb : ImRect(bb.Min.x, bb.Min.y, bb.Min.x + text_width + style.ItemSpacing.x*2, bb.Max.y); | ||||
|     bool is_open = TreeNodeBehaviorIsOpen(id, flags); | ||||
|     if (!ItemAdd(interact_bb, id)) | ||||
| @@ -6163,12 +6163,12 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l | ||||
|  | ||||
|     // Render | ||||
|     const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); | ||||
|     const ImVec2 text_pos = bb.Min + ImVec2(text_offset_x, padding.y + text_base_offset_y); | ||||
|     const ImVec2 text_pos = bb.Min + ImVec2(text_offset_x, text_base_offset_y); | ||||
|     if (display_frame) | ||||
|     { | ||||
|         // Framed type | ||||
|         RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); | ||||
|         RenderCollapseTriangle(bb.Min + padding + ImVec2(0.0f, text_base_offset_y), is_open, 1.0f); | ||||
|         RenderCollapseTriangle(bb.Min + ImVec2(padding.x, text_base_offset_y), is_open, 1.0f); | ||||
|         if (g.LogEnabled) | ||||
|         { | ||||
|             // NB: '##' is normally used to hide text (as a library-wide feature), so we need to specify the text range to make sure the ## aren't stripped out here. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user