mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Internals: Extracted some code out of the NewFrame() function.
This commit is contained in:
parent
c37f21788f
commit
f1ba217a92
51
imgui.cpp
51
imgui.cpp
@ -1089,6 +1089,7 @@ static int FindWindowFocusIndex(ImGuiWindow* window);
|
|||||||
static void UpdateMouseInputs();
|
static void UpdateMouseInputs();
|
||||||
static void UpdateMouseWheel();
|
static void UpdateMouseWheel();
|
||||||
static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
||||||
|
static void UpdateDebugToolItemPicker();
|
||||||
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
||||||
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
||||||
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
||||||
@ -3584,15 +3585,10 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|||||||
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::NewFrame()
|
static void NewFrameSanityChecks()
|
||||||
{
|
{
|
||||||
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
||||||
ImGuiTestEngineHook_PreNewFrame(&g);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Check user data
|
// 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)
|
// (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.Initialized);
|
||||||
@ -3605,7 +3601,6 @@ void ImGui::NewFrame()
|
|||||||
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.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.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
||||||
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
||||||
|
|
||||||
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
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)");
|
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)");
|
||||||
|
|
||||||
@ -3616,6 +3611,19 @@ void ImGui::NewFrame()
|
|||||||
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
|
// 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))
|
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
|
||||||
g.IO.ConfigWindowsResizeFromEdges = false;
|
g.IO.ConfigWindowsResizeFromEdges = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::NewFrame()
|
||||||
|
{
|
||||||
|
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
|
ImGuiTestEngineHook_PreNewFrame(&g);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Check and assert for various common IO and Configuration mistakes
|
||||||
|
NewFrameSanityChecks();
|
||||||
|
|
||||||
// Load settings on first frame (if not explicitly loaded manually before)
|
// Load settings on first frame (if not explicitly loaded manually before)
|
||||||
if (!g.SettingsLoaded)
|
if (!g.SettingsLoaded)
|
||||||
@ -3798,6 +3806,24 @@ void ImGui::NewFrame()
|
|||||||
ClosePopupsOverWindow(g.NavWindow, false);
|
ClosePopupsOverWindow(g.NavWindow, false);
|
||||||
|
|
||||||
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
|
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
|
||||||
|
UpdateDebugToolItemPicker();
|
||||||
|
|
||||||
|
// Create implicit/fallback window - which we will only render it if the user has added something to it.
|
||||||
|
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
||||||
|
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
|
||||||
|
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
||||||
|
Begin("Debug##Default");
|
||||||
|
g.FrameScopePushedImplicitWindow = true;
|
||||||
|
|
||||||
|
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||||
|
ImGuiTestEngineHook_PostNewFrame(&g);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
|
||||||
|
void ImGui::UpdateDebugToolItemPicker()
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
g.DebugItemPickerBreakID = 0;
|
g.DebugItemPickerBreakID = 0;
|
||||||
if (g.DebugItemPickerActive)
|
if (g.DebugItemPickerActive)
|
||||||
{
|
{
|
||||||
@ -3817,17 +3843,6 @@ void ImGui::NewFrame()
|
|||||||
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
|
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create implicit/fallback window - which we will only render it if the user has added something to it.
|
|
||||||
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
|
|
||||||
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
|
|
||||||
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
|
|
||||||
Begin("Debug##Default");
|
|
||||||
g.FrameScopePushedImplicitWindow = true;
|
|
||||||
|
|
||||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
|
||||||
ImGuiTestEngineHook_PostNewFrame(&g);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::Initialize(ImGuiContext* context)
|
void ImGui::Initialize(ImGuiContext* context)
|
||||||
|
Loading…
Reference in New Issue
Block a user