Skip to content

Commit bff1836

Browse files
committed
Internals: added facility to hide windows from render without interfering with the HiddenFramesCanSkipItems/HiddenFramesCannotSkipItems fields which have effects on layout. Compact some fields.
Ideally we'd have a simpler system but it's not easy to make the capture system change to hook at the right spot. Will rework.
1 parent 1ad5502 commit bff1836

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

imgui.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5668,6 +5668,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
56685668
window->HiddenFramesCanSkipItems--;
56695669
if (window->HiddenFramesCannotSkipItems > 0)
56705670
window->HiddenFramesCannotSkipItems--;
5671+
if (window->HiddenFramesForRenderOnly > 0)
5672+
window->HiddenFramesForRenderOnly--;
56715673

56725674
// Hide new windows for one frame until they calculate their size
56735675
if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
@@ -6121,7 +6123,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
61216123
window->HiddenFramesCanSkipItems = 1;
61226124

61236125
// Update the Hidden flag
6124-
window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0);
6126+
window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0) || (window->HiddenFramesForRenderOnly > 0);
61256127

61266128
// Update the SkipItems flag, used to early out of all items functions (no layout required)
61276129
bool skip_items = false;
@@ -7788,7 +7790,7 @@ void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags toolt
77887790
{
77897791
// Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
77907792
window->Hidden = true;
7791-
window->HiddenFramesCanSkipItems = 1;
7793+
window->HiddenFramesCanSkipItems = 1; // FIXME: This may not be necessary?
77927794
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
77937795
}
77947796
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;

imgui_internal.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,11 +1722,12 @@ struct IMGUI_API ImGuiWindow
17221722
ImS8 AutoFitChildAxises;
17231723
bool AutoFitOnlyGrows;
17241724
ImGuiDir AutoPosLastDirection;
1725-
int HiddenFramesCanSkipItems; // Hide the window for N frames
1726-
int HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
1727-
ImGuiCond SetWindowPosAllowFlags; // store acceptable condition flags for SetNextWindowPos() use.
1728-
ImGuiCond SetWindowSizeAllowFlags; // store acceptable condition flags for SetNextWindowSize() use.
1729-
ImGuiCond SetWindowCollapsedAllowFlags; // store acceptable condition flags for SetNextWindowCollapsed() use.
1725+
ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames
1726+
ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size
1727+
ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only
1728+
ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use.
1729+
ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use.
1730+
ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use.
17301731
ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size)
17311732
ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right.
17321733

imgui_tables.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
716716
// Combine width from regular rows + width from headers unless requested not to.
717717
if (!column->IsPreserveWidthAuto)
718718
{
719-
const float content_width_body = (float)ImMax(column->ContentMaxXFrozen, column->ContentMaxXUnfrozen) - column->WorkMinX;
720-
const float content_width_headers = (float)column->ContentMaxXHeadersIdeal - column->WorkMinX;
719+
const float content_width_body = ImMax(column->ContentMaxXFrozen, column->ContentMaxXUnfrozen) - column->WorkMinX;
720+
const float content_width_headers = column->ContentMaxXHeadersIdeal - column->WorkMinX;
721721
float width_auto = content_width_body;
722722
if (!(table->Flags & ImGuiTableFlags_NoHeadersWidth) && !(column->Flags & ImGuiTableColumnFlags_NoHeaderWidth))
723723
width_auto = ImMax(width_auto, content_width_headers);

0 commit comments

Comments
 (0)