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

Method TreeNodeBehavior

include/imgui/imgui_widgets.cpp:6839–7120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6837}
6838
6839bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
6840{
6841 ImGuiWindow* window = GetCurrentWindow();
6842 if (window->SkipItems)
6843 return false;
6844
6845 ImGuiContext& g = *GImGui;
6846 const ImGuiStyle& style = g.Style;
6847
6848 // When not framed, we vertically increase height up to typical framed widget height
6849 const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
6850 const bool use_frame_padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding));
6851 const ImVec2 padding = use_frame_padding ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
6852
6853 if (!label_end)
6854 label_end = FindRenderedTextEnd(label);
6855 const ImVec2 label_size = CalcTextSize(label, label_end, false);
6856
6857 const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
6858 const float text_offset_y = use_frame_padding ? ImMax(style.FramePadding.y, window->DC.CurrLineTextBaseOffset) : window->DC.CurrLineTextBaseOffset; // Latch before ItemSize changes it
6859 const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow
6860
6861 const float frame_height = label_size.y + padding.y * 2;
6862 const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
6863 const bool span_all_columns_label = (flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) != 0 && (g.CurrentTable != NULL);
6864 ImRect frame_bb;
6865 frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
6866 frame_bb.Min.y = window->DC.CursorPos.y + (text_offset_y - padding.y);
6867 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;
6868 frame_bb.Max.y = window->DC.CursorPos.y + (text_offset_y - padding.y) + frame_height;
6869 if (display_frame)
6870 {
6871 const float outer_extend = IM_TRUNC(window->WindowPadding.x * 0.5f); // Framed header expand a little outside of current limits
6872 frame_bb.Min.x -= outer_extend;
6873 frame_bb.Max.x += outer_extend;
6874 }
6875
6876 ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
6877 ItemSize(ImVec2(text_width, frame_height), padding.y);
6878
6879 // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
6880 ImRect interact_bb = frame_bb;
6881 if ((flags & (ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_SpanLabelWidth | ImGuiTreeNodeFlags_SpanAllColumns)) == 0)
6882 interact_bb.Max.x = frame_bb.Min.x + text_width + (label_size.x > 0.0f ? style.ItemSpacing.x * 2.0f : 0.0f);
6883
6884 // Compute open and multi-select states before ItemAdd() as it clear NextItem data.
6885 ImGuiID storage_id = (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasStorageID) ? g.NextItemData.StorageId : id;
6886 bool is_open = TreeNodeUpdateNextOpen(storage_id, flags);
6887
6888 bool is_visible;
6889 if (span_all_columns || span_all_columns_label)
6890 {
6891 // Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackgroundChannel for every Selectable..
6892 const float backup_clip_rect_min_x = window->ClipRect.Min.x;
6893 const float backup_clip_rect_max_x = window->ClipRect.Max.x;
6894 window->ClipRect.Min.x = window->ParentWorkRect.Min.x;
6895 window->ClipRect.Max.x = window->ParentWorkRect.Max.x;
6896 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