|
@@ -1,4 +1,4 @@
|
|
|
-// dear imgui, v1.89.6
|
|
|
+// dear imgui, v1.89.7 WIP
|
|
|
// (main code and documentation)
|
|
|
|
|
|
// Help:
|
|
@@ -5589,7 +5589,7 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, b
|
|
|
|
|
|
// Process navigation-in immediately so NavInit can run on first frame
|
|
|
// Can enter a child if (A) it has navigatable items or (B) it can be scrolled.
|
|
|
- const ImGuiID temp_id_for_activation = (id + 1);
|
|
|
+ const ImGuiID temp_id_for_activation = ImHashStr("##Child", 0, id);
|
|
|
if (g.ActiveId == temp_id_for_activation)
|
|
|
ClearActiveID();
|
|
|
if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavWindowHasScrollY))
|
|
@@ -8131,13 +8131,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;
|
|
@@ -8153,13 +8146,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 | 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);
|
|
|
+ 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.
|
|
@@ -8167,14 +8187,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);
|
|
@@ -12221,9 +12242,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;
|
|
|
}
|
|
|
|
|
@@ -12249,8 +12271,8 @@ void ImGui::NavMoveRequestApplyResult()
|
|
|
if (result == NULL)
|
|
|
{
|
|
|
if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
|
|
- g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight;
|
|
|
- if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0)
|
|
|
+ g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavHighlight;
|
|
|
+ if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
|
|
NavRestoreHighlightAfterMove();
|
|
|
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");
|
|
@@ -12289,7 +12311,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|
|
}
|
|
|
if (g.ActiveId != result->ID)
|
|
|
ClearActiveID();
|
|
|
- if (g.NavId != result->ID)
|
|
|
+ if (g.NavId != result->ID && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
|
|
{
|
|
|
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
|
|
|
g.NavJustMovedToId = result->ID;
|
|
@@ -12310,23 +12332,22 @@ 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_NoSetNavHighlight;
|
|
|
+ if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing)
|
|
|
+ g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState;
|
|
|
}
|
|
|
|
|
|
// Enable nav highlight
|
|
|
- if ((g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0)
|
|
|
+ if ((g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavHighlight) == 0)
|
|
|
NavRestoreHighlightAfterMove();
|
|
|
}
|
|
|
|