Skip to content

Commit 6db0766

Browse files
committed
Misc comments, internal renaming, added disable indentation option to Columns demo section.
1 parent 6789ea3 commit 6db0766

6 files changed

+25
-10
lines changed

docs/TODO.txt

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
207207
- tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer)
208208
- tree node: tweak color scheme to distinguish headers from selected tree node (#581)
209209
- tree node: leaf/non-leaf highlight mismatch.
210+
- tree node: _NoIndentOnOpen flag? would require to store a per-depth bit mask to store info for pop (or whatever is cheaper)
210211

211212
- settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes?
212213
- settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437)

imgui.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ CODE
393393
- 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
394394
- 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
395395
- 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.).
396-
old binding will still work as is, however prefer using the separated bindings as they will be updated to be multi-viewport conformant.
396+
old bindings will still work as is, however prefer using the separated bindings as they will be updated to support multi-viewports.
397397
when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call.
398+
in particular, note that old bindings called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function.
398399
- 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
399400
- 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details.
400401
- 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
@@ -5444,7 +5445,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
54445445
window->DC.TextWrapPosStack.resize(0);
54455446
window->DC.CurrentColumns = NULL;
54465447
window->DC.TreeDepth = 0;
5447-
window->DC.TreeDepthMayJumpToParentOnPop = 0x00;
5448+
window->DC.TreeStoreMayJumpToParentOnPop = 0x00;
54485449
window->DC.StateStorage = &window->StateStorage;
54495450
window->DC.GroupStack.resize(0);
54505451
window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
@@ -6396,7 +6397,7 @@ void ImGui::SetNextWindowBgAlpha(float alpha)
63966397
g.NextWindowData.BgAlphaCond = ImGuiCond_Always; // Using a Cond member for consistency (may transition all of them to single flag set for fast Clear() op)
63976398
}
63986399

6399-
// FIXME: This is in window space (not screen space!)
6400+
// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
64006401
ImVec2 ImGui::GetContentRegionMax()
64016402
{
64026403
ImGuiWindow* window = GImGui->CurrentWindow;

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ enum ImGuiTreeNodeFlags_
782782
ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
783783
ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow
784784
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().
785-
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
785+
//ImGuiTreeNodeFlags_SpanAllAvailWidth = 1 << 11, // FIXME: TODO: Extend hit box horizontally even if not framed
786786
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 12, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible
787787
ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop)
788788
ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog

imgui_demo.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,13 @@ static void ShowDemoWindowColumns()
23672367

23682368
ImGui::PushID("Columns");
23692369

2370+
static bool disable_indent = false;
2371+
ImGui::Checkbox("Disable tree indentation", &disable_indent);
2372+
ImGui::SameLine();
2373+
HelpMarker("Disable the indenting of tree nodes so demo columns can use the full window width.");
2374+
if (disable_indent)
2375+
ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 0.0f);
2376+
23702377
// Basic columns
23712378
if (ImGui::TreeNode("Basic"))
23722379
{
@@ -2472,7 +2479,10 @@ static void ShowDemoWindowColumns()
24722479
if (h_borders && ImGui::GetColumnIndex() == 0)
24732480
ImGui::Separator();
24742481
ImGui::Text("%c%c%c", 'a'+i, 'a'+i, 'a'+i);
2475-
ImGui::Text("Width %.2f\nOffset %.2f", ImGui::GetColumnWidth(), ImGui::GetColumnOffset());
2482+
ImGui::Text("Width %.2f", ImGui::GetColumnWidth());
2483+
ImGui::Text("Offset %.2f", ImGui::GetColumnOffset());
2484+
ImGui::Text("Long text that is likely to clip");
2485+
ImGui::Button("Button", ImVec2(-1.0f, 0.0f));
24762486
ImGui::NextColumn();
24772487
}
24782488
ImGui::Columns(1);
@@ -2540,6 +2550,9 @@ static void ShowDemoWindowColumns()
25402550
ImGui::Separator();
25412551
ImGui::TreePop();
25422552
}
2553+
2554+
if (disable_indent)
2555+
ImGui::PopStyleVar();
25432556
ImGui::PopID();
25442557
}
25452558

imgui_internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ struct IMGUI_API ImGuiWindowTempData
11231123
ImVec2 PrevLineSize;
11241124
float PrevLineTextBaseOffset;
11251125
int TreeDepth;
1126-
ImU32 TreeDepthMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31
1126+
ImU32 TreeStoreMayJumpToParentOnPop; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary.
11271127
ImGuiID LastItemId;
11281128
ImGuiItemStatusFlags LastItemStatusFlags;
11291129
ImRect LastItemRect; // Interaction rect
@@ -1165,7 +1165,7 @@ struct IMGUI_API ImGuiWindowTempData
11651165
CurrentLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
11661166
CurrentLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
11671167
TreeDepth = 0;
1168-
TreeDepthMayJumpToParentOnPop = 0x00;
1168+
TreeStoreMayJumpToParentOnPop = 0x00;
11691169
LastItemId = 0;
11701170
LastItemStatusFlags = 0;
11711171
LastItemRect = LastItemDisplayRect = ImRect();

imgui_widgets.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -5073,7 +5073,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
50735073
// For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop().
50745074
// This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero.
50755075
if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
5076-
window->DC.TreeDepthMayJumpToParentOnPop |= (1 << window->DC.TreeDepth);
5076+
window->DC.TreeStoreMayJumpToParentOnPop |= (1 << window->DC.TreeDepth);
50775077

50785078
bool item_add = ItemAdd(interact_bb, id);
50795079
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDisplayRect;
@@ -5223,12 +5223,12 @@ void ImGui::TreePop()
52235223

52245224
window->DC.TreeDepth--;
52255225
if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
5226-
if (g.NavIdIsAlive && (window->DC.TreeDepthMayJumpToParentOnPop & (1 << window->DC.TreeDepth)))
5226+
if (g.NavIdIsAlive && (window->DC.TreeStoreMayJumpToParentOnPop & (1 << window->DC.TreeDepth)))
52275227
{
52285228
SetNavID(window->IDStack.back(), g.NavLayer);
52295229
NavMoveRequestCancel();
52305230
}
5231-
window->DC.TreeDepthMayJumpToParentOnPop &= (1 << window->DC.TreeDepth) - 1;
5231+
window->DC.TreeStoreMayJumpToParentOnPop &= (1 << window->DC.TreeDepth) - 1;
52325232

52335233
IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much.
52345234
PopID();

0 commit comments

Comments
 (0)