|
|
@@ -379,6 +379,9 @@ CODE
|
|
|
- 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency.
|
|
|
- 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
|
|
|
- 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
|
|
|
+ - 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.).
|
|
|
+ old binding will still work as is, however prefer using the separated bindings as they will be updated to be multi-viewport conformant.
|
|
|
+ when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call.
|
|
|
- 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
|
|
|
- 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details.
|
|
|
- 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
|
|
|
@@ -2534,6 +2537,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
|
|
|
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -2973,7 +2977,7 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
|
|
|
|
|
|
// Handle mouse moving window
|
|
|
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
|
|
|
-void ImGui::UpdateMouseMovingWindow()
|
|
|
+void ImGui::UpdateMouseMovingWindowNewFrame()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
if (g.MovingWindow != NULL)
|
|
|
@@ -3011,6 +3015,56 @@ void ImGui::UpdateMouseMovingWindow()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// Initiate moving window, handle left-click and right-click focus
|
|
|
+void ImGui::UpdateMouseMovingWindowEndFrame()
|
|
|
+{
|
|
|
+ // Initiate moving window
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ if (g.ActiveId != 0 || g.HoveredId != 0)
|
|
|
+ return;
|
|
|
+
|
|
|
+ // Unless we just made a window/popup appear
|
|
|
+ if (g.NavWindow && g.NavWindow->Appearing)
|
|
|
+ return;
|
|
|
+
|
|
|
+ // Click to focus window and start moving (after we're done with all our widgets)
|
|
|
+ if (g.IO.MouseClicked[0])
|
|
|
+ {
|
|
|
+ if (g.HoveredRootWindow != NULL)
|
|
|
+ {
|
|
|
+ StartMouseMovingWindow(g.HoveredWindow);
|
|
|
+ if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar))
|
|
|
+ if (!g.HoveredRootWindow->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
|
|
+ g.MovingWindow = NULL;
|
|
|
+ }
|
|
|
+ else if (g.NavWindow != NULL && GetFrontMostPopupModal() == NULL)
|
|
|
+ {
|
|
|
+ FocusWindow(NULL); // Clicking on void disable focus
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // With right mouse button we close popups without changing focus
|
|
|
+ // (The left mouse button path calls FocusWindow which will lead NewFrame->ClosePopupsOverWindow to trigger)
|
|
|
+ if (g.IO.MouseClicked[1])
|
|
|
+ {
|
|
|
+ // Find the top-most window between HoveredWindow and the front most Modal Window.
|
|
|
+ // This is where we can trim the popup stack.
|
|
|
+ ImGuiWindow* modal = GetFrontMostPopupModal();
|
|
|
+ bool hovered_window_above_modal = false;
|
|
|
+ if (modal == NULL)
|
|
|
+ hovered_window_above_modal = true;
|
|
|
+ for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--)
|
|
|
+ {
|
|
|
+ ImGuiWindow* window = g.Windows[i];
|
|
|
+ if (window == modal)
|
|
|
+ break;
|
|
|
+ if (window == g.HoveredWindow)
|
|
|
+ hovered_window_above_modal = true;
|
|
|
+ }
|
|
|
+ ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
static bool IsWindowActiveAndVisible(ImGuiWindow* window)
|
|
|
{
|
|
|
return (window->Active) && (!window->Hidden);
|
|
|
@@ -3302,7 +3356,7 @@ void ImGui::NewFrame()
|
|
|
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
|
|
|
|
|
|
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
|
|
- UpdateMouseMovingWindow();
|
|
|
+ UpdateMouseMovingWindowNewFrame();
|
|
|
UpdateHoveredWindowAndCaptureFlags();
|
|
|
|
|
|
// Background darkening/whitening
|
|
|
@@ -3353,6 +3407,7 @@ void ImGui::NewFrame()
|
|
|
// 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();
|
|
|
@@ -3584,9 +3639,6 @@ void ImGui::EndFrame()
|
|
|
return;
|
|
|
IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");
|
|
|
|
|
|
- g.FrameScopeActive = false;
|
|
|
- g.FrameCountEnded = g.FrameCount;
|
|
|
-
|
|
|
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
|
|
if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)
|
|
|
{
|
|
|
@@ -3611,11 +3663,12 @@ void ImGui::EndFrame()
|
|
|
}
|
|
|
|
|
|
// Hide implicit/fallback "Debug" window if it hasn't been used
|
|
|
+ g.FrameScopePushedImplicitWindow = false;
|
|
|
if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
|
|
|
g.CurrentWindow->Active = false;
|
|
|
End();
|
|
|
|
|
|
- // Show CTRL+TAB list
|
|
|
+ // Show CTRL+TAB list window
|
|
|
if (g.NavWindowingTarget)
|
|
|
NavUpdateWindowingList();
|
|
|
|
|
|
@@ -3636,49 +3689,12 @@ void ImGui::EndFrame()
|
|
|
g.DragDropWithinSourceOrTarget = false;
|
|
|
}
|
|
|
|
|
|
- // Initiate moving window
|
|
|
- if (g.ActiveId == 0 && g.HoveredId == 0)
|
|
|
- {
|
|
|
- if (!g.NavWindow || !g.NavWindow->Appearing) // Unless we just made a window/popup appear
|
|
|
- {
|
|
|
- // Click to focus window and start moving (after we're done with all our widgets)
|
|
|
- if (g.IO.MouseClicked[0])
|
|
|
- {
|
|
|
- if (g.HoveredRootWindow != NULL)
|
|
|
- {
|
|
|
- StartMouseMovingWindow(g.HoveredWindow);
|
|
|
- if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar))
|
|
|
- if (!g.HoveredRootWindow->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
|
|
- g.MovingWindow = NULL;
|
|
|
- }
|
|
|
- else if (g.NavWindow != NULL && GetFrontMostPopupModal() == NULL)
|
|
|
- {
|
|
|
- FocusWindow(NULL); // Clicking on void disable focus
|
|
|
- }
|
|
|
- }
|
|
|
+ // End frame
|
|
|
+ g.FrameScopeActive = false;
|
|
|
+ g.FrameCountEnded = g.FrameCount;
|
|
|
|
|
|
- // With right mouse button we close popups without changing focus
|
|
|
- // (The left mouse button path calls FocusWindow which will lead NewFrame->ClosePopupsOverWindow to trigger)
|
|
|
- if (g.IO.MouseClicked[1])
|
|
|
- {
|
|
|
- // Find the top-most window between HoveredWindow and the front most Modal Window.
|
|
|
- // This is where we can trim the popup stack.
|
|
|
- ImGuiWindow* modal = GetFrontMostPopupModal();
|
|
|
- bool hovered_window_above_modal = false;
|
|
|
- if (modal == NULL)
|
|
|
- hovered_window_above_modal = true;
|
|
|
- for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--)
|
|
|
- {
|
|
|
- ImGuiWindow* window = g.Windows[i];
|
|
|
- if (window == modal)
|
|
|
- break;
|
|
|
- if (window == g.HoveredWindow)
|
|
|
- hovered_window_above_modal = true;
|
|
|
- }
|
|
|
- ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // Initiate moving window + handle left-click and right-click focus
|
|
|
+ UpdateMouseMovingWindowEndFrame();
|
|
|
|
|
|
// Sort the window list so that all child windows are after their parent
|
|
|
// We cannot do that on FocusWindow() because childs may not exist yet
|
|
|
@@ -4902,6 +4918,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
// Position child window
|
|
|
if (flags & ImGuiWindowFlags_ChildWindow)
|
|
|
{
|
|
|
+ IM_ASSERT(parent_window->Active);
|
|
|
window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size;
|
|
|
parent_window->DC.ChildWindows.push_back(window);
|
|
|
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip)
|
|
|
@@ -5287,11 +5304,12 @@ void ImGui::End()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
- if (g.CurrentWindowStack.Size <= 1 && g.FrameScopeActive)
|
|
|
+ if (g.CurrentWindowStack.Size <= 1 && g.FrameScopePushedImplicitWindow)
|
|
|
{
|
|
|
IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
|
|
|
return; // FIXME-ERRORHANDLING
|
|
|
}
|
|
|
+ IM_ASSERT(g.CurrentWindowStack.Size > 0);
|
|
|
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
|
|
@@ -5368,7 +5386,7 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|
|
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
|
|
g.NavIdIsAlive = false;
|
|
|
g.NavLayer = ImGuiNavLayer_Main;
|
|
|
- //printf("[%05d] FocusWindow(\"%s\")\n", g.FrameCount, window ? window->Name : NULL);
|
|
|
+ //IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", g.FrameCount, window ? window->Name : NULL);
|
|
|
}
|
|
|
|
|
|
// Passing NULL allow to disable keyboard focus
|
|
|
@@ -6545,7 +6563,7 @@ void ImGui::OpenPopupEx(ImGuiID id)
|
|
|
popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
|
|
|
popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
|
|
|
|
|
|
- //printf("[%05d] OpenPopupEx(0x%08X)\n", g.FrameCount, id);
|
|
|
+ //IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id);
|
|
|
if (g.OpenPopupStack.Size < current_stack_size + 1)
|
|
|
{
|
|
|
g.OpenPopupStack.push_back(popup_ref);
|
|
|
@@ -7335,7 +7353,7 @@ static void ImGui::NavUpdate()
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
g.IO.WantSetMousePos = false;
|
|
|
#if 0
|
|
|
- if (g.NavScoringCount > 0) printf("[%05d] NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
|
|
|
+ if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
|
|
|
#endif
|
|
|
|
|
|
// Set input source as Gamepad when buttons are pressed before we map Keyboard (some features differs when used with Gamepad vs Keyboard)
|