Internals: zero-clearing ImGuiWindow / ImGuiWindowTempData for simplicity. (amend)
All the non-zero fields previously initialized in ImGuiWindowTempData() are in fact setup in Begin: FocusCounterRegular, FocusCounterTabStop, TextWrapPos, LayoutType, ParentLayoutType
diff --git a/imgui.cpp b/imgui.cpp
index 4c37255..ca7afd3 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -2774,70 +2774,27 @@
//-----------------------------------------------------------------------------
// ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods
-ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
- : DrawListInst(&context->DrawListSharedData)
+ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst(NULL)
{
+ memset(this, 0, sizeof(*this));
Name = ImStrdup(name);
+ NameBufLen = (int)strlen(name) + 1;
ID = ImHashStr(name);
IDStack.push_back(ID);
- Flags = ImGuiWindowFlags_None;
- Pos = ImVec2(0.0f, 0.0f);
- Size = SizeFull = ImVec2(0.0f, 0.0f);
- ContentSize = ContentSizeExplicit = ImVec2(0.0f, 0.0f);
- WindowPadding = ImVec2(0.0f, 0.0f);
- WindowRounding = 0.0f;
- WindowBorderSize = 0.0f;
- NameBufLen = (int)strlen(name) + 1;
MoveId = GetID("#MOVE");
- ChildId = 0;
- Scroll = ImVec2(0.0f, 0.0f);
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
- ScrollbarSizes = ImVec2(0.0f, 0.0f);
- ScrollbarX = ScrollbarY = false;
- Active = WasActive = false;
- WriteAccessed = false;
- Collapsed = false;
- WantCollapseToggle = false;
- SkipItems = false;
- Appearing = false;
- Hidden = false;
- IsFallbackWindow = false;
- HasCloseButton = false;
- ResizeBorderHeld = -1;
- BeginCount = 0;
- BeginOrderWithinParent = -1;
- BeginOrderWithinContext = -1;
- PopupId = 0;
AutoFitFramesX = AutoFitFramesY = -1;
- AutoFitChildAxises = 0x00;
- AutoFitOnlyGrows = false;
AutoPosLastDirection = ImGuiDir_None;
- HiddenFramesCanSkipItems = HiddenFramesCannotSkipItems = 0;
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
-
- InnerRect = ImRect(0.0f, 0.0f, 0.0f, 0.0f); // Clear so the InnerRect.GetSize() code in Begin() doesn't lead to overflow even if the result isn't used.
-
LastFrameActive = -1;
LastTimeActive = -1.0f;
- ItemWidthDefault = 0.0f;
FontWindowScale = 1.0f;
SettingsOffset = -1;
-
DrawList = &DrawListInst;
+ DrawList->_Data = &context->DrawListSharedData;
DrawList->_OwnerName = Name;
- ParentWindow = NULL;
- RootWindow = NULL;
- RootWindowForTitleBarHighlight = NULL;
- RootWindowForNav = NULL;
-
- NavLastIds[0] = NavLastIds[1] = 0;
- NavRectRel[0] = NavRectRel[1] = ImRect();
- NavLastChildNavWindow = NULL;
-
- MemoryCompacted = false;
- MemoryDrawListIdxCapacity = MemoryDrawListVtxCapacity = 0;
}
ImGuiWindow::~ImGuiWindow()
diff --git a/imgui_internal.h b/imgui_internal.h
index 6b701a0..8e19894 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1503,7 +1503,8 @@
//-----------------------------------------------------------------------------
// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow.
-// FIXME: That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered.
+// (That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered..)
+// (This doesn't need a constructor because we zero-clear it as part of ImGuiWindow and all frame-temporary data are setup on Begin)
struct IMGUI_API ImGuiWindowTempData
{
// Layout
@@ -1557,40 +1558,6 @@
ImVector<float> TextWrapPosStack;
ImVector<ImGuiGroupData>GroupStack;
short StackSizesBackup[6]; // Store size of various stacks for asserting
-
- ImGuiWindowTempData()
- {
- CursorPos = CursorPosPrevLine = CursorStartPos = CursorMaxPos = ImVec2(0.0f, 0.0f);
- CurrLineSize = PrevLineSize = ImVec2(0.0f, 0.0f);
- CurrLineTextBaseOffset = PrevLineTextBaseOffset = 0.0f;
- Indent = ImVec1(0.0f);
- ColumnsOffset = ImVec1(0.0f);
- GroupOffset = ImVec1(0.0f);
-
- LastItemId = 0;
- LastItemStatusFlags = ImGuiItemStatusFlags_None;
- LastItemRect = LastItemDisplayRect = ImRect();
-
- NavLayerActiveMask = NavLayerActiveMaskNext = 0x00;
- NavLayerCurrent = ImGuiNavLayer_Main;
- NavFocusScopeIdCurrent = 0;
- NavHideHighlightOneFrame = false;
- NavHasScroll = false;
-
- MenuBarAppending = false;
- MenuBarOffset = ImVec2(0.0f, 0.0f);
- TreeDepth = 0;
- TreeJumpToParentOnPopMask = 0x00;
- StateStorage = NULL;
- CurrentColumns = NULL;
- LayoutType = ParentLayoutType = ImGuiLayoutType_Vertical;
- FocusCounterRegular = FocusCounterTabStop = -1;
-
- ItemFlags = ImGuiItemFlags_Default_;
- ItemWidth = 0.0f;
- TextWrapPos = -1.0f;
- memset(StackSizesBackup, 0, sizeof(StackSizesBackup));
- }
};
// Storage for one window