WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 9f64d59

Browse files
Merge branch 'ocornut:master' into features/modules
2 parents 167495e + 620a33d commit 9f64d59

File tree

7 files changed

+45
-21
lines changed

7 files changed

+45
-21
lines changed

docs/CHANGELOG.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ Other Changes:
5454
- Menus:
5555
- Fixed MenuItem() label position and BeginMenu() arrow/icon/popup positions,
5656
when used inside a line with a baseline offset.
57+
- TreeNode:
58+
- Fixed highlight position when used inside a line with a large text baseline offset.
59+
(never quite worked in this situation; but then most of the time the text
60+
baseline offset ends up being zero or FramePadding.y for a given line).
61+
- Tables:
62+
- Fixed an issue where a very thin scrolling table would advance parent layout
63+
slightly differently depending on its visibility (caused by a mismatch
64+
between hard minimum window size and table minimum size).
65+
- Fixed an issue where submitting non-integer row heights would eventually
66+
advance table parent layout by +0/+1 depending on its visibility.
5767
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
5868
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
5969
- Backends:

imgui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6584,13 +6584,13 @@ static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
65846584
ImVec2 size_min;
65856585
if ((window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup))
65866586
{
6587-
size_min.x = (window->ChildFlags & ImGuiChildFlags_ResizeX) ? g.Style.WindowMinSize.x : 4.0f;
6588-
size_min.y = (window->ChildFlags & ImGuiChildFlags_ResizeY) ? g.Style.WindowMinSize.y : 4.0f;
6587+
size_min.x = (window->ChildFlags & ImGuiChildFlags_ResizeX) ? g.Style.WindowMinSize.x : IMGUI_WINDOW_HARD_MIN_SIZE;
6588+
size_min.y = (window->ChildFlags & ImGuiChildFlags_ResizeY) ? g.Style.WindowMinSize.y : IMGUI_WINDOW_HARD_MIN_SIZE;
65896589
}
65906590
else
65916591
{
6592-
size_min.x = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : 4.0f;
6593-
size_min.y = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.y : 4.0f;
6592+
size_min.x = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : IMGUI_WINDOW_HARD_MIN_SIZE;
6593+
size_min.y = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.y : IMGUI_WINDOW_HARD_MIN_SIZE;
65946594
}
65956595

65966596
// Reduce artifacts with very small windows

imgui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// Library Version
3131
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
3232
#define IMGUI_VERSION "1.92.6 WIP"
33-
#define IMGUI_VERSION_NUM 19251
33+
#define IMGUI_VERSION_NUM 19252
3434
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
3535
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
3636

imgui_demo.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,7 +2863,7 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
28632863

