update Dear ImGui to 1.91.4
This commit is contained in:
parent
623fce4f01
commit
2a7eac93f8
41 changed files with 1145 additions and 791 deletions
337
extern/imgui_patched/imgui.cpp
vendored
337
extern/imgui_patched/imgui.cpp
vendored
|
|
@ -1,4 +1,4 @@
|
|||
// dear imgui, v1.91.3
|
||||
// dear imgui, v1.91.4
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
|
|
@ -184,8 +184,8 @@ CODE
|
|||
- Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + run examples/libs/synergy/uSynergy.c (on your console/tablet/phone app)
|
||||
in order to share your PC mouse/keyboard.
|
||||
- See https://github.com/ocornut/imgui/wiki/Useful-Extensions#remoting for other remoting solutions.
|
||||
- On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag.
|
||||
Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs Dear ImGui to move your mouse cursor along with navigation movements.
|
||||
- On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the io.ConfigNavMoveSetMousePos flag.
|
||||
Enabling io.ConfigNavMoveSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs Dear ImGui to move your mouse cursor along with navigation movements.
|
||||
When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved.
|
||||
When that happens your backend NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the backends in examples/ do that.
|
||||
(If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, Dear ImGui will misbehave as it will see your mouse moving back & forth!)
|
||||
|
|
@ -438,6 +438,18 @@ 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/10/18 (1.91.4) - renamed ImGuiCol_NavHighlight to ImGuiCol_NavCursor (for consistency with newly exposed and reworked features). Kept inline redirection enum (will obsolete).
|
||||
- 2024/10/14 (1.91.4) - moved ImGuiConfigFlags_NavEnableSetMousePos to standalone io.ConfigNavMoveSetMousePos bool.
|
||||
moved ImGuiConfigFlags_NavNoCaptureKeyboard to standalone io.ConfigNavCaptureKeyboard bool (note the inverted value!).
|
||||
kept legacy names (will obsolete) + code that copies settings once the first time. Dynamically changing the old value won't work. Switch to using the new value!
|
||||
- 2024/10/10 (1.91.4) - the typedef for ImTextureID now defaults to ImU64 instead of void*. (#1641)
|
||||
this removes the requirement to redefine it for backends which are e.g. storing descriptor sets or other 64-bits structures when building on 32-bits archs. It therefore simplify various building scripts/helpers.
|
||||
you may have compile-time issues if you were casting to 'void*' instead of 'ImTextureID' when passing your types to functions taking ImTextureID values, e.g. ImGui::Image().
|
||||
in doubt it is almost always better to do an intermediate intptr_t cast, since it allows casting any pointer/integer type without warning:
|
||||
- May warn: ImGui::Image((void*)MyTextureData, ...);
|
||||
- May warn: ImGui::Image((void*)(intptr_t)MyTextureData, ...);
|
||||
- Won't warn: ImGui::Image((ImTextureID)(intptr_t)MyTextureData), ...);
|
||||
- note that you can always define ImTextureID to be your own high-level structures (with dedicated constructors) if you like.
|
||||
- 2024/10/03 (1.91.3) - drags: treat v_min==v_max as a valid clamping range when != 0.0f. Zero is a still special value due to legacy reasons, unless using ImGuiSliderFlags_ClampZeroRange. (#7968, #3361, #76)
|
||||
- drags: extended behavior of ImGuiSliderFlags_AlwaysClamp to include _ClampZeroRange. It considers v_min==v_max==0.0f as a valid clamping range (aka edits not allowed).
|
||||
although unlikely, it you wish to only clamp on text input but want v_min==v_max==0.0f to mean unclamped drags, you can use _ClampOnInput instead of _AlwaysClamp. (#7968, #3361, #76)
|
||||
|
|
@ -1204,6 +1216,7 @@ static bool NavScoreItem(ImGuiNavItemData* result);
|
|||
static void NavApplyItemToResult(ImGuiNavItemData* result);
|
||||
static void NavProcessItem();
|
||||
static void NavProcessItemForTabbingRequest(ImGuiID id, ImGuiItemFlags item_flags, ImGuiNavMoveFlags move_flags);
|
||||
static ImGuiInputSource NavCalcPreferredRefPosSource();
|
||||
static ImVec2 NavCalcPreferredRefPos();
|
||||
static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window);
|
||||
static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window);
|
||||
|
|
@ -1420,6 +1433,15 @@ ImGuiIO::ImGuiIO()
|
|||
FontAllowUserScaling = false;
|
||||
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
|
||||
|
||||
// Keyboard/Gamepad Navigation options
|
||||
ConfigNavSwapGamepadButtons = false;
|
||||
ConfigNavMoveSetMousePos = false;
|
||||
ConfigNavCaptureKeyboard = true;
|
||||
ConfigNavEscapeClearFocusItem = true;
|
||||
ConfigNavEscapeClearFocusWindow = false;
|
||||
ConfigNavCursorVisibleAuto = true;
|
||||
ConfigNavCursorVisibleAlways = false;
|
||||
|
||||
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
|
||||
ConfigDockingNoSplit = false;
|
||||
ConfigDockingWithShift = false;
|
||||
|
|
@ -1447,7 +1469,6 @@ ImGuiIO::ImGuiIO()
|
|||
#else
|
||||
ConfigMacOSXBehaviors = false;
|
||||
#endif
|
||||
ConfigNavSwapGamepadButtons = false;
|
||||
ConfigInputTrickleEventQueue = true;
|
||||
ConfigInputTextCursorBlink = true;
|
||||
ConfigInputTextEnterKeepActive = false;
|
||||
|
|
@ -3558,7 +3579,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
|||
case ImGuiCol_TextLink: return "TextLink";
|
||||
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
||||
case ImGuiCol_DragDropTarget: return "DragDropTarget";
|
||||
case ImGuiCol_NavHighlight: return "NavHighlight";
|
||||
case ImGuiCol_NavCursor: return "NavCursor";
|
||||
case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
|
||||
case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg";
|
||||
case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg";
|
||||
|
|
@ -3847,24 +3868,26 @@ void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
|
|||
}
|
||||
}
|
||||
|
||||
void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags)
|
||||
void ImGui::RenderNavCursor(const ImRect& bb, ImGuiID id, ImGuiNavRenderCursorFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (id != g.NavId)
|
||||
return;
|
||||
if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw))
|
||||
if (!g.NavCursorVisible && !(flags & ImGuiNavRenderCursorFlags_AlwaysDraw))
|
||||
return;
|
||||
if (id == g.LastItemData.ID && (g.LastItemData.ItemFlags & ImGuiItemFlags_NoNav))
|
||||
return;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (window->DC.NavHideHighlightOneFrame)
|
||||
return;
|
||||
|
||||
float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding;
|
||||
float rounding = (flags & ImGuiNavRenderCursorFlags_NoRounding) ? 0.0f : g.Style.FrameRounding;
|
||||
ImRect display_rect = bb;
|
||||
display_rect.ClipWith(window->ClipRect);
|
||||
const float thickness = 2.0f;
|
||||
if (flags & ImGuiNavHighlightFlags_Compact)
|
||||
if (flags & ImGuiNavRenderCursorFlags_Compact)
|
||||
{
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, 0, thickness);
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavCursor), rounding, 0, thickness);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3873,7 +3896,7 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
|
|||
bool fully_visible = window->ClipRect.Contains(display_rect);
|
||||
if (!fully_visible)
|
||||
window->DrawList->PushClipRect(display_rect.Min, display_rect.Max);
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, 0, thickness);
|
||||
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavCursor), rounding, 0, thickness);
|
||||
if (!fully_visible)
|
||||
window->DrawList->PopClipRect();
|
||||
}
|
||||
|
|
@ -4058,8 +4081,13 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|||
ViewportCreatedCount = PlatformWindowsCreatedCount = 0;
|
||||
ViewportFocusedStampCount = 0;
|
||||
|
||||
NavCursorVisible = false;
|
||||
NavHighlightItemUnderNav = false;
|
||||
NavMousePosDirty = false;
|
||||
NavIdIsAlive = false;
|
||||
NavId = 0;
|
||||
NavWindow = NULL;
|
||||
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
||||
NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
|
||||
NavLayer = ImGuiNavLayer_Main;
|
||||
NavNextActivateId = 0;
|
||||
NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
|
||||
|
|
@ -4067,10 +4095,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|||
NavHighlightActivatedTimer = 0.0f;
|
||||
NavInputSource = ImGuiInputSource_Keyboard;
|
||||
NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid;
|
||||
NavIdIsAlive = false;
|
||||
NavMousePosDirty = false;
|
||||
NavDisableHighlight = true;
|
||||
NavDisableMouseHover = false;
|
||||
NavCursorHideFrames = 0;
|
||||
|
||||
NavAnyRequest = false;
|
||||
NavInitRequest = false;
|
||||
|
|
@ -4148,7 +4173,6 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|||
DragSpeedDefaultRatio = 1.0f / 100.0f;
|
||||
DisabledAlphaBackup = 0.0f;
|
||||
DisabledStackSize = 0;
|
||||
LockMarkEdited = 0;
|
||||
TooltipOverrideCount = 0;
|
||||
TooltipPreviousWindow = NULL;
|
||||
|
||||
|
|
@ -4541,7 +4565,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|||
g.ActiveIdIsAlive = id;
|
||||
g.ActiveIdSource = (g.NavActivateId == id || g.NavJustMovedToId == id) ? g.NavInputSource : ImGuiInputSource_Mouse;
|
||||
// TODO: check whether this works
|
||||
if (g.LastItemData.InFlags & ImGuiItemFlags_NoInertialScroll) {
|
||||
if (g.LastItemData.ItemFlags & ImGuiItemFlags_NoInertialScroll) {
|
||||
g.InertialScrollInhibited=true;
|
||||
}
|
||||
IM_ASSERT(g.ActiveIdSource != ImGuiInputSource_None);
|
||||
|
|
@ -4575,10 +4599,10 @@ ImGuiID ImGui::GetHoveredID()
|
|||
|
||||
void ImGui::MarkItemEdited(ImGuiID id)
|
||||
{
|
||||
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
|
||||
// This marking is to be able to provide info for IsItemDeactivatedAfterEdit().
|
||||
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need to fill the data.
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.LockMarkEdited > 0)
|
||||
if (g.LastItemData.ItemFlags & ImGuiItemFlags_NoMarkEdited)
|
||||
return;
|
||||
if (g.ActiveId == id || g.ActiveId == 0)
|
||||
{
|
||||
|
|
@ -4650,16 +4674,16 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
IM_ASSERT((flags & ~ImGuiHoveredFlags_AllowedMaskForIsItemHovered) == 0 && "Invalid flags for IsItemHovered()!");
|
||||
IM_ASSERT_USER_ERROR((flags & ~ImGuiHoveredFlags_AllowedMaskForIsItemHovered) == 0, "Invalid flags for IsItemHovered()!");
|
||||
|
||||
if (g.NavDisableMouseHover && !g.NavDisableHighlight && !(flags & ImGuiHoveredFlags_NoNavOverride))
|
||||
if (g.NavHighlightItemUnderNav && g.NavCursorVisible && !(flags & ImGuiHoveredFlags_NoNavOverride))
|
||||
{
|
||||
if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
return false;
|
||||
if (!IsItemFocused())
|
||||
return false;
|
||||
if (window->InertialScroll)
|
||||
return false;
|
||||
if ((g.LastItemData.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
return false;
|
||||
|
||||
if (flags & ImGuiHoveredFlags_ForTooltip)
|
||||
flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipNav);
|
||||
|
|
@ -4674,8 +4698,6 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
if (flags & ImGuiHoveredFlags_ForTooltip)
|
||||
flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipMouse);
|
||||
|
||||
IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy | ImGuiHoveredFlags_DockHierarchy)) == 0); // Flags not supported by this function
|
||||
|
||||
// Done with rectangle culling so we can perform heavier checks now
|
||||
// Test if we are hovering the right window (our window could be behind another window)
|
||||
// [2021/03/02] Reworked / reverted the revert, finally. Note we want e.g. BeginGroup/ItemAdd/EndGroup to work as well. (#3851)
|
||||
|
|
@ -4695,11 +4717,11 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
|
||||
// Test if interactions on this window are blocked by an active popup or modal.
|
||||
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
||||
if (!IsWindowContentHoverable(window, flags) && !(g.LastItemData.InFlags & ImGuiItemFlags_NoWindowHoverableCheck))
|
||||
if (!IsWindowContentHoverable(window, flags) && !(g.LastItemData.ItemFlags & ImGuiItemFlags_NoWindowHoverableCheck))
|
||||
return false;
|
||||
|
||||
// Test if the item is disabled
|
||||
if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
if ((g.LastItemData.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
||||
return false;
|
||||
|
||||
// Test for inertial scroll
|
||||
|
|
@ -4713,7 +4735,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
return false;
|
||||
|
||||
// Test if using AllowOverlap and overlapped
|
||||
if ((g.LastItemData.InFlags & ImGuiItemFlags_AllowOverlap) && id != 0)
|
||||
if ((g.LastItemData.ItemFlags & ImGuiItemFlags_AllowOverlap) && id != 0)
|
||||
if ((flags & ImGuiHoveredFlags_AllowWhenOverlappedByItem) == 0)
|
||||
if (g.HoveredIdPreviousFrame != g.LastItemData.ID)
|
||||
return false;
|
||||
|
|
@ -4746,7 +4768,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|||
// (this does not rely on LastItemData it can be called from a ButtonBehavior() call not following an ItemAdd() call)
|
||||
// FIXME-LEGACY: the 'ImGuiItemFlags item_flags' parameter was added on 2023-06-28.
|
||||
// If you used this in your legacy/custom widgets code:
|
||||
// - Commonly: if your ItemHoverable() call comes after an ItemAdd() call: pass 'item_flags = g.LastItemData.InFlags'.
|
||||
// - Commonly: if your ItemHoverable() call comes after an ItemAdd() call: pass 'item_flags = g.LastItemData.ItemFlags'.
|
||||
// - Rare: otherwise you may pass 'item_flags = 0' (ImGuiItemFlags_None) unless you want to benefit from special behavior handled by ItemHoverable.
|
||||
bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flags)
|
||||
{
|
||||
|
|
@ -4832,7 +4854,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|||
}
|
||||
#endif
|
||||
|
||||
if (g.NavDisableMouseHover)
|
||||
if (g.NavHighlightItemUnderNav && (item_flags & ImGuiItemFlags_NoNavDisableMouseHover) == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -4857,7 +4879,7 @@ void ImGui::SetLastItemData(ImGuiID item_id, ImGuiItemFlags in_flags, ImGuiItemS
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.LastItemData.ID = item_id;
|
||||
g.LastItemData.InFlags = in_flags;
|
||||
g.LastItemData.ItemFlags = in_flags;
|
||||
g.LastItemData.StatusFlags = item_flags;
|
||||
g.LastItemData.Rect = g.LastItemData.NavRect = item_rect;
|
||||
}
|
||||
|
|
@ -5033,7 +5055,8 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
|
|||
ImGuiContext& g = *GImGui;
|
||||
FocusWindow(window);
|
||||
SetActiveID(window->MoveId, window);
|
||||
g.NavDisableHighlight = true;
|
||||
if (g.IO.ConfigNavCursorVisibleAuto)
|
||||
g.NavCursorVisible = false;
|
||||
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindowDockTree->Pos;
|
||||
g.ActiveIdNoClearOnFocusLoss = true;
|
||||
SetActiveIdUsingAllKeyboardKeys();
|
||||
|
|
@ -5140,12 +5163,13 @@ void ImGui::UpdateMouseMovingWindowNewFrame()
|
|||
}
|
||||
}
|
||||
|
||||
// Initiate moving window when clicking on empty space or title bar.
|
||||
// Initiate focusing and moving window when clicking on empty space or title bar.
|
||||
// Initiate focusing window when clicking on a disabled item.
|
||||
// Handle left-click and right-click focus.
|
||||
void ImGui::UpdateMouseMovingWindowEndFrame()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.ActiveId != 0 || g.HoveredId != 0)
|
||||
if (g.ActiveId != 0 || (g.HoveredId != 0 && !g.HoveredIdIsDisabled))
|
||||
return;
|
||||
|
||||
// Unless we just made a window/popup appear
|
||||
|
|
@ -5171,7 +5195,8 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|||
if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
|
||||
g.MovingWindow = NULL;
|
||||
|
||||
// Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already)
|
||||
// Cancel moving if clicked over an item which was disabled or inhibited by popups
|
||||
// (when g.HoveredIdIsDisabled == true && g.HoveredId == 0 we are inhibited by popups, when g.HoveredIdIsDisabled == true && g.HoveredId != 0 we are over a disabled item)0 already)
|
||||
if (g.HoveredIdIsDisabled)
|
||||
g.MovingWindow = NULL;
|
||||
}
|
||||
|
|
@ -5185,7 +5210,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|||
// With right mouse button we close popups without changing focus based on where the mouse is aimed
|
||||
// Instead, focus will be restored to the window under the bottom-most closed popup.
|
||||
// (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
|
||||
if (g.IO.MouseClicked[1])
|
||||
if (g.IO.MouseClicked[1] && g.HoveredId == 0)
|
||||
{
|
||||
// Find the top-most window between HoveredWindow and the top-most Modal Window.
|
||||
// This is where we can trim the popup stack.
|
||||
|
|
@ -5294,9 +5319,14 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
|||
}
|
||||
|
||||
// Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to Dear ImGui only, false = dispatch keyboard info to Dear ImGui + underlying app)
|
||||
io.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
|
||||
if (io.NavActive && (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
|
||||
io.WantCaptureKeyboard = true;
|
||||
io.WantCaptureKeyboard = false;
|
||||
if ((io.ConfigFlags & ImGuiConfigFlags_NoKeyboard) == 0)
|
||||
{
|
||||
if ((g.ActiveId != 0) || (modal_window != NULL))
|
||||
io.WantCaptureKeyboard = true;
|
||||
else if (io.NavActive && (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && io.ConfigNavCaptureKeyboard)
|
||||
io.WantCaptureKeyboard = true;
|
||||
}
|
||||
if (g.WantCaptureKeyboardNextFrame != -1) // Manual override
|
||||
io.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
|
||||
|
||||
|
|
@ -5485,7 +5515,7 @@ void ImGui::NewFrame()
|
|||
//IM_ASSERT(g.IO.KeyAlt == IsKeyDown(ImGuiKey_LeftAlt) || IsKeyDown(ImGuiKey_RightAlt));
|
||||
//IM_ASSERT(g.IO.KeySuper == IsKeyDown(ImGuiKey_LeftSuper) || IsKeyDown(ImGuiKey_RightSuper));
|
||||
|
||||
// Update gamepad/keyboard navigation
|
||||
// Update keyboard/gamepad navigation
|
||||
NavUpdate();
|
||||
|
||||
// Update mouse input state
|
||||
|
|
@ -6220,7 +6250,7 @@ bool ImGui::IsAnyItemActive()
|
|||
bool ImGui::IsAnyItemFocused()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.NavId != 0 && !g.NavDisableHighlight;
|
||||
return g.NavId != 0 && g.NavCursorVisible;
|
||||
}
|
||||
|
||||
bool ImGui::IsItemVisible()
|
||||
|
|
@ -6452,11 +6482,11 @@ void ImGui::EndChild()
|
|||
if ((child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavWindowHasScrollY) && !nav_flattened)
|
||||
{
|
||||
ItemAdd(bb, child_window->ChildId);
|
||||
RenderNavHighlight(bb, child_window->ChildId);
|
||||
RenderNavCursor(bb, child_window->ChildId);
|
||||
|
||||
// When browsing a window that has no activable items (scroll only) we keep a highlight on the child (pass g.NavId to trick into always displaying)
|
||||
if (child_window->DC.NavLayersActiveMask == 0 && child_window == g.NavWindow)
|
||||
RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_Compact);
|
||||
RenderNavCursor(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavRenderCursorFlags_Compact);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -7016,7 +7046,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
|||
g.NavWindowingAccumDeltaSize += nav_resize_dir * resize_step;
|
||||
g.NavWindowingAccumDeltaSize = ImMax(g.NavWindowingAccumDeltaSize, clamp_rect.Min - window->Pos - window->Size); // We need Pos+Size >= clmap_rect.Min, so Size >= clmap_rect.Min - Pos, so size_delta >= clmap_rect.Min - window->Pos - window->Size
|
||||
g.NavWindowingToggleLayer = false;
|
||||
g.NavDisableMouseHover = true;
|
||||
g.NavHighlightItemUnderNav = true;
|
||||
resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive);
|
||||
ImVec2 accum_floored = ImTrunc(g.NavWindowingAccumDeltaSize);
|
||||
if (accum_floored.x != 0.0f || accum_floored.y != 0.0f)
|
||||
|
|
@ -7122,7 +7152,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
|||
// Title bar only
|
||||
const float backup_border_size = style.FrameBorderSize;
|
||||
g.Style.FrameBorderSize = window->WindowBorderSize;
|
||||
ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed);
|
||||
ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && g.NavCursorVisible) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed);
|
||||
if (window->ViewportOwned)
|
||||
title_bar_col |= IM_COL32_A_MASK; // No alpha (we don't support is_docking_transparent_payload here because simpler and less meaningful, but could with a bit of code shuffle/reuse)
|
||||
RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding);
|
||||
|
|
@ -8624,7 +8654,7 @@ void ImGui::FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags)
|
|||
if (g.NavWindow != window)
|
||||
{
|
||||
SetNavWindow(window);
|
||||
if (window && g.NavDisableMouseHover)
|
||||
if (window && g.NavHighlightItemUnderNav)
|
||||
g.NavMousePosDirty = true;
|
||||
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
|
||||
g.NavLayer = ImGuiNavLayer_Main;
|
||||
|
|
@ -8961,9 +8991,9 @@ bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_b
|
|||
// Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details.
|
||||
bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
||||
{
|
||||
IM_ASSERT((flags & ~ImGuiHoveredFlags_AllowedMaskForIsWindowHovered) == 0 && "Invalid flags for IsWindowHovered()!");
|
||||
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT_USER_ERROR((flags & ~ImGuiHoveredFlags_AllowedMaskForIsWindowHovered) == 0, "Invalid flags for IsWindowHovered()!");
|
||||
|
||||
ImGuiWindow* ref_window = g.HoveredWindow;
|
||||
ImGuiWindow* cur_window = g.CurrentWindow;
|
||||
if (ref_window == NULL)
|
||||
|
|
@ -9421,7 +9451,7 @@ void ImGui::FocusItem()
|
|||
return;
|
||||
}
|
||||
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSetNavHighlight | ImGuiNavMoveFlags_NoSelect;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSetNavCursorVisible | ImGuiNavMoveFlags_NoSelect;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
SetNavWindow(window);
|
||||
NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_Up, move_flags, scroll_flags);
|
||||
|
|
@ -9456,7 +9486,7 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
|||
|
||||
SetNavWindow(window);
|
||||
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi | ImGuiNavMoveFlags_NoSetNavCursorVisible;
|
||||
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
||||
NavMoveRequestSubmit(ImGuiDir_None, offset < 0 ? ImGuiDir_Up : ImGuiDir_Down, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
||||
if (offset == -1)
|
||||
|
|
@ -10643,9 +10673,9 @@ static void ImGui::UpdateMouseInputs()
|
|||
g.MouseStationaryTimer = mouse_stationary ? (g.MouseStationaryTimer + io.DeltaTime) : 0.0f;
|
||||
//IMGUI_DEBUG_LOG("%.4f\n", g.MouseStationaryTimer);
|
||||
|
||||
// If mouse moved we re-enable mouse hovering in case it was disabled by gamepad/keyboard. In theory should use a >0.0f threshold but would need to reset in everywhere we set this to true.
|
||||
// If mouse moved we re-enable mouse hovering in case it was disabled by keyboard/gamepad. In theory should use a >0.0f threshold but would need to reset in everywhere we set this to true.
|
||||
if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)
|
||||
g.NavDisableMouseHover = false;
|
||||
g.NavHighlightItemUnderNav = false;
|
||||
|
||||
// Update mouse speed
|
||||
if (ImFabs(io.MouseDelta.x)>ImFabs(io.MouseDeltaPrev.x)) {
|
||||
|
|
@ -10698,9 +10728,9 @@ static void ImGui::UpdateMouseInputs()
|
|||
// We provide io.MouseDoubleClicked[] as a legacy service
|
||||
io.MouseDoubleClicked[i] = (io.MouseClickedCount[i] == 2);
|
||||
|
||||
// Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation
|
||||
// Clicking any mouse button reactivate mouse hovering which may have been deactivated by keyboard/gamepad navigation
|
||||
if (io.MouseClicked[i])
|
||||
g.NavDisableMouseHover = false;
|
||||
g.NavHighlightItemUnderNav = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -11172,7 +11202,7 @@ bool ImGui::IsKeyChordPressed(ImGuiKeyChord key_chord, ImGuiInputFlags flags, Im
|
|||
void ImGui::SetNextItemShortcut(ImGuiKeyChord key_chord, ImGuiInputFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasShortcut;
|
||||
g.NextItemData.HasFlags |= ImGuiNextItemDataFlags_HasShortcut;
|
||||
g.NextItemData.Shortcut = key_chord;
|
||||
g.NextItemData.ShortcutFlags = flags;
|
||||
}
|
||||
|
|
@ -11184,7 +11214,7 @@ void ImGui::ItemHandleShortcut(ImGuiID id)
|
|||
ImGuiInputFlags flags = g.NextItemData.ShortcutFlags;
|
||||
IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetNextItemShortcut) == 0); // Passing flags not supported by SetNextItemShortcut()!
|
||||
|
||||
if (g.LastItemData.InFlags & ImGuiItemFlags_Disabled)
|
||||
if (g.LastItemData.ItemFlags & ImGuiItemFlags_Disabled)
|
||||
return;
|
||||
if (flags & ImGuiInputFlags_Tooltip)
|
||||
{
|
||||
|
|
@ -11357,8 +11387,20 @@ static void ImGui::ErrorCheckNewFrameSanityChecks()
|
|||
if (g.IO.ConfigErrorRecovery)
|
||||
IM_ASSERT(g.IO.ConfigErrorRecoveryEnableAssert || g.IO.ConfigErrorRecoveryEnableDebugLog || g.IO.ConfigErrorRecoveryEnableTooltip || g.ErrorCallback != NULL);
|
||||
|
||||
// Remap legacy clipboard handlers (OBSOLETED in 1.91.1, August 2024)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
// Remap legacy names
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos)
|
||||
{
|
||||
g.IO.ConfigNavMoveSetMousePos = true;
|
||||
g.IO.ConfigFlags &= ~ImGuiConfigFlags_NavEnableSetMousePos;
|
||||
}
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard)
|
||||
{
|
||||
g.IO.ConfigNavCaptureKeyboard = false;
|
||||
g.IO.ConfigFlags &= ~ImGuiConfigFlags_NavNoCaptureKeyboard;
|
||||
}
|
||||
|
||||
// Remap legacy clipboard handlers (OBSOLETED in 1.91.1, August 2024)
|
||||
if (g.IO.GetClipboardTextFn != NULL && (g.PlatformIO.Platform_GetClipboardTextFn == NULL || g.PlatformIO.Platform_GetClipboardTextFn == Platform_GetClipboardTextFn_DefaultImpl))
|
||||
g.PlatformIO.Platform_GetClipboardTextFn = [](ImGuiContext* ctx) { return ctx->IO.GetClipboardTextFn(ctx->IO.ClipboardUserData); };
|
||||
if (g.IO.SetClipboardTextFn != NULL && (g.PlatformIO.Platform_SetClipboardTextFn == NULL || g.PlatformIO.Platform_SetClipboardTextFn == Platform_SetClipboardTextFn_DefaultImpl))
|
||||
|
|
@ -11703,7 +11745,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|||
g.LastItemData.ID = id;
|
||||
g.LastItemData.Rect = bb;
|
||||
g.LastItemData.NavRect = nav_bb_arg ? *nav_bb_arg : bb;
|
||||
g.LastItemData.InFlags = g.CurrentItemFlags | g.NextItemData.ItemFlags | extra_flags;
|
||||
g.LastItemData.ItemFlags = g.CurrentItemFlags | g.NextItemData.ItemFlags | extra_flags;
|
||||
g.LastItemData.StatusFlags = ImGuiItemStatusFlags_None;
|
||||
// Note: we don't copy 'g.NextItemData.SelectionUserData' to an hypothetical g.LastItemData.SelectionUserData: since the former is not cleared.
|
||||
|
||||
|
|
@ -11721,7 +11763,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|||
// to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
|
||||
// We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
|
||||
// If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
|
||||
if (!(g.LastItemData.InFlags & ImGuiItemFlags_NoNav))
|
||||
if (!(g.LastItemData.ItemFlags & ImGuiItemFlags_NoNav))
|
||||
{
|
||||
// FIMXE-NAV: investigate changing the window tests into a simple 'if (g.NavFocusScopeId == g.CurrentFocusScopeId)' test.
|
||||
window->DC.NavLayersActiveMaskNext |= (1 << window->DC.NavLayerCurrent);
|
||||
|
|
@ -11731,12 +11773,12 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|||
NavProcessItem();
|
||||
}
|
||||
|
||||
if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasShortcut)
|
||||
if (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasShortcut)
|
||||
ItemHandleShortcut(id);
|
||||
}
|
||||
|
||||
// Lightweight clear of SetNextItemXXX data.
|
||||
g.NextItemData.Flags = ImGuiNextItemDataFlags_None;
|
||||
g.NextItemData.HasFlags = ImGuiNextItemDataFlags_None;
|
||||
g.NextItemData.ItemFlags = ImGuiItemFlags_None;
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
|
|
@ -11766,7 +11808,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
|||
IM_ASSERT(id != window->ID && "Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works!");
|
||||
}
|
||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
|
||||
//if ((g.LastItemData.InFlags & ImGuiItemFlags_NoNav) == 0)
|
||||
//if ((g.LastItemData.ItemFlags & ImGuiItemFlags_NoNav) == 0)
|
||||
// window->DrawList->AddRect(g.LastItemData.NavRect.Min, g.LastItemData.NavRect.Max, IM_COL32(255,255,0,255)); // [DEBUG]
|
||||
#endif
|
||||
|
||||
|
|
@ -11965,7 +12007,7 @@ void ImGui::Unindent(float indent_w)
|
|||
void ImGui::SetNextItemWidth(float item_width)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth;
|
||||
g.NextItemData.HasFlags |= ImGuiNextItemDataFlags_HasWidth;
|
||||
g.NextItemData.Width = item_width;
|
||||
}
|
||||
|
||||
|
|
@ -11976,7 +12018,7 @@ void ImGui::PushItemWidth(float item_width)
|
|||
ImGuiWindow* window = g.CurrentWindow;
|
||||
window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width
|
||||
window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width);
|
||||
g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
|
||||
g.NextItemData.HasFlags &= ~ImGuiNextItemDataFlags_HasWidth;
|
||||
}
|
||||
|
||||
void ImGui::PushMultiItemsWidths(int components, float w_full)
|
||||
|
|
@ -11995,7 +12037,7 @@ void ImGui::PushMultiItemsWidths(int components, float w_full)
|
|||
prev_split = next_split;
|
||||
}
|
||||
window->DC.ItemWidth = ImMax(prev_split, 1.0f);
|
||||
g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
|
||||
g.NextItemData.HasFlags &= ~ImGuiNextItemDataFlags_HasWidth;
|
||||
}
|
||||
|
||||
void ImGui::PopItemWidth()
|
||||
|
|
@ -12018,7 +12060,7 @@ float ImGui::CalcItemWidth()
|
|||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
float w;
|
||||
if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
|
||||
if (g.NextItemData.HasFlags & ImGuiNextItemDataFlags_HasWidth)
|
||||
w = g.NextItemData.Width;
|
||||
else
|
||||
w = window->DC.ItemWidth;
|
||||
|
|
@ -13111,16 +13153,16 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||
const float scale = g.Style.MouseCursorScale;
|
||||
const ImVec2 ref_pos = NavCalcPreferredRefPos();
|
||||
|
||||
if (g.IO.MouseSource == ImGuiMouseSource_TouchScreen)
|
||||
if (g.IO.MouseSource == ImGuiMouseSource_TouchScreen && NavCalcPreferredRefPosSource() == ImGuiInputSource_Mouse)
|
||||
{
|
||||
ImVec2 tooltip_pos = g.IO.MousePos + TOOLTIP_DEFAULT_OFFSET_TOUCH * scale - (TOOLTIP_DEFAULT_PIVOT_TOUCH * window->Size);
|
||||
ImVec2 tooltip_pos = ref_pos + TOOLTIP_DEFAULT_OFFSET_TOUCH * scale - (TOOLTIP_DEFAULT_PIVOT_TOUCH * window->Size);
|
||||
if (r_outer.Contains(ImRect(tooltip_pos, tooltip_pos + window->Size)))
|
||||
return tooltip_pos;
|
||||
}
|
||||
|
||||
ImVec2 tooltip_pos = g.IO.MousePos + TOOLTIP_DEFAULT_OFFSET_MOUSE * scale;
|
||||
ImVec2 tooltip_pos = ref_pos + TOOLTIP_DEFAULT_OFFSET_MOUSE * scale;
|
||||
ImRect r_avoid;
|
||||
if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos))
|
||||
if (g.NavCursorVisible && g.NavHighlightItemUnderNav && !g.IO.ConfigNavMoveSetMousePos)
|
||||
r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
|
||||
else
|
||||
r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * scale, ref_pos.y + 24 * scale); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
|
||||
|
|
@ -13140,6 +13182,23 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||
// In our terminology those should be interchangeable, yet right now this is super confusing.
|
||||
// Those two functions are merely a legacy artifact, so at minimum naming should be clarified.
|
||||
|
||||
void ImGui::SetNavCursorVisible(bool visible)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.IO.ConfigNavCursorVisibleAlways)
|
||||
visible = true;
|
||||
g.NavCursorVisible = visible;
|
||||
}
|
||||
|
||||
// (was called NavRestoreHighlightAfterMove() before 1.91.4)
|
||||
void ImGui::SetNavCursorVisibleAfterMove()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.IO.ConfigNavCursorVisibleAuto)
|
||||
g.NavCursorVisible = true;
|
||||
g.NavHighlightItemUnderNav = g.NavMousePosDirty = true;
|
||||
}
|
||||
|
||||
void ImGui::SetNavWindow(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
@ -13201,9 +13260,9 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
|||
window->NavRectRel[nav_layer] = WindowRectAbsToRel(window, g.LastItemData.NavRect);
|
||||
|
||||
if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad)
|
||||
g.NavDisableMouseHover = true;
|
||||
else
|
||||
g.NavDisableHighlight = true;
|
||||
g.NavHighlightItemUnderNav = true;
|
||||
else if (g.IO.ConfigNavCursorVisibleAuto)
|
||||
g.NavCursorVisible = false;
|
||||
|
||||
// Clear preferred scoring position (NavMoveRequestApplyResult() will tend to restore it)
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_X);
|
||||
|
|
@ -13226,7 +13285,7 @@ static float inline NavScoreItemDistInterval(float cand_min, float cand_max, flo
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057
|
||||
// Scoring function for keyboard/gamepad directional navigation. Based on https://gist.github.com/rygorous/6981057
|
||||
static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
@ -13375,9 +13434,9 @@ static void ImGui::NavApplyItemToResult(ImGuiNavItemData* result)
|
|||
result->Window = window;
|
||||
result->ID = g.LastItemData.ID;
|
||||
result->FocusScopeId = g.CurrentFocusScopeId;
|
||||
result->InFlags = g.LastItemData.InFlags;
|
||||
result->ItemFlags = g.LastItemData.ItemFlags;
|
||||
result->RectRel = WindowRectAbsToRel(window, g.LastItemData.NavRect);
|
||||
if (result->InFlags & ImGuiItemFlags_HasSelectionUserData)
|
||||
if (result->ItemFlags & ImGuiItemFlags_HasSelectionUserData)
|
||||
{
|
||||
IM_ASSERT(g.NextItemData.SelectionUserData != ImGuiSelectionUserData_Invalid);
|
||||
result->SelectionUserData = g.NextItemData.SelectionUserData; // INTENTIONAL: At this point this field is not cleared in NextItemData. Avoid unnecessary copy to LastItemData.
|
||||
|
|
@ -13400,7 +13459,7 @@ static void ImGui::NavProcessItem()
|
|||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
const ImGuiID id = g.LastItemData.ID;
|
||||
const ImGuiItemFlags item_flags = g.LastItemData.InFlags;
|
||||
const ImGuiItemFlags item_flags = g.LastItemData.ItemFlags;
|
||||
|
||||
// When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221)
|
||||
if (window->DC.NavIsScrollPushableX == false)
|
||||
|
|
@ -13462,7 +13521,7 @@ static void ImGui::NavProcessItem()
|
|||
SetNavFocusScope(g.CurrentFocusScopeId); // Will set g.NavFocusScopeId AND store g.NavFocusScopePath
|
||||
g.NavFocusScopeId = g.CurrentFocusScopeId;
|
||||
g.NavIdIsAlive = true;
|
||||
if (g.LastItemData.InFlags & ImGuiItemFlags_HasSelectionUserData)
|
||||
if (g.LastItemData.ItemFlags & ImGuiItemFlags_HasSelectionUserData)
|
||||
{
|
||||
IM_ASSERT(g.NextItemData.SelectionUserData != ImGuiSelectionUserData_Invalid);
|
||||
g.NavLastValidSelectionUserData = g.NextItemData.SelectionUserData; // INTENTIONAL: At this point this field is not cleared in NextItemData. Avoid unnecessary copy to LastItemData.
|
||||
|
|
@ -13583,7 +13642,7 @@ void ImGui::NavMoveRequestResolveWithPastTreeNode(ImGuiNavItemData* result, ImGu
|
|||
ImGuiContext& g = *GImGui;
|
||||
g.NavMoveScoringItems = false;
|
||||
g.LastItemData.ID = tree_node_data->ID;
|
||||
g.LastItemData.InFlags = tree_node_data->InFlags & ~ImGuiItemFlags_HasSelectionUserData; // Losing SelectionUserData, recovered next-frame (cheaper).
|
||||
g.LastItemData.ItemFlags = tree_node_data->ItemFlags & ~ImGuiItemFlags_HasSelectionUserData; // Losing SelectionUserData, recovered next-frame (cheaper).
|
||||
g.LastItemData.NavRect = tree_node_data->NavRect;
|
||||
NavApplyItemToResult(result); // Result this instead of implementing a NavApplyPastTreeNodeToResult()
|
||||
NavClearPreferredPosForAxis(ImGuiAxis_Y);
|
||||
|
|
@ -13669,13 +13728,6 @@ void ImGui::NavRestoreLayer(ImGuiNavLayer layer)
|
|||
}
|
||||
}
|
||||
|
||||
void ImGui::NavRestoreHighlightAfterMove()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.NavDisableHighlight = false;
|
||||
g.NavDisableMouseHover = g.NavMousePosDirty = true;
|
||||
}
|
||||
|
||||
static inline void ImGui::NavUpdateAnyRequestFlag()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
@ -13717,14 +13769,29 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|||
}
|
||||
}
|
||||
|
||||
static ImVec2 ImGui::NavCalcPreferredRefPos()
|
||||
static ImGuiInputSource ImGui::NavCalcPreferredRefPosSource()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.NavWindow;
|
||||
const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID;
|
||||
|
||||
// Testing for !activated_shortcut here could in theory be removed if we decided that activating a remote shortcut altered one of the g.NavDisableXXX flag.
|
||||
if ((g.NavDisableHighlight || !g.NavDisableMouseHover || !window) && !activated_shortcut)
|
||||
if ((!g.NavCursorVisible || !g.NavHighlightItemUnderNav || !window) && !activated_shortcut)
|
||||
return ImGuiInputSource_Mouse;
|
||||
else
|
||||
return ImGuiInputSource_Keyboard; // or Nav in general
|
||||
}
|
||||
|
||||
static ImVec2 ImGui::NavCalcPreferredRefPos()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.NavWindow;
|
||||
ImGuiInputSource source = NavCalcPreferredRefPosSource();
|
||||
|
||||
const bool activated_shortcut = g.ActiveId != 0 && g.ActiveIdFromShortcut && g.ActiveId == g.LastItemData.ID;
|
||||
|
||||
// Testing for !activated_shortcut here could in theory be removed if we decided that activating a remote shortcut altered one of the g.NavDisableXXX flag.
|
||||
if (source == ImGuiInputSource_Mouse)
|
||||
{
|
||||
// Mouse (we need a fallback in case the mouse becomes invalid after being used)
|
||||
// The +1.0f offset when stored by OpenPopupEx() allows reopening this or another popup (same or another mouse button) while not moving the mouse, it is pretty standard.
|
||||
|
|
@ -13813,11 +13880,14 @@ static void ImGui::NavUpdate()
|
|||
NavMoveRequestApplyResult();
|
||||
g.NavTabbingCounter = 0;
|
||||
g.NavMoveSubmitted = g.NavMoveScoringItems = false;
|
||||
if (g.NavCursorHideFrames > 0)
|
||||
if (--g.NavCursorHideFrames == 0)
|
||||
g.NavCursorVisible = true;
|
||||
|
||||
// Schedule mouse position update (will be done at the bottom of this function, after 1) processing all move requests and 2) updating scrolling)
|
||||
bool set_mouse_pos = false;
|
||||
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
||||
if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow)
|
||||
if (g.NavCursorVisible && g.NavHighlightItemUnderNav && g.NavWindow)
|
||||
set_mouse_pos = true;
|
||||
g.NavMousePosDirty = false;
|
||||
IM_ASSERT(g.NavLayer == ImGuiNavLayer_Main || g.NavLayer == ImGuiNavLayer_Menu);
|
||||
|
|
@ -13833,7 +13903,7 @@ static void ImGui::NavUpdate()
|
|||
|
||||
// Set output flags for user application
|
||||
io.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
|
||||
io.NavVisible = (io.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL);
|
||||
io.NavVisible = (io.NavActive && g.NavId != 0 && g.NavCursorVisible) || (g.NavWindowingTarget != NULL);
|
||||
|
||||
// Process NavCancel input (to close a popup, get back to parent, clear focus)
|
||||
NavUpdateCancelRequest();
|
||||
|
|
@ -13841,7 +13911,7 @@ static void ImGui::NavUpdate()
|
|||
// Process manual activation request
|
||||
g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = 0;
|
||||
g.NavActivateFlags = ImGuiActivateFlags_None;
|
||||
if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
|
||||
if (g.NavId != 0 && g.NavCursorVisible && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
|
||||
{
|
||||
const bool activate_down = (nav_keyboard_active && IsKeyDown(ImGuiKey_Space, ImGuiKeyOwner_NoOwner)) || (nav_gamepad_active && IsKeyDown(ImGuiKey_NavGamepadActivate, ImGuiKeyOwner_NoOwner));
|
||||
const bool activate_pressed = activate_down && ((nav_keyboard_active && IsKeyPressed(ImGuiKey_Space, 0, ImGuiKeyOwner_NoOwner)) || (nav_gamepad_active && IsKeyPressed(ImGuiKey_NavGamepadActivate, 0, ImGuiKeyOwner_NoOwner)));
|
||||
|
|
@ -13866,7 +13936,9 @@ static void ImGui::NavUpdate()
|
|||
}
|
||||
}
|
||||
if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
|
||||
g.NavDisableHighlight = true;
|
||||
g.NavCursorVisible = false;
|
||||
else if (g.IO.ConfigNavCursorVisibleAlways && g.NavCursorHideFrames == 0)
|
||||
g.NavCursorVisible = true;
|
||||
if (g.NavActivateId != 0)
|
||||
IM_ASSERT(g.NavActivateDownId == g.NavActivateId);
|
||||
|
||||
|
|
@ -13923,13 +13995,13 @@ static void ImGui::NavUpdate()
|
|||
// Always prioritize mouse highlight if navigation is disabled
|
||||
if (!nav_keyboard_active && !nav_gamepad_active)
|
||||
{
|
||||
g.NavDisableHighlight = true;
|
||||
g.NavDisableMouseHover = set_mouse_pos = false;
|
||||
g.NavCursorVisible = false;
|
||||
g.NavHighlightItemUnderNav = set_mouse_pos = false;
|
||||
}
|
||||
|
||||
// Update mouse position if requested
|
||||
// (This will take into account the possibility that a Scroll was queued in the window to offset our absolute mouse position before scroll has been applied)
|
||||
if (set_mouse_pos && (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
|
||||
if (set_mouse_pos && io.ConfigNavMoveSetMousePos && (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
|
||||
TeleportMousePos(NavCalcPreferredRefPos());
|
||||
|
||||
// [DEBUG]
|
||||
|
|
@ -13959,7 +14031,7 @@ void ImGui::NavInitRequestApplyResult()
|
|||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = 0;
|
||||
g.NavJustMovedToIsTabbing = false;
|
||||
g.NavJustMovedToHasSelectionData = (result->InFlags & ImGuiItemFlags_HasSelectionUserData) != 0;
|
||||
g.NavJustMovedToHasSelectionData = (result->ItemFlags & ImGuiItemFlags_HasSelectionUserData) != 0;
|
||||
}
|
||||
|
||||
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
|
||||
|
|
@ -13970,7 +14042,7 @@ void ImGui::NavInitRequestApplyResult()
|
|||
if (result->SelectionUserData != ImGuiSelectionUserData_Invalid)
|
||||
g.NavLastValidSelectionUserData = result->SelectionUserData;
|
||||
if (g.NavInitRequestFromMove)
|
||||
NavRestoreHighlightAfterMove();
|
||||
SetNavCursorVisibleAfterMove();
|
||||
}
|
||||
|
||||
// Bias scoring rect ahead of scoring + update preferred pos (if missing) using source position
|
||||
|
|
@ -14067,7 +14139,8 @@ void ImGui::NavUpdateCreateMoveRequest()
|
|||
IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from move, window \"%s\", layer=%d\n", window ? window->Name : "<NULL>", g.NavLayer);
|
||||
g.NavInitRequest = g.NavInitRequestFromMove = true;
|
||||
g.NavInitResult.ID = 0;
|
||||
g.NavDisableHighlight = false;
|
||||
if (g.IO.ConfigNavCursorVisibleAuto)
|
||||
g.NavCursorVisible = true;
|
||||
}
|
||||
|
||||
// When using gamepad, we project the reference nav bounding box into window visible area.
|
||||
|
|
@ -14131,7 +14204,7 @@ void ImGui::NavUpdateCreateTabbingRequest()
|
|||
// See NavProcessItemForTabbingRequest() for a description of the various forward/backward tabbing cases with and without wrapping.
|
||||
const bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
|
||||
if (nav_keyboard_active)
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavDisableHighlight == true && g.ActiveId == 0) ? 0 : +1;
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavCursorVisible == false && g.ActiveId == 0) ? 0 : +1;
|
||||
else
|
||||
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1;
|
||||
ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_IsTabbing | ImGuiNavMoveFlags_Activate;
|
||||
|
|
@ -14163,9 +14236,9 @@ void ImGui::NavMoveRequestApplyResult()
|
|||
if (result == NULL)
|
||||
{
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
||||
NavRestoreHighlightAfterMove();
|
||||
g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavCursorVisible;
|
||||
if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavCursorVisible) == 0)
|
||||
SetNavCursorVisibleAfterMove();
|
||||
NavClearPreferredPosForAxis(axis); // On a failed move, clear preferred pos for this axis.
|
||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveSubmitted but not led to a result!\n");
|
||||
return;
|
||||
|
|
@ -14218,7 +14291,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||
g.NavJustMovedToIsTabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0;
|
||||
g.NavJustMovedToHasSelectionData = (result->InFlags & ImGuiItemFlags_HasSelectionUserData) != 0;
|
||||
g.NavJustMovedToHasSelectionData = (result->ItemFlags & ImGuiItemFlags_HasSelectionUserData) != 0;
|
||||
//IMGUI_DEBUG_LOG_NAV("[nav] NavJustMovedFromFocusScopeId = 0x%08X, NavJustMovedToFocusScopeId = 0x%08X\n", g.NavJustMovedFromFocusScopeId, g.NavJustMovedToFocusScopeId);
|
||||
}
|
||||
|
||||
|
|
@ -14238,7 +14311,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|||
}
|
||||
|
||||
// Tabbing: Activates Inputable, otherwise only Focus
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && (result->ItemFlags & ImGuiItemFlags_Inputable) == 0)
|
||||
g.NavMoveFlags &= ~ImGuiNavMoveFlags_Activate;
|
||||
|
||||
// Activate
|
||||
|
|
@ -14250,12 +14323,12 @@ void ImGui::NavMoveRequestApplyResult()
|
|||
g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState | ImGuiActivateFlags_FromTabbing;
|
||||
}
|
||||
|
||||
// Enable nav highlight
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
||||
NavRestoreHighlightAfterMove();
|
||||
// Make nav cursor visible
|
||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavCursorVisible) == 0)
|
||||
SetNavCursorVisibleAfterMove();
|
||||
}
|
||||
|
||||
// Process NavCancel input (to close a popup, get back to parent, clear focus)
|
||||
// Process Escape/NavCancel input (to close a popup, get back to parent, clear focus)
|
||||
// FIXME: In order to support e.g. Escape to clear a selection we'll need:
|
||||
// - either to store the equivalent of ActiveIdUsingKeyInputMask for a FocusScope and test for it.
|
||||
// - either to move most/all of those tests to the epilogue/end functions of the scope they are dealing with (e.g. exit child window in EndChild()) or in EndFrame(), to allow an earlier intercept
|
||||
|
|
@ -14276,7 +14349,7 @@ static void ImGui::NavUpdateCancelRequest()
|
|||
{
|
||||
// Leave the "menu" layer
|
||||
NavRestoreLayer(ImGuiNavLayer_Main);
|
||||
NavRestoreHighlightAfterMove();
|
||||
SetNavCursorVisibleAfterMove();
|
||||
}
|
||||
else if (g.NavWindow && g.NavWindow != g.NavWindow->RootWindow && !(g.NavWindow->RootWindowForNav->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->RootWindowForNav->ParentWindow)
|
||||
{
|
||||
|
|
@ -14286,7 +14359,7 @@ static void ImGui::NavUpdateCancelRequest()
|
|||
IM_ASSERT(child_window->ChildId != 0);
|
||||
FocusWindow(parent_window);
|
||||
SetNavID(child_window->ChildId, ImGuiNavLayer_Main, 0, WindowRectAbsToRel(parent_window, child_window->Rect()));
|
||||
NavRestoreHighlightAfterMove();
|
||||
SetNavCursorVisibleAfterMove();
|
||||
}
|
||||
else if (g.OpenPopupStack.Size > 0 && g.OpenPopupStack.back().Window != NULL && !(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
|
||||
{
|
||||
|
|
@ -14296,9 +14369,16 @@ static void ImGui::NavUpdateCancelRequest()
|
|||
else
|
||||
{
|
||||
// Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
|
||||
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
|
||||
g.NavWindow->NavLastIds[0] = 0;
|
||||
g.NavId = 0;
|
||||
// FIXME-NAV: This should happen on window appearing.
|
||||
if (g.IO.ConfigNavEscapeClearFocusItem || g.IO.ConfigNavEscapeClearFocusWindow)
|
||||
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup)))// || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
|
||||
g.NavWindow->NavLastIds[0] = 0;
|
||||
|
||||
// Clear nav focus
|
||||
if (g.IO.ConfigNavEscapeClearFocusItem || g.IO.ConfigNavEscapeClearFocusWindow)
|
||||
g.NavId = 0;
|
||||
if (g.IO.ConfigNavEscapeClearFocusWindow)
|
||||
FocusWindow(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -14473,7 +14553,7 @@ static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) //
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
|
||||
static void NavUpdateWindowingTarget(int focus_change_dir)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindowingTarget);
|
||||
|
|
@ -14525,14 +14605,17 @@ static void ImGui::NavUpdateWindowing()
|
|||
const bool keyboard_prev_window = allow_windowing && g.ConfigNavWindowingKeyPrev && Shortcut(g.ConfigNavWindowingKeyPrev, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways, owner_id);
|
||||
const bool start_windowing_with_gamepad = allow_windowing && nav_gamepad_active && !g.NavWindowingTarget && IsKeyPressed(ImGuiKey_NavGamepadMenu, ImGuiInputFlags_None);
|
||||
const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && (keyboard_next_window || keyboard_prev_window); // Note: enabled even without NavEnableKeyboard!
|
||||
bool just_started_windowing_from_null_focus = false;
|
||||
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
||||
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
|
||||
{
|
||||
g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow;
|
||||
g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // Current location
|
||||
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
|
||||
g.NavWindowingAccumDeltaPos = g.NavWindowingAccumDeltaSize = ImVec2(0.0f, 0.0f);
|
||||
g.NavWindowingToggleLayer = start_windowing_with_gamepad ? true : false; // Gamepad starts toggling layer
|
||||
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad;
|
||||
if (g.NavWindow == NULL)
|
||||
just_started_windowing_from_null_focus = true;
|
||||
|
||||
// Manually register ownership of our mods. Using a global route in the Shortcut() calls instead would probably be correct but may have more side-effects.
|
||||
if (keyboard_next_window || keyboard_prev_window)
|
||||
|
|
@ -14548,9 +14631,9 @@ static void ImGui::NavUpdateWindowing()
|
|||
|
||||
// Select window to focus
|
||||
const int focus_change_dir = (int)IsKeyPressed(ImGuiKey_GamepadL1) - (int)IsKeyPressed(ImGuiKey_GamepadR1);
|
||||
if (focus_change_dir != 0)
|
||||
if (focus_change_dir != 0 && !just_started_windowing_from_null_focus)
|
||||
{
|
||||
NavUpdateWindowingHighlightWindow(focus_change_dir);
|
||||
NavUpdateWindowingTarget(focus_change_dir);
|
||||
g.NavWindowingHighlightAlpha = 1.0f;
|
||||
}
|
||||
|
||||
|
|
@ -14573,8 +14656,8 @@ static void ImGui::NavUpdateWindowing()
|
|||
ImGuiKeyChord shared_mods = ((g.ConfigNavWindowingKeyNext ? g.ConfigNavWindowingKeyNext : ImGuiMod_Mask_) & (g.ConfigNavWindowingKeyPrev ? g.ConfigNavWindowingKeyPrev : ImGuiMod_Mask_)) & ImGuiMod_Mask_;
|
||||
IM_ASSERT(shared_mods != 0); // Next/Prev shortcut currently needs a shared modifier to "hold", otherwise Prev actions would keep cycling between two windows.
|
||||
g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f
|
||||
if (keyboard_next_window || keyboard_prev_window)
|
||||
NavUpdateWindowingHighlightWindow(keyboard_next_window ? -1 : +1);
|
||||
if ((keyboard_next_window || keyboard_prev_window) && !just_started_windowing_from_null_focus)
|
||||
NavUpdateWindowingTarget(keyboard_next_window ? -1 : +1);
|
||||
else if ((io.KeyMods & shared_mods) != shared_mods)
|
||||
apply_focus_window = g.NavWindowingTarget;
|
||||
}
|
||||
|
|
@ -14627,7 +14710,7 @@ static void ImGui::NavUpdateWindowing()
|
|||
const float NAV_MOVE_SPEED = 800.0f;
|
||||
const float move_step = NAV_MOVE_SPEED * io.DeltaTime * ImMin(io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
||||
g.NavWindowingAccumDeltaPos += nav_move_dir * move_step;
|
||||
g.NavDisableMouseHover = true;
|
||||
g.NavHighlightItemUnderNav = true;
|
||||
ImVec2 accum_floored = ImTrunc(g.NavWindowingAccumDeltaPos);
|
||||
if (accum_floored.x != 0.0f || accum_floored.y != 0.0f)
|
||||
{
|
||||
|
|
@ -14645,7 +14728,7 @@ static void ImGui::NavUpdateWindowing()
|
|||
// Investigate for each of them: ClearActiveID(), NavRestoreHighlightAfterMove(), NavRestoreLastChildNavWindow(), ClosePopupsOverWindow(), NavInitWindow()
|
||||
ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL;
|
||||
ClearActiveID();
|
||||
NavRestoreHighlightAfterMove();
|
||||
SetNavCursorVisibleAfterMove();
|
||||
ClosePopupsOverWindow(apply_focus_window, false);
|
||||
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
||||
apply_focus_window = g.NavWindow;
|
||||
|
|
@ -14697,7 +14780,7 @@ static void ImGui::NavUpdateWindowing()
|
|||
if (new_nav_layer == ImGuiNavLayer_Menu && !preserve_layer_1_nav_id)
|
||||
g.NavWindow->NavLastIds[new_nav_layer] = 0;
|
||||
NavRestoreLayer(new_nav_layer);
|
||||
NavRestoreHighlightAfterMove();
|
||||
SetNavCursorVisibleAfterMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14838,7 +14921,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
|||
// Rely on keeping other window->LastItemXXX fields intact.
|
||||
source_id = g.LastItemData.ID = window->GetIDFromRectangle(g.LastItemData.Rect);
|
||||
KeepAliveID(source_id);
|
||||
bool is_hovered = ItemHoverable(g.LastItemData.Rect, source_id, g.LastItemData.InFlags);
|
||||
bool is_hovered = ItemHoverable(g.LastItemData.Rect, source_id, g.LastItemData.ItemFlags);
|
||||
if (is_hovered && g.IO.MouseClicked[mouse_button])
|
||||
{
|
||||
SetActiveID(source_id, window);
|
||||
|
|
@ -16467,7 +16550,7 @@ static void ImGui::WindowSelectViewport(ImGuiWindow* window)
|
|||
// We need to take account of the possibility that mouse may become invalid.
|
||||
// Popups/Tooltip always set ViewportAllowPlatformMonitorExtend so GetWindowAllowedExtentRect() will return full monitor bounds.
|
||||
ImVec2 mouse_ref = (flags & ImGuiWindowFlags_Tooltip) ? g.IO.MousePos : g.BeginPopupStack.back().OpenMousePos;
|
||||
bool use_mouse_ref = (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow);
|
||||
bool use_mouse_ref = (!g.NavCursorVisible || !g.NavHighlightItemUnderNav || !g.NavWindow);
|
||||
bool mouse_valid = IsMousePosValid(&mouse_ref);
|
||||
if ((window->Appearing || (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_ChildMenu))) && (!use_mouse_ref || mouse_valid))
|
||||
window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos());
|
||||
|
|
@ -21845,7 +21928,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||
Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible);
|
||||
Text("NavActivateId/DownId/PressedId: %08X/%08X/%08X", g.NavActivateId, g.NavActivateDownId, g.NavActivatePressedId);
|
||||
Text("NavActivateFlags: %04X", g.NavActivateFlags);
|
||||
Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover);
|
||||
Text("NavCursorVisible: %d, NavHighlightItemUnderNav: %d", g.NavCursorVisible, g.NavHighlightItemUnderNav);
|
||||
Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId);
|
||||
Text("NavFocusRoute[] = ");
|
||||
for (int path_n = g.NavFocusRoute.Size - 1; path_n >= 0; path_n--)
|
||||
|
|
@ -21985,7 +22068,7 @@ bool ImGui::DebugBreakButton(const char* label, const char* description_of_locat
|
|||
ColorConvertRGBtoHSV(col4f.x, col4f.y, col4f.z, hsv.x, hsv.y, hsv.z);
|
||||
ColorConvertHSVtoRGB(hsv.x + 0.20f, hsv.y, hsv.z, col4f.x, col4f.y, col4f.z);
|
||||
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderNavCursor(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, GetColorU32(col4f), true, g.Style.FrameRounding);
|
||||
RenderTextClipped(bb.Min, bb.Max, label, NULL, &label_size, g.Style.ButtonTextAlign, &bb);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue