Skip to content

Commit 290e402

Browse files
committed
TreeNode, Tables: added ImGuiTreeNodeFlags_LabelSpanAllColumns. (ocornut#8318, ocornut#3565)
1 parent 6fb7d44 commit 290e402

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

docs/CHANGELOG.txt

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ Other changes:
7070
coordinates.
7171
- Tables, MultiSelect: Fixed an issue where column width may be mismeasured
7272
when calling BeginMultiSelect() while inside a table. (#8250)
73+
- TreeNode, Tables: Added ImGuiTreeNodeFlags_LabelSpanAllColumns to make
74+
the label (not only the frame) also spans all columns. This can be useful
75+
for table rows where you know nothing else is submitted. (#8318, #3565)
76+
Obviously best used with ImGuiTableFlags_NoBordersInBodyUntilResize.
7377
- Drags: Added ImGuiSliderFlags_NoSpeedTweaks flag to disable keyboard
7478
modifiers altering the tweak speed. Useful if you want to alter tweak speed
7579
yourself based on your own logic. (#8223)

imgui.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
// Library Version
3030
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
3131
#define IMGUI_VERSION "1.91.7 WIP"
32-
#define IMGUI_VERSION_NUM 19165
32+
#define IMGUI_VERSION_NUM 19166
3333
#define IMGUI_HAS_TABLE
3434

3535
/*
@@ -1206,9 +1206,10 @@ enum ImGuiTreeNodeFlags_
12061206
ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line without using AllowOverlap mode.
12071207
ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (cover the indent area).
12081208
ImGuiTreeNodeFlags_SpanTextWidth = 1 << 13, // Narrow hit box + narrow hovering highlight, will only cover the label text.
1209-
ImGuiTreeNodeFlags_SpanAllColumns = 1 << 14, // Frame will span all columns of its container table (text will still fit in current column)
1210-
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 15, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
1209+
ImGuiTreeNodeFlags_SpanAllColumns = 1 << 14, // Frame will span all columns of its container table (label will still fit in current column)
1210+
ImGuiTreeNodeFlags_LabelSpanAllColumns = 1 << 15, // Label will span all columns of its container table
12111211
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 16, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
1212+
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 17, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
12121213
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog,
12131214

12141215
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS

imgui_demo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6363,6 +6363,8 @@ static void ShowDemoWindowTables()
63636363
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanFullWidth);
63646364
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanTextWidth", &tree_node_flags, ImGuiTreeNodeFlags_SpanTextWidth);
63656365
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &tree_node_flags, ImGuiTreeNodeFlags_SpanAllColumns);
6366+
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_LabelSpanAllColumns", &tree_node_flags, ImGuiTreeNodeFlags_LabelSpanAllColumns);
6367+
ImGui::SameLine(); HelpMarker("Useful if you know that you aren't displaying contents in other columns");
63666368

63676369
HelpMarker("See \"Columns flags\" section to configure how indentation is applied to individual columns.");
63686370
if (ImGui::BeginTable("3ways", 3, flags))

imgui_widgets.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -6532,6 +6532,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
65326532
// We vertically grow up to current line height up the typical widget height.
65336533
const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2);
65346534
const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
6535+
const bool span_all_columns_label = (flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) != 0 && (g.CurrentTable != NULL);
65356536
ImRect frame_bb;
65366537
frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
65376538
frame_bb.Min.y = window->DC.CursorPos.y;
@@ -6557,7 +6558,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
65576558
bool is_open = TreeNodeUpdateNextOpen(storage_id, flags);
65586559

65596560
bool is_visible;
6560-
if (span_all_columns)
6561+
if (span_all_columns || span_all_columns_label)
65616562
{
65626563
// Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackgroundChannel for every Selectable..
65636564
const float backup_clip_rect_min_x = window->ClipRect.Min.x;
@@ -6598,7 +6599,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
65986599
return is_open;
65996600
}
66006601

6601-
if (span_all_columns)
6602+
if (span_all_columns || span_all_columns_label)
66026603
{
66036604
TablePushBackgroundChannel();
66046605
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasClipRect;
@@ -6751,14 +6752,17 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
67516752
LogSetNextTextDecoration(">", NULL);
67526753
}
67536754

6754-
if (span_all_columns)
6755+
if (span_all_columns && !span_all_columns_label)
67556756
TablePopBackgroundChannel();
67566757

67576758
// Label
67586759
if (display_frame)
67596760
RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size);
67606761
else
67616762
RenderText(text_pos, label, label_end, false);
6763+
6764+
if (span_all_columns_label)
6765+
TablePopBackgroundChannel();
67626766
}
67636767

67646768
if (store_tree_node_stack_data && is_open)

0 commit comments

Comments
 (0)