28642864
const int ITEMS_COUNT = 10000;
28652865
ImGui::Text("Selection: %d/%d", selection.Size, ITEMS_COUNT);
2866-
if (ImGui::BeginTable("##Basket", 2, ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter))
2866+
if (ImGui::BeginTable("##Basket", 2, ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter, ImVec2(0.0f, ImGui::GetFontSize() * 20)))
28672867
{
28682868
ImGui::TableSetupColumn("Object");
28692869
ImGui::TableSetupColumn("Action");
@@ -2884,13 +2884,15 @@ static void DemoWindowWidgetsSelectionAndMultiSelect(ImGuiDemoWindowData* demo_d
28842884
{
28852885
ImGui::TableNextRow();
28862886
ImGui::TableNextColumn();
2887+
ImGui::PushID(n);
28872888
char label[64];
28882889
sprintf(label, "Object %05d: %s", n, ExampleNames[n % IM_ARRAYSIZE(ExampleNames)]);
28892890
bool item_is_selected = selection.Contains((ImGuiID)n);
28902891
ImGui::SetNextItemSelectionUserData(n);
28912892
ImGui::Selectable(label, item_is_selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap);
28922893
ImGui::TableNextColumn();
28932894
ImGui::SmallButton("hello");
2895+
ImGui::PopID();
28942896
}
28952897
}
28962898

@@ -4084,6 +4086,7 @@ static void DemoWindowWidgetsTreeNodes()
40844086
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAllColumns", &base_flags, ImGuiTreeNodeFlags_SpanAllColumns); ImGui::SameLine(); HelpMarker("For use in Tables only.");
40854087
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_AllowOverlap", &base_flags, ImGuiTreeNodeFlags_AllowOverlap);
40864088
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_Framed", &base_flags, ImGuiTreeNodeFlags_Framed); ImGui::SameLine(); HelpMarker("Draw frame with background (e.g. for CollapsingHeader)");
4089+
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_FramePadding", &base_flags, ImGuiTreeNodeFlags_FramePadding);
40874090
ImGui::CheckboxFlags("ImGuiTreeNodeFlags_NavLeftJumpsToParent", &base_flags, ImGuiTreeNodeFlags_NavLeftJumpsToParent);
40884091

40894092
HelpMarker("Default option for DrawLinesXXX is stored in style.TreeLinesFlags");
@@ -4748,7 +4751,7 @@ static void DemoWindowLayout()
47484751
// Tree
47494752
// (here the node appears after a button and has odd intent, so we use ImGuiTreeNodeFlags_DrawLinesNone to disable hierarchy outline)
47504753
const float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
4751-
ImGui::Button("Button##1");
4754+
ImGui::Button("Button##1"); // Will make line higher
47524755
ImGui::SameLine(0.0f, spacing);
47534756
if (ImGui::TreeNodeEx("Node##1", ImGuiTreeNodeFlags_DrawLinesNone))
47544757
{
@@ -4758,14 +4761,22 @@ static void DemoWindowLayout()
47584761
ImGui::TreePop();
47594762
}
47604763

4764+
const float padding = (float)(int)(ImGui::GetFontSize() * 1.20f); // Large padding
4765+
ImGui::PushStyleVarY(ImGuiStyleVar_FramePadding, padding);
4766+
ImGui::Button("Button##2");
4767+
ImGui::PopStyleVar();
4768+
ImGui::SameLine(0.0f, spacing);
4769+
if (ImGui::TreeNodeEx("Node##2", ImGuiTreeNodeFlags_DrawLinesNone))
4770+
ImGui::TreePop();
4771+
47614772
// Vertically align text node a bit lower so it'll be vertically centered with upcoming widget.
47624773
// Otherwise you can use SmallButton() (smaller fit).
47634774
ImGui::AlignTextToFramePadding();
47644775

47654776
// Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add
4766-
// other contents below the node.
4767-
bool node_open = ImGui::TreeNode("Node##2");
4768-
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2");
4777+
// other contents "inside" the node.
4778+
bool node_open = ImGui::TreeNode("Node##3");
4779+
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##3");
47694780
if (node_open)
47704781
{
47714782
// Placeholder tree data
@@ -4775,13 +4786,13 @@ static void DemoWindowLayout()
47754786
}
47764787

47774788
// Bullet
4778-
ImGui::Button("Button##3");
4789+
ImGui::Button("Button##4");
47794790
ImGui::SameLine(0.0f, spacing);
47804791
ImGui::BulletText("Bullet text");
47814792

47824793
ImGui::AlignTextToFramePadding();
47834794
ImGui::BulletText("Node");
4784-
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4");
4795+
ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##5");
47854796
ImGui::Unindent();
47864797
}
47874798

imgui_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,6 +2561,8 @@ struct ImGuiContext
25612561
// [SECTION] ImGuiWindowTempData, ImGuiWindow
25622562
//-----------------------------------------------------------------------------
25632563

2564+
#define IMGUI_WINDOW_HARD_MIN_SIZE 4.0f
2565+
25642566
// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
25652567
// (That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered..)
25662568
// (This doesn't need a constructor because we zero-clear it as part of ImGuiWindow and all frame-temporary data are setup on Begin)

