|
@@ -7530,13 +7530,6 @@ void ImGui::SetWindowFontScale(float scale)
|
|
|
g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
|
|
|
}
|
|
|
|
|
|
-void ImGui::ActivateItem(ImGuiID id)
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- g.NavNextActivateId = id;
|
|
|
- g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
|
|
-}
|
|
|
-
|
|
|
void ImGui::PushFocusScope(ImGuiID id)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
@@ -7552,13 +7545,40 @@ void ImGui::PopFocusScope()
|
|
|
g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back() : 0;
|
|
|
}
|
|
|
|
|
|
+// Focus = move navigation cursor, set scrolling, set focus window.
|
|
|
+void ImGui::FocusItem()
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ ImGuiWindow* window = g.CurrentWindow;
|
|
|
+ IMGUI_DEBUG_LOG_FOCUS("FocusItem(0x%08x) in window \"%s\"\n", g.LastItemData.ID, window->Name);
|
|
|
+ if (g.DragDropActive || g.MovingWindow != NULL) // FIXME: Opt-in flags for this?
|
|
|
+ {
|
|
|
+ IMGUI_DEBUG_LOG_FOCUS("FocusItem() ignored while DragDropActive!\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_FocusApi; // No activation/selection
|
|
|
+ ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
|
|
+ SetNavWindow(window);
|
|
|
+ NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_Up, move_flags, scroll_flags);
|
|
|
+ NavMoveRequestResolveWithLastItem(&g.NavMoveResultLocal);
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui::ActivateItemByID(ImGuiID id)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ g.NavNextActivateId = id;
|
|
|
+ g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
|
|
+}
|
|
|
+
|
|
|
// Note: this will likely be called ActivateItem() once we rework our Focus/Activation system!
|
|
|
+// But ActivateItem() should function without altering scroll/focus?
|
|
|
void ImGui::SetKeyboardFocusHere(int offset)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
|
|
- IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name);
|
|
|
+ IMGUI_DEBUG_LOG_FOCUS("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name);
|
|
|
|
|
|
// It makes sense in the vast majority of cases to never interrupt a drag and drop.
|
|
|
// When we refactor this function into ActivateItem() we may want to make this an option.
|
|
@@ -7566,14 +7586,15 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
|
|
// is also automatically dropped in the event g.ActiveId is stolen.
|
|
|
if (g.DragDropActive || g.MovingWindow != NULL)
|
|
|
{
|
|
|
- IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere() ignored while DragDropActive!\n");
|
|
|
+ IMGUI_DEBUG_LOG_FOCUS("SetKeyboardFocusHere() ignored while DragDropActive!\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
SetNavWindow(window);
|
|
|
|
|
|
+ ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate | ImGuiNavMoveFlags_FocusApi;
|
|
|
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
|
|
- NavMoveRequestSubmit(ImGuiDir_None, offset < 0 ? ImGuiDir_Up : ImGuiDir_Down, ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_FocusApi, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
|
|
+ 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)
|
|
|
{
|
|
|
NavMoveRequestResolveWithLastItem(&g.NavMoveResultLocal);
|
|
@@ -11555,9 +11576,10 @@ void ImGui::NavUpdateCreateTabbingRequest()
|
|
|
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.NavDisableHighlight == true && g.ActiveId == 0) ? 0 : +1;
|
|
|
else
|
|
|
g.NavTabbingDir = g.IO.KeyShift ? -1 : (g.ActiveId == 0) ? 0 : +1;
|
|
|
+ ImGuiNavMoveFlags move_flags = ImGuiNavMoveFlags_Tabbing | ImGuiNavMoveFlags_Activate;
|
|
|
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
|
|
|
ImGuiDir clip_dir = (g.NavTabbingDir < 0) ? ImGuiDir_Up : ImGuiDir_Down;
|
|
|
- NavMoveRequestSubmit(ImGuiDir_None, clip_dir, ImGuiNavMoveFlags_Tabbing, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
|
|
+ NavMoveRequestSubmit(ImGuiDir_None, clip_dir, move_flags, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable.
|
|
|
g.NavTabbingCounter = -1;
|
|
|
}
|
|
|
|
|
@@ -11623,7 +11645,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|
|
}
|
|
|
if (g.ActiveId != result->ID)
|
|
|
ClearActiveID();
|
|
|
- if (g.NavId != result->ID)
|
|
|
+ if (g.NavId != result->ID && (g.NavMoveFlags & ImGuiNavMoveFlags_Activate) != 0)
|
|
|
{
|
|
|
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
|
|
g.NavJustMovedToId = result->ID;
|
|
@@ -11644,19 +11666,18 @@ void ImGui::NavMoveRequestApplyResult()
|
|
|
g.NavWindow->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer] = preferred_scoring_pos_rel;
|
|
|
}
|
|
|
|
|
|
- // Tabbing: Activates Inputable or Focus non-Inputable
|
|
|
- if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable))
|
|
|
- {
|
|
|
- g.NavNextActivateId = result->ID;
|
|
|
- g.NavNextActivateFlags = ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
|
|
- g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight;
|
|
|
- }
|
|
|
+ // Tabbing: Activates Inputable, otherwise only Focus
|
|
|
+ if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable) == 0)
|
|
|
+ g.NavMoveFlags &= ~ImGuiNavMoveFlags_Activate;
|
|
|
|
|
|
// Activate
|
|
|
if (g.NavMoveFlags & ImGuiNavMoveFlags_Activate)
|
|
|
{
|
|
|
g.NavNextActivateId = result->ID;
|
|
|
g.NavNextActivateFlags = ImGuiActivateFlags_None;
|
|
|
+ g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight;
|
|
|
+ if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
|
|
+ g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
|
|
}
|
|
|
|
|
|
// Enable nav highlight
|