mirror of
https://github.com/ocornut/imgui.git
synced 2026-08-03 22:28:48 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_opengl3.cpp # imgui.cpp # imgui_internal.h
This commit is contained in:
62
imgui.cpp
62
imgui.cpp
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.6 WIP
|
||||
// dear imgui, v1.90.6
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@@ -438,7 +438,7 @@ CODE
|
||||
- likewise io.MousePos and GetMousePos() will use OS coordinates.
|
||||
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
|
||||
|
||||
- 2024/04/18 (1.90.6) - treeNode: Fixed a layout inconsistency when using an empty/hidden label followed by a SameLine() call. (#7505, #282)
|
||||
- 2024/04/18 (1.90.6) - TreeNode: Fixed a layout inconsistency when using an empty/hidden label followed by a SameLine() call. (#7505, #282)
|
||||
- old: TreeNode("##Hidden"); SameLine(); Text("Hello"); // <-- This was actually incorrect! BUT appeared to look ok with the default style where ItemSpacing.x == FramePadding.x * 2 (it didn't look aligned otherwise).
|
||||
- new: TreeNode("##Hidden"); SameLine(0, 0); Text("Hello"); // <-- This is correct for all styles values.
|
||||
with the fix, IF you were successfully using TreeNode("")+SameLine(); you will now have extra spacing between your TreeNode and the following item.
|
||||
@@ -6703,6 +6703,30 @@ void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags
|
||||
}
|
||||
}
|
||||
|
||||
// [EXPERIMENTAL] Called by Begin(). NextWindowData is valid at this point.
|
||||
// This is designed as a toy/test-bed for
|
||||
void ImGui::UpdateWindowSkipRefresh(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
window->SkipRefresh = false;
|
||||
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasRefreshPolicy) == 0)
|
||||
return;
|
||||
if (g.NextWindowData.RefreshFlagsVal & ImGuiWindowRefreshFlags_TryToAvoidRefresh)
|
||||
{
|
||||
// FIXME-IDLE: Tests for e.g. mouse clicks or keyboard while focused.
|
||||
if (window->Appearing) // If currently appearing
|
||||
return;
|
||||
if (window->Hidden) // If was hidden (previous frame)
|
||||
return;
|
||||
if ((g.NextWindowData.RefreshFlagsVal & ImGuiWindowRefreshFlags_RefreshOnHover) && g.HoveredWindow && window->RootWindow == g.HoveredWindow->RootWindow)
|
||||
return;
|
||||
if ((g.NextWindowData.RefreshFlagsVal & ImGuiWindowRefreshFlags_RefreshOnFocus) && g.NavWindow && window->RootWindow == g.NavWindow->RootWindow)
|
||||
return;
|
||||
window->DrawList = NULL;
|
||||
window->SkipRefresh = true;
|
||||
}
|
||||
}
|
||||
|
||||
// When a modal popup is open, newly created windows that want focus (i.e. are not popups and do not specify ImGuiWindowFlags_NoFocusOnAppearing)
|
||||
// should be positioned behind that modal window, unless the window was created inside the modal begin-stack.
|
||||
// In case of multiple stacked modals newly created window honors begin stack order and does not go below its own modal parent.
|
||||
@@ -6950,11 +6974,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
if (window->Appearing)
|
||||
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
||||
|
||||
// [EXPERIMENTAL] Skip Refresh mode
|
||||
UpdateWindowSkipRefresh(window);
|
||||
|
||||
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
|
||||
g.CurrentWindow = NULL;
|
||||
|
||||
// When reusing window again multiple times a frame, just append content (don't need to setup again)
|
||||
if (first_begin_of_the_frame)
|
||||
if (first_begin_of_the_frame && !window->SkipRefresh)
|
||||
{
|
||||
// Initialize
|
||||
const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
|
||||
@@ -7547,6 +7574,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip refresh always mark active
|
||||
if (window->SkipRefresh)
|
||||
window->Active = true;
|
||||
|
||||
// Append
|
||||
SetCurrentViewport(window, window->Viewport);
|
||||
SetCurrentWindow(window);
|
||||
@@ -7554,7 +7585,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
SetLastItemDataForWindow(window, window->TitleBarRect());
|
||||
}
|
||||
|
||||
if (!(flags & ImGuiWindowFlags_DockNodeHost))
|
||||
if (!(flags & ImGuiWindowFlags_DockNodeHost) && !window->SkipRefresh)
|
||||
PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
|
||||
|
||||
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
|
||||
@@ -7562,7 +7593,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->BeginCount++;
|
||||
|
||||
// Update visibility
|
||||
if (first_begin_of_the_frame)
|
||||
if (first_begin_of_the_frame && !window->SkipRefresh)
|
||||
{
|
||||
// When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems.
|
||||
// This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents.
|
||||
@@ -7630,6 +7661,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
if (window->SkipItems && !window->Appearing)
|
||||
IM_ASSERT(window->Appearing == false); // Please report on GitHub if this triggers: https://github.com/ocornut/imgui/issues/4177
|
||||
}
|
||||
else if (first_begin_of_the_frame)
|
||||
{
|
||||
// Skip refresh mode
|
||||
window->SkipItems = true;
|
||||
}
|
||||
|
||||
// [DEBUG] io.ConfigDebugBeginReturnValue override return value to test Begin/End and BeginChild/EndChild behaviors.
|
||||
// (The implicit fallback window is NOT automatically ended allowing it to always be able to receive commands without crashing)
|
||||
@@ -7675,10 +7711,16 @@ void ImGui::End()
|
||||
// Close anything that is open
|
||||
if (window->DC.CurrentColumns)
|
||||
EndColumns();
|
||||
if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle
|
||||
if (!(window->Flags & ImGuiWindowFlags_DockNodeHost) && !window->SkipRefresh) // Pop inner window clip rectangle
|
||||
PopClipRect();
|
||||
PopFocusScope();
|
||||
|
||||
if (window->SkipRefresh)
|
||||
{
|
||||
IM_ASSERT(window->DrawList == NULL);
|
||||
window->DrawList = &window->DrawListInst;
|
||||
}
|
||||
|
||||
// Stop logging
|
||||
if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
|
||||
LogFinish();
|
||||
@@ -8426,6 +8468,14 @@ void ImGui::SetNextWindowClass(const ImGuiWindowClass* window_class)
|
||||
g.NextWindowData.WindowClass = *window_class;
|
||||
}
|
||||
|
||||
// This is experimental and meant to be a toy for exploring a future/wider range of features.
|
||||
void ImGui::SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasRefreshPolicy;
|
||||
g.NextWindowData.RefreshFlagsVal = flags;
|
||||
}
|
||||
|
||||
ImDrawList* ImGui::GetWindowDrawList()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
|
||||
Reference in New Issue
Block a user