Internals: refactored g.SetNextWindow fields into g.NextWindow. structure (so it can be more easily transported/copied)

This commit is contained in:
omar
2018-01-03 12:12:41 +01:00
parent 856ee17ed8
commit 04b44398eb
2 changed files with 95 additions and 90 deletions

View File

@ -459,6 +459,38 @@ struct ImDrawListSharedData
ImDrawListSharedData();
};
// Storage for SetNexWindow** functions
struct ImGuiNextWindowData
{
ImGuiCond PosCond;
ImGuiCond SizeCond;
ImGuiCond ContentSizeCond;
ImGuiCond CollapsedCond;
ImVec2 PosVal;
ImVec2 PosPivotVal;
ImVec2 SizeVal;
ImVec2 ContentSizeVal;
bool CollapsedVal;
ImRect SizeConstraintRect; // Valid if 'SetNextWindowSizeConstraint' is true
ImGuiSizeConstraintCallback SizeConstraintCallback;
void* SizeConstraintCallbackUserData;
bool SizeConstraint;
bool Focus;
ImGuiNextWindowData()
{
PosCond = SizeCond = ContentSizeCond = CollapsedCond = 0;
PosVal = PosPivotVal = SizeVal = ImVec2(0.0f, 0.0f);
ContentSizeVal = ImVec2(0.0f, 0.0f);
CollapsedVal = false;
SizeConstraintRect = ImRect();
SizeConstraintCallback = NULL;
SizeConstraintCallbackUserData = NULL;
SizeConstraint = false;
Focus = false;
}
};
// Main state for ImGui
struct ImGuiContext
{
@ -502,24 +534,9 @@ struct ImGuiContext
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont()
ImVector<ImGuiPopupRef> OpenPopupStack; // Which popups are open (persistent)
ImVector<ImGuiPopupRef> CurrentPopupStack; // Which level of BeginPopup() we are in (reset every frame)
// Storage for SetNexWindow** and SetNextTreeNode*** functions
ImVec2 SetNextWindowPosVal;
ImVec2 SetNextWindowPosPivot;
ImVec2 SetNextWindowSizeVal;
ImVec2 SetNextWindowContentSizeVal;
bool SetNextWindowCollapsedVal;
ImGuiCond SetNextWindowPosCond;
ImGuiCond SetNextWindowSizeCond;
ImGuiCond SetNextWindowContentSizeCond;
ImGuiCond SetNextWindowCollapsedCond;
ImRect SetNextWindowSizeConstraintRect; // Valid if 'SetNextWindowSizeConstraint' is true
ImGuiSizeConstraintCallback SetNextWindowSizeConstraintCallback;
void* SetNextWindowSizeConstraintCallbackUserData;
bool SetNextWindowSizeConstraint;
bool SetNextWindowFocus;
bool SetNextTreeNodeOpenVal;
ImGuiCond SetNextTreeNodeOpenCond;
ImGuiNextWindowData NextWindow; // Storage for SetNextWindow** functions
bool NextTreeNodeOpenVal; // Storage for SetNextTreeNode** functions
ImGuiCond NextTreeNodeOpenCond;
// Render
ImDrawData RenderDrawData; // Main ImDrawData instance to pass render information to the user
@ -609,20 +626,8 @@ struct ImGuiContext
MovingWindow = NULL;
MovingWindowMoveId = 0;
SetNextWindowPosVal = ImVec2(0.0f, 0.0f);
SetNextWindowSizeVal = ImVec2(0.0f, 0.0f);
SetNextWindowCollapsedVal = false;
SetNextWindowPosCond = 0;
SetNextWindowSizeCond = 0;
SetNextWindowContentSizeCond = 0;
SetNextWindowCollapsedCond = 0;
SetNextWindowSizeConstraintRect = ImRect();
SetNextWindowSizeConstraintCallback = NULL;
SetNextWindowSizeConstraintCallbackUserData = NULL;
SetNextWindowSizeConstraint = false;
SetNextWindowFocus = false;
SetNextTreeNodeOpenVal = false;
SetNextTreeNodeOpenCond = 0;
NextTreeNodeOpenVal = false;
NextTreeNodeOpenCond = 0;
DragDropActive = false;
DragDropSourceFlags = 0;