imgui_tables.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
335335
// - always performing the GetOrAddByKey() O(log N) query in g.Tables.Map[].
336336
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
337337
const ImVec2 avail_size = GetContentRegionAvail();
338-
const ImVec2 actual_outer_size = ImTrunc(CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f));
338+
const ImVec2 actual_outer_size = ImTrunc(CalcItemSize(outer_size, ImMax(avail_size.x, IMGUI_WINDOW_HARD_MIN_SIZE), use_child_window ? ImMax(avail_size.y, IMGUI_WINDOW_HARD_MIN_SIZE) : 0.0f));
339339
const ImRect outer_rect(outer_window->DC.CursorPos, outer_window->DC.CursorPos + actual_outer_size);
340340
const bool outer_window_is_measuring_size = (outer_window->AutoFitFramesX > 0) || (outer_window->AutoFitFramesY > 0); // Doesn't apply to AlwaysAutoResize windows!
341341
if (use_child_window && IsClippedEx(outer_rect, 0) && !outer_window_is_measuring_size)
@@ -1383,7 +1383,7 @@ void ImGui::EndTable()
13831383
inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize;
13841384
inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize;
13851385
inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos;
1386-
const float inner_content_max_y = table->RowPosY2;
1386+
const float inner_content_max_y = ImCeil(table->RowPosY2); // Rounding final position is important as we currently don't round row height ('Demo->Tables->Outer Size' demo uses non-integer heights)
13871387
IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y);
13881388
if (inner_window != outer_window)
13891389
inner_window->DC.CursorMaxPos.y = inner_content_max_y;

imgui_widgets.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6776,7 +6776,6 @@ static void TreeNodeStoreStackData(ImGuiTreeNodeFlags flags, float x1)
67766776
window->DC.TreeRecordsClippedNodesY2Mask |= (1 << window->DC.TreeDepth);
67776777
}
67786778

6779-
// When using public API, currently 'id == storage_id' is always true, but we separate the values to facilitate advanced user code doing storage queries outside of UI loop.
67806779
bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end)
67816780
{
67826781
ImGuiWindow* window = GetCurrentWindow();
@@ -6785,26 +6784,28 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
67856784

67866785
ImGuiContext& g = *GImGui;
67876786
const ImGuiStyle& style = g.Style;
6787+
6788+
// When not framed, we vertically increase height up to typical framed widget height
67886789
const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0;
6789-
const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
6790+
const bool use_frame_padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding));
6791+
const ImVec2 padding = use_frame_padding ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y));
67906792

67916793
if (!label_end)
67926794
label_end = FindRenderedTextEnd(label);
67936795
const ImVec2 label_size = CalcTextSize(label, label_end, false);
67946796

67956797
const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapsing arrow width + Spacing
6796-
const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
6798+
const float text_offset_y = use_frame_padding ? ImMax(style.FramePadding.y, window->DC.CurrLineTextBaseOffset) : window->DC.CurrLineTextBaseOffset; // Latch before ItemSize changes it
67976799
const float text_width = g.FontSize + label_size.x + padding.x * 2; // Include collapsing arrow
67986800

6799-
// We vertically grow up to current line height up the typical widget height.
6800-
const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2);
6801+
const float frame_height = label_size.y + padding.y * 2;
68016802
const bool span_all_columns = (flags & ImGuiTreeNodeFlags_SpanAllColumns) != 0 && (g.CurrentTable != NULL);
68026803
const bool span_all_columns_label = (flags & ImGuiTreeNodeFlags_LabelSpanAllColumns) != 0 && (g.CurrentTable != NULL);
68036804
ImRect frame_bb;
68046805
frame_bb.Min.x = span_all_columns ? window->ParentWorkRect.Min.x : (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
6805-
frame_bb.Min.y = window->DC.CursorPos.y;
6806+
frame_bb.Min.y = window->DC.CursorPos.y + (text_offset_y - padding.y);
68066807
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;
6807-
frame_bb.Max.y = window->DC.CursorPos.y + frame_height;
6808+
frame_bb.Max.y = window->DC.CursorPos.y + (text_offset_y - padding.y) + frame_height;
68086809
if (display_frame)
68096810
{
68106811
const float outer_extend = IM_TRUNC(window->WindowPadding.x * 0.5f); // Framed header expand a little outside of current limits

0 commit comments

Comments
 (0)