mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Nav: Fixed toggling menu layer with Alt exiting menu layer with Esc not moving mouse when NavEnableSetMousePos config flag is set.
This commit is contained in:
parent
3d9d3b49ae
commit
dff15acdb5
@ -42,11 +42,13 @@ Breaking Changes:
|
|||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Windows: fixed background order of overlapping childs submitted sequentially. (#4493)
|
- Windows: Fixed background order of overlapping childs submitted sequentially. (#4493)
|
||||||
- InputTextMultiline: Fixed label size not being included into window contents rect unless
|
- InputTextMultiline: Fixed label size not being included into window contents rect unless
|
||||||
the whole widget is clipped.
|
the whole widget is clipped.
|
||||||
- TextUnformatted: Accept null ranges including (NULL,NULL) without asserting, in order to conform
|
- TextUnformatted: Accept null ranges including (NULL,NULL) without asserting, in order to conform
|
||||||
to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#3615)
|
to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#3615)
|
||||||
|
- Nav: Fixed toggling menu layer with Alt or exiting menu layer with Esc not moving mouse when
|
||||||
|
the NavEnableSetMousePos config flag is set.
|
||||||
- PlotHistogram: Fixed zero-line position when manually specifying min<0 and max>0. (#4349) [@filippocrocchini]
|
- PlotHistogram: Fixed zero-line position when manually specifying min<0 and max>0. (#4349) [@filippocrocchini]
|
||||||
- IO: Added 'io.WantCaptureMouseUnlessPopupClose' alternative to `io.WantCaptureMouse'. (#4480)
|
- IO: Added 'io.WantCaptureMouseUnlessPopupClose' alternative to `io.WantCaptureMouse'. (#4480)
|
||||||
This allows apps to receive the click on void when that click is used to close popup (by default,
|
This allows apps to receive the click on void when that click is used to close popup (by default,
|
||||||
|
28
imgui.cpp
28
imgui.cpp
@ -8682,6 +8682,7 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// FIXME-NAV: The existence of SetNavID vs SetFocusID properly needs to be clarified/reworked.
|
// FIXME-NAV: The existence of SetNavID vs SetFocusID properly needs to be clarified/reworked.
|
||||||
|
// In our terminology those should be interchangeable. Those two functions are merely a legacy artifact, so at minimum naming should be clarified.
|
||||||
void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -9039,14 +9040,14 @@ void ImGui::NavRestoreLayer(ImGuiNavLayer layer)
|
|||||||
if (window->NavLastIds[layer] != 0)
|
if (window->NavLastIds[layer] != 0)
|
||||||
{
|
{
|
||||||
SetNavID(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]);
|
SetNavID(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]);
|
||||||
g.NavDisableHighlight = false;
|
|
||||||
g.NavDisableMouseHover = g.NavMousePosDirty = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g.NavLayer = layer;
|
g.NavLayer = layer;
|
||||||
NavInitWindow(window, true);
|
NavInitWindow(window, true);
|
||||||
}
|
}
|
||||||
|
g.NavDisableHighlight = false;
|
||||||
|
g.NavDisableMouseHover = g.NavMousePosDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ImGui::NavUpdateAnyRequestFlag()
|
static inline void ImGui::NavUpdateAnyRequestFlag()
|
||||||
@ -9211,6 +9212,7 @@ static void ImGui::NavUpdate()
|
|||||||
{
|
{
|
||||||
io.MousePos = io.MousePosPrev = NavCalcPreferredRefPos();
|
io.MousePos = io.MousePosPrev = NavCalcPreferredRefPos();
|
||||||
io.WantSetMousePos = true;
|
io.WantSetMousePos = true;
|
||||||
|
//IMGUI_DEBUG_LOG("SetMousePos: (%.1f,%.1f)\n", io.MousePos.x, io.MousePos.y);
|
||||||
}
|
}
|
||||||
g.NavMousePosDirty = false;
|
g.NavMousePosDirty = false;
|
||||||
}
|
}
|
||||||
@ -9310,6 +9312,7 @@ static void ImGui::NavUpdateInitResult()
|
|||||||
// FIXME-NAV: On _NavFlattened windows, g.NavWindow will only be updated during subsequent frame. Not a problem currently.
|
// FIXME-NAV: On _NavFlattened windows, g.NavWindow will only be updated during subsequent frame. Not a problem currently.
|
||||||
IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
|
IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name);
|
||||||
SetNavID(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel);
|
SetNavID(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel);
|
||||||
|
g.NavIdIsAlive = true; // Mark as alive from previous frame as we got a result
|
||||||
if (g.NavInitRequestFromMove)
|
if (g.NavInitRequestFromMove)
|
||||||
{
|
{
|
||||||
g.NavDisableHighlight = false;
|
g.NavDisableHighlight = false;
|
||||||
@ -9415,9 +9418,10 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
||||||
|
// No result
|
||||||
|
// In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
|
||||||
if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
|
if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
|
||||||
{
|
{
|
||||||
// In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
|
|
||||||
if (g.NavId != 0)
|
if (g.NavId != 0)
|
||||||
{
|
{
|
||||||
g.NavDisableHighlight = false;
|
g.NavDisableHighlight = false;
|
||||||
@ -9470,8 +9474,12 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Focus
|
||||||
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name);
|
IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name);
|
||||||
SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel);
|
||||||
|
|
||||||
|
// Enable nav highlight
|
||||||
g.NavDisableHighlight = false;
|
g.NavDisableHighlight = false;
|
||||||
g.NavDisableMouseHover = g.NavMousePosDirty = true;
|
g.NavDisableMouseHover = g.NavMousePosDirty = true;
|
||||||
}
|
}
|
||||||
@ -9863,14 +9871,16 @@ static void ImGui::NavUpdateWindowing()
|
|||||||
FocusWindow(new_nav_window);
|
FocusWindow(new_nav_window);
|
||||||
new_nav_window->NavLastChildNavWindow = old_nav_window;
|
new_nav_window->NavLastChildNavWindow = old_nav_window;
|
||||||
}
|
}
|
||||||
g.NavDisableHighlight = false;
|
|
||||||
g.NavDisableMouseHover = true;
|
|
||||||
|
|
||||||
// Reinitialize navigation when entering menu bar with the Alt key.
|
// Toggle layer
|
||||||
const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayersActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main;
|
const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayersActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main;
|
||||||
if (new_nav_layer == ImGuiNavLayer_Menu)
|
if (new_nav_layer != g.NavLayer)
|
||||||
g.NavWindow->NavLastIds[new_nav_layer] = 0;
|
{
|
||||||
NavRestoreLayer(new_nav_layer);
|
// Reinitialize navigation when entering menu bar with the Alt key (FIXME: could be a properly of the layer?)
|
||||||
|
if (new_nav_layer == ImGuiNavLayer_Menu)
|
||||||
|
g.NavWindow->NavLastIds[new_nav_layer] = 0;
|
||||||
|
NavRestoreLayer(new_nav_layer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user