mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Nav: Tidying up, renaming + update AnyRequest flag in NavMoveRequestSubmit().
This commit is contained in:
parent
528104a89b
commit
ade4c15eea
22
imgui.cpp
22
imgui.cpp
@ -910,7 +910,6 @@ namespace ImGui
|
||||
static void NavUpdate();
|
||||
static void NavUpdateWindowing();
|
||||
static void NavUpdateWindowingOverlay();
|
||||
static void NavUpdateInitResult();
|
||||
static void NavUpdateCancelRequest();
|
||||
static void NavUpdateCreateMoveRequest();
|
||||
static float NavUpdatePageUpPageDown();
|
||||
@ -3332,7 +3331,7 @@ void ImGui::ItemInputable(ImGuiWindow* window, ImGuiID id)
|
||||
}
|
||||
if (is_tab_stop && window->DC.FocusCounterTabStop == g.TabFocusRequestCurrCounterTabStop)
|
||||
{
|
||||
g.NavJustTabbedId = id;
|
||||
g.NavJustTabbedId = id; // FIXME-NAV: aim to eventually set in NavUpdate() once we finish the refactor
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_FocusedByTabbing;
|
||||
return;
|
||||
}
|
||||
@ -8975,6 +8974,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
||||
g.NavMoveResultLocal.Clear();
|
||||
g.NavMoveResultLocalVisible.Clear();
|
||||
g.NavMoveResultOther.Clear();
|
||||
NavUpdateAnyRequestFlag();
|
||||
}
|
||||
|
||||
void ImGui::NavMoveRequestCancel()
|
||||
@ -9150,9 +9150,7 @@ static void ImGui::NavUpdate()
|
||||
ImGuiIO& io = g.IO;
|
||||
|
||||
io.WantSetMousePos = false;
|
||||
#if 0
|
||||
if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG("NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
|
||||
#endif
|
||||
//if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG("NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
|
||||
|
||||
// Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard)
|
||||
// (do it before we map Keyboard input!)
|
||||
@ -9188,7 +9186,7 @@ static void ImGui::NavUpdate()
|
||||
|
||||
// Process navigation init request (select first/default focus)
|
||||
if (g.NavInitResultId != 0)
|
||||
NavUpdateInitResult();
|
||||
NavInitRequestApplyResult();
|
||||
g.NavInitRequest = false;
|
||||
g.NavInitRequestFromMove = false;
|
||||
g.NavInitResultId = 0;
|
||||
@ -9253,6 +9251,7 @@ static void ImGui::NavUpdate()
|
||||
IM_ASSERT(g.NavActivateDownId == g.NavActivateId);
|
||||
|
||||
// Process programmatic activation request
|
||||
// FIXME-NAV: Those should eventually be queued (unlike focus they don't cancel each others)
|
||||
if (g.NavNextActivateId != 0)
|
||||
g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId;
|
||||
g.NavNextActivateId = 0;
|
||||
@ -9304,7 +9303,7 @@ static void ImGui::NavUpdate()
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ImGui::NavUpdateInitResult()
|
||||
void ImGui::NavInitRequestApplyResult()
|
||||
{
|
||||
// In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void)
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -9425,9 +9424,11 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
return;
|
||||
#endif
|
||||
|
||||
// No result
|
||||
// Select which result to use
|
||||
ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL;
|
||||
|
||||
// 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 (result == NULL)
|
||||
{
|
||||
if (g.NavId != 0)
|
||||
{
|
||||
@ -9437,9 +9438,6 @@ void ImGui::NavMoveRequestApplyResult()
|
||||
return;
|
||||
}
|
||||
|
||||
// Select which result to use
|
||||
ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
||||
|
||||
// PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
|
||||
if (g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet)
|
||||
if (g.NavMoveResultLocalVisible.ID != 0 && g.NavMoveResultLocalVisible.ID != g.NavId)
|
||||
|
@ -2451,6 +2451,7 @@ namespace ImGui
|
||||
|
||||
// Gamepad/Keyboard Navigation
|
||||
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
|
||||
IMGUI_API void NavInitRequestApplyResult();
|
||||
IMGUI_API bool NavMoveRequestButNoResultYet();
|
||||
IMGUI_API void NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags);
|
||||
IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags);
|
||||
|
@ -2416,7 +2416,6 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
temp_input_is_active = true;
|
||||
}
|
||||
// Experimental: simple click (without moving) turns Drag into an InputText
|
||||
// FIXME: Currently polling ImGuiConfigFlags_IsTouchScreen, may either poll an hypothetical ImGuiBackendFlags_HasKeyboard and/or an explicit drag settings.
|
||||
if (g.IO.ConfigDragClickToInputText && temp_input_allowed && !temp_input_is_active)
|
||||
if (g.ActiveId == id && hovered && g.IO.MouseReleased[0] && !IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user