Internal: Refactor: Moved NewFrameSanityChecks as ErrorCheckNewFrameSanityChecks()
This commit is contained in:
parent
ccf0cc8584
commit
fbc93debf9
73
imgui.cpp
73
imgui.cpp
@ -935,7 +935,8 @@ static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window);
|
||||
static int FindWindowFocusIndex(ImGuiWindow* window);
|
||||
|
||||
// Error Checking
|
||||
static void ErrorCheckEndFrame();
|
||||
static void ErrorCheckNewFrameSanityChecks();
|
||||
static void ErrorCheckEndFrameSanityChecks();
|
||||
static void ErrorCheckBeginEndCompareStacksSize(ImGuiWindow* window, bool write);
|
||||
|
||||
// Misc
|
||||
@ -3675,35 +3676,6 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
||||
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
||||
}
|
||||
|
||||
static void NewFrameSanityChecks()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// Check user data
|
||||
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
||||
IM_ASSERT(g.Initialized);
|
||||
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
||||
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
||||
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
||||
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
||||
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
||||
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
||||
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
||||
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
||||
|
||||
// Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
|
||||
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
||||
|
||||
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
||||
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
||||
g.IO.ConfigWindowsResizeFromEdges = false;
|
||||
}
|
||||
|
||||
static ImGuiKeyModFlags GetMergedKeyModFlags()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -3725,7 +3697,7 @@ void ImGui::NewFrame()
|
||||
#endif
|
||||
|
||||
// Check and assert for various common IO and Configuration mistakes
|
||||
NewFrameSanityChecks();
|
||||
ErrorCheckNewFrameSanityChecks();
|
||||
|
||||
// Load settings on first frame, save settings when modified (after a delay)
|
||||
UpdateSettings();
|
||||
@ -4171,10 +4143,14 @@ void ImGui::EndFrame()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.Initialized);
|
||||
if (g.FrameCountEnded == g.FrameCount) // Don't process EndFrame() multiple times.
|
||||
|
||||
// Don't process EndFrame() multiple times.
|
||||
if (g.FrameCountEnded == g.FrameCount)
|
||||
return;
|
||||
IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?");
|
||||
|
||||
ErrorCheckEndFrameSanityChecks();
|
||||
|
||||
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
||||
if (g.IO.ImeSetInputScreenPosFn && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f))
|
||||
{
|
||||
@ -4182,8 +4158,6 @@ void ImGui::EndFrame()
|
||||
g.PlatformImeLastPos = g.PlatformImePos;
|
||||
}
|
||||
|
||||
ErrorCheckEndFrame();
|
||||
|
||||
// Hide implicit/fallback "Debug" window if it hasn't been used
|
||||
g.WithinFrameScopeWithImplicitWindow = false;
|
||||
if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
|
||||
@ -6731,7 +6705,36 @@ bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, si
|
||||
return !error;
|
||||
}
|
||||
|
||||
static void ImGui::ErrorCheckEndFrame()
|
||||
static void ImGui::ErrorCheckNewFrameSanityChecks()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// Check user data
|
||||
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
||||
IM_ASSERT(g.Initialized);
|
||||
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
||||
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
||||
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
||||
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
||||
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
||||
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
||||
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
||||
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
||||
|
||||
// Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
|
||||
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
||||
|
||||
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
||||
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
||||
g.IO.ConfigWindowsResizeFromEdges = false;
|
||||
}
|
||||
|
||||
static void ImGui::ErrorCheckEndFrameSanityChecks()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user