MCPcopy Create free account
hub / github.com/Wemino/MarkerPatch / TreeNodeBehavior

Method TreeNodeBehavior

include/imgui/imgui_widgets.cpp:6869–7150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6867}
6868
6869bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
6870{
6871 ImGuiWindow* window = GetCurrentWindow();
6872 if (window->SkipItems)
6873 return false;
6874
6875 ImGuiContext& g = *GImGui;
6876 const ImGuiStyle& style = g.Style;
6877
6878 // When not framed, we vertically increase height up to typical framed widget height
6879 const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
6880 const bool use_frame_padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding));
6881 const ImVec2 padding = use_frame_padding ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
6882
6883 if (!label_end)
6884 label_end = FindRenderedTextEnd(label);
6885 const ImVec2 label_size = CalcTextSize(label, label_end, false);
6886
6887 const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
6888 const float text_offset_y = use_frame_padding ? ImMax(style.FramePadding.y, window->DC.CurrLineTextBaseOffset) : window->DC.CurrLineTextBaseOffset; // Latch before ItemSize changes it
6889 const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow
6890
6891 const float frame_height = label_size.y + padding.y * 2;
6892 const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
6893 const bool span_all_columns_label = (flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) != 0 && (g.CurrentTable != NULL);
6894 ImRect frame_bb;
6895 frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
6896 frame_bb.Min.y = window->DC.CursorPos.y + (text_offset_y - padding.y);
6897 frame_bb.Max.x = span_all_columns ? window->ParentWorkRect.Max.x : (flags & ImGuiTreeNodeFlags_SpanLabelWidth) ? window->DC.CursorPos.x + text_width + padding.x : window->WorkRect.Max.x;
6898 frame_bb.Max.y = window->DC.CursorPos.y + (text_offset_y - padding.y) + frame_height;
6899 if (display_frame)
6900 {
6901 const float outer_extend = IM_TRUNC(window->WindowPadding.x * 0.5f); // Framed header expand a little outside of current limits
6902 frame_bb.Min.x -= outer_extend;
6903 frame_bb.Max.x += outer_extend;
6904 }
6905
6906 ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
6907 ItemSize(ImVec2(text_width, frame_height), padding.y);
6908
6909 // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
6910 ImRect interact_bb = frame_bb;
6911 if ((flags & (ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanLabelWidth | ImGuiTreeNodeFlags_SpanAllColumns)) == 0)
6912 interact_bb.Max.x = frame_bb.Min.x + text_width + (label_size.x > 0.0f ? style.ItemSpacing.x * 2.0f : 0.0f);
6913
6914 // Compute open and multi-select states before ItemAdd() as it clear NextItem data.
6915 ImGuiID storage_id = (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasStorageID) ? g.NextItemData.StorageId : id;
6916 bool is_open = TreeNodeUpdateNextOpen(storage_id, flags);
6917
6918 bool is_visible;
6919 if (span_all_columns || span_all_columns_label)
6920 {
6921 // Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackgroundChannel for every Selectable..
6922 const float backup_clip_rect_min_x = window->ClipRect.Min.x;
6923 const float backup_clip_rect_max_x = window->ClipRect.Max.x;
6924 window->ClipRect.Min.x = window->ParentWorkRect.Min.x;
6925 window->ClipRect.Max.x = window->ParentWorkRect.Max.x;
6926 is_visible = ItemAdd(interact_bb, id);

Callers

nothing calls this directly

Calls 7

GetCurrentWindowFunction · 0.85
ImVec2Function · 0.85
ImMinFunction · 0.85
ImMaxFunction · 0.85
ItemSizeFunction · 0.85
TreeNodeStoreStackDataFunction · 0.85
SetIntMethod · 0.80

Tested by

no test coverage detected