From 6089e38e279fc0f1d1c01b23c7b977adac279b1f Mon Sep 17 00:00:00 2001 From: Marco Melorio Date: Thu, 21 Mar 2019 02:52:41 +0100 Subject: [PATCH] Added ImGuiTreeNodeFlags_SpanAllAvailWidth flag option to TreeNodeEx --- imgui.h | 2 +- imgui_widgets.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/imgui.h b/imgui.h index 04a4c0e337d3..7dd0d59902db 100644 --- a/imgui.h +++ b/imgui.h @@ -777,7 +777,7 @@ enum ImGuiTreeNodeFlags_ ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding(). - //ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed + ImGuiTreeNodeFlags_SpanAllAvailWidth = 1 << 11, // Extend hit box horizontally even if not framed //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop) ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index f457f8277478..072bcf773386 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5002,8 +5002,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 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 ? frame_bb : ImRect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + text_width + style.ItemSpacing.x*2, frame_bb.Max.y); + const ImRect interact_bb = display_frame || (flags & ImGuiTreeNodeFlags_SpanAllAvailWidth) ? frame_bb : ImRect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + text_width + style.ItemSpacing.x*2, frame_bb.Max.y); bool is_open = TreeNodeBehaviorIsOpen(id, flags); bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;