Skip to content

Commit 3982cb3

Browse files
committed
Nav, Docs: consistently use "keyboard/gamepad" instead of sometimes "gamepad/keyboard".
1 parent 1ff9768 commit 3982cb3

File tree

5 files changed

+41
-36
lines changed

5 files changed

+41
-36
lines changed

imgui.cpp

+17-14
Original file line numberDiff line numberDiff line change
@@ -1400,18 +1400,20 @@ ImGuiIO::ImGuiIO()
14001400
FontAllowUserScaling = false;
14011401
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
14021402

1403+
// Keyboard/Gamepad Navigation options
1404+
ConfigNavSwapGamepadButtons = false;
1405+
ConfigNavMoveSetMousePos = false;
1406+
ConfigNavCaptureKeyboard = true;
1407+
ConfigNavEscapeClearFocusItem = true;
1408+
ConfigNavEscapeClearFocusWindow = false;
1409+
14031410
// Miscellaneous options
14041411
MouseDrawCursor = false;
14051412
#ifdef __APPLE__
14061413
ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag
14071414
#else
14081415
ConfigMacOSXBehaviors = false;
14091416
#endif
1410-
ConfigNavSwapGamepadButtons = false;
1411-
ConfigNavMoveSetMousePos = false;
1412-
ConfigNavCaptureKeyboard = true;
1413-
ConfigNavEscapeClearFocusItem = true;
1414-
ConfigNavEscapeClearFocusWindow = false;
14151417
ConfigInputTrickleEventQueue = true;
14161418
ConfigInputTextCursorBlink = true;
14171419
ConfigInputTextEnterKeepActive = false;
@@ -3900,19 +3902,20 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
39003902
CurrentItemFlags = ImGuiItemFlags_None;
39013903
DebugShowGroupRects = false;
39023904

3905+
NavCursorVisible = false;
3906+
NavHighlightItemUnderNav = false;
3907+
NavMousePosDirty = false;
3908+
NavIdIsAlive = false;
3909+
NavId = 0;
39033910
NavWindow = NULL;
3904-
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
3911+
NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = 0;
39053912
NavLayer = ImGuiNavLayer_Main;
39063913
NavNextActivateId = 0;
39073914
NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None;
39083915
NavHighlightActivatedId = 0;
39093916
NavHighlightActivatedTimer = 0.0f;
39103917
NavInputSource = ImGuiInputSource_Keyboard;
39113918
NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid;
3912-
NavIdIsAlive = false;
3913-
NavMousePosDirty = false;
3914-
NavCursorVisible = false;
3915-
NavHighlightItemUnderNav = false;
39163919

39173920
NavAnyRequest = false;
39183921
NavInitRequest = false;
@@ -5197,7 +5200,7 @@ void ImGui::NewFrame()
51975200
//IM_ASSERT(g.IO.KeyAlt == IsKeyDown(ImGuiKey_LeftAlt) || IsKeyDown(ImGuiKey_RightAlt));
51985201
//IM_ASSERT(g.IO.KeySuper == IsKeyDown(ImGuiKey_LeftSuper) || IsKeyDown(ImGuiKey_RightSuper));
51995202

5200-
// Update gamepad/keyboard navigation
5203+
// Update keyboard/gamepad navigation
52015204
NavUpdate();
52025205

52035206
// Update mouse input state
@@ -9777,7 +9780,7 @@ static void ImGui::UpdateMouseInputs()
97779780
g.MouseStationaryTimer = mouse_stationary ? (g.MouseStationaryTimer + io.DeltaTime) : 0.0f;
97789781
//IMGUI_DEBUG_LOG("%.4f\n", g.MouseStationaryTimer);
97799782

9780-
// 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.
9783+
// 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.
97819784
if (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)
97829785
g.NavHighlightItemUnderNav = false;
97839786

@@ -9816,7 +9819,7 @@ static void ImGui::UpdateMouseInputs()
98169819
// We provide io.MouseDoubleClicked[] as a legacy service
98179820
io.MouseDoubleClicked[i] = (io.MouseClickedCount[i] == 2);
98189821

9819-
// Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation
9822+
// Clicking any mouse button reactivate mouse hovering which may have been deactivated by keyboard/gamepad navigation
98209823
if (io.MouseClicked[i])
98219824
g.NavHighlightItemUnderNav = false;
98229825
}
@@ -12310,7 +12313,7 @@ static float inline NavScoreItemDistInterval(float cand_min, float cand_max, flo
1231012313
return 0.0f;
1231112314
}
1231212315

12313-
// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057
12316+
// Scoring function for keyboard/gamepad directional navigation. Based on https://gist.github.com/rygorous/6981057
1231412317
static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
1231512318
{
1231612319
ImGuiContext& g = *GImGui;

imgui.h

+13-11
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ namespace ImGui
581581
// the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x
582582
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
583583
// - Format string may also be set to NULL or use the default format ("%f" or "%d").
584-
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
584+
// - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For keyboard/gamepad navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision).
585585
// - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits if ImGuiSliderFlags_AlwaysClamp is not used.
586586
// - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum.
587587
// - We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them.
@@ -1080,8 +1080,8 @@ enum ImGuiWindowFlags_
10801080
ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus)
10811081
ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y)
10821082
ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x)
1083-
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No gamepad/keyboard navigation within the window
1084-
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
1083+
ImGuiWindowFlags_NoNavInputs = 1 << 16, // No keyboard/gamepad navigation within the window
1084+
ImGuiWindowFlags_NoNavFocus = 1 << 17, // No focusing toward this window with keyboard/gamepad navigation (e.g. skipped by CTRL+TAB)
10851085
ImGuiWindowFlags_UnsavedDocument = 1 << 18, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
10861086
ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus,
10871087
ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse,
@@ -1121,7 +1121,7 @@ enum ImGuiChildFlags_
11211121
ImGuiChildFlags_AutoResizeY = 1 << 5, // Enable auto-resizing height. Read "IMPORTANT: Size measurement" details above.
11221122
ImGuiChildFlags_AlwaysAutoResize = 1 << 6, // Combined with AutoResizeX/AutoResizeY. Always measure size even when child is hidden, always return true, always disable clipping optimization! NOT RECOMMENDED.
11231123
ImGuiChildFlags_FrameStyle = 1 << 7, // Style the child window like a framed item: use FrameBg, FrameRounding, FrameBorderSize, FramePadding instead of ChildBg, ChildRounding, ChildBorderSize, WindowPadding.
1124-
ImGuiChildFlags_NavFlattened = 1 << 8, // [BETA] Share focus scope, allow gamepad/keyboard navigation to cross over parent border to this child or between sibling child windows.
1124+
ImGuiChildFlags_NavFlattened = 1 << 8, // [BETA] Share focus scope, allow keyboard/gamepad navigation to cross over parent border to this child or between sibling child windows.
11251125

11261126
// Obsolete names
11271127
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
@@ -1328,7 +1328,7 @@ enum ImGuiHoveredFlags_
13281328
ImGuiHoveredFlags_AllowWhenOverlappedByItem = 1 << 8, // IsItemHovered() only: Return true even if the item uses AllowOverlap mode and is overlapped by another hoverable item.
13291329
ImGuiHoveredFlags_AllowWhenOverlappedByWindow = 1 << 9, // IsItemHovered() only: Return true even if the position is obstructed or overlapped by another window.
13301330
ImGuiHoveredFlags_AllowWhenDisabled = 1 << 10, // IsItemHovered() only: Return true even if the item is disabled
1331-
ImGuiHoveredFlags_NoNavOverride = 1 << 11, // IsItemHovered() only: Disable using gamepad/keyboard navigation state when active, always query mouse
1331+
ImGuiHoveredFlags_NoNavOverride = 1 << 11, // IsItemHovered() only: Disable using keyboard/gamepad navigation state when active, always query mouse
13321332
ImGuiHoveredFlags_AllowWhenOverlapped = ImGuiHoveredFlags_AllowWhenOverlappedByItem | ImGuiHoveredFlags_AllowWhenOverlappedByWindow,
13331333
ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped,
13341334
ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows,
@@ -1678,7 +1678,7 @@ enum ImGuiCol_
16781678
ImGuiCol_TextLink, // Hyperlink color
16791679
ImGuiCol_TextSelectedBg,
16801680
ImGuiCol_DragDropTarget, // Rectangle highlighting a drop target
1681-
ImGuiCol_NavCursor, // Color of gamepad/keyboard navigation cursor/rectangle, when visible
1681+
ImGuiCol_NavCursor, // Color of keyboard/gamepad navigation cursor/rectangle, when visible
16821682
ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
16831683
ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active
16841684
ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active
@@ -2230,7 +2230,7 @@ struct ImGuiIO
22302230
// Configuration // Default value
22312231
//------------------------------------------------------------------
22322232

2233-
ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc.
2233+
ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Keyboard/Gamepad navigation options, etc.
22342234
ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend.
22352235
ImVec2 DisplaySize; // <unset> // Main display size, in pixels (generally == GetMainViewport()->Size). May change every frame.
22362236
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. May change every frame.
@@ -2246,15 +2246,17 @@ struct ImGuiIO
22462246
ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0].
22472247
ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale.
22482248

2249-
// Miscellaneous options
2250-
// (you can visualize and interact with all options in 'Demo->Configuration')
2251-
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
2252-
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
2249+
// Keyboard/Gamepad Navigation options
22532250
bool ConfigNavSwapGamepadButtons; // = false // Swap Activate<>Cancel (A<>B) buttons, matching typical "Nintendo/Japanese style" gamepad layout.
22542251
bool ConfigNavMoveSetMousePos; // = false // Directional/tabbing navigation teleports the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is difficult. Will update io.MousePos and set io.WantSetMousePos=true.
22552252
bool ConfigNavCaptureKeyboard; // = true // Sets io.WantCaptureKeyboard when io.NavActive is set.
22562253
bool ConfigNavEscapeClearFocusItem; // = true // Pressing Escape can clear focused item + navigation id/highlight. Set to false if you want to always keep highlight on.
22572254
bool ConfigNavEscapeClearFocusWindow;// = false // Pressing Escape can clear focused window as well (super set of io.ConfigNavEscapeClearFocusItem).
2255+
2256+
// Miscellaneous options
2257+
// (you can visualize and interact with all options in 'Demo->Configuration')
2258+
bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations.
2259+
bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // Swap Cmd<>Ctrl keys + OS X style text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl.
22582260
bool ConfigInputTrickleEventQueue; // = true // Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.
22592261
bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting).
22602262
bool ConfigInputTextEnterKeepActive; // = false // [BETA] Pressing Enter will keep item active and select contents (single-line only).

imgui_demo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ static void ShowDemoWindowWidgets(ImGuiDemoWindowData* demo_data)
10121012

10131013
// The following examples are passed for documentation purpose but may not be useful to most users.
10141014
// Passing ImGuiHoveredFlags_ForTooltip to IsItemHovered() will pull ImGuiHoveredFlags flags values from
1015-
// 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' depending on whether mouse or gamepad/keyboard is being used.
1015+
// 'style.HoverFlagsForTooltipMouse' or 'style.HoverFlagsForTooltipNav' depending on whether mouse or keyboard/gamepad is being used.
10161016
// With default settings, ImGuiHoveredFlags_ForTooltip is equivalent to ImGuiHoveredFlags_DelayShort + ImGuiHoveredFlags_Stationary.
10171017
ImGui::Button("Manual", sz);
10181018
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip))

imgui_internal.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ struct ImGuiLocEntry; // A localization entry.
141141
struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
142142
struct ImGuiMultiSelectState; // Multi-selection persistent state (for focused selection).
143143
struct ImGuiMultiSelectTempData; // Multi-selection temporary state (while traversing).
144-
struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result
144+
struct ImGuiNavItemData; // Result of a keyboard/gamepad directional navigation move query result
145145
struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions
146146
struct ImGuiNextWindowData; // Storage for SetNextWindow** functions
147147
struct ImGuiNextItemData; // Storage for SetNextItem** functions
@@ -2132,13 +2132,15 @@ struct ImGuiContext
21322132
// Viewports
21332133
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
21342134

2135-
// Gamepad/keyboard Navigation
2135+
// Keyboard/Gamepad Navigation
21362136
bool NavCursorVisible; // Nav focus cursor/rectangle is visible? We hide it after a mouse click. We show it after a nav move.
21372137
bool NavHighlightItemUnderNav; // Disable mouse hovering highlight. Highlight navigation focused item instead of mouse hovered item.
21382138
//bool NavDisableHighlight; // Old name for !g.NavCursorVisible before 1.91.4 (2024/10/18). OPPOSITE VALUE (g.NavDisableHighlight == !g.NavCursorVisible)
21392139
//bool NavDisableMouseHover; // Old name for g.NavHighlightItemUnderNav before 1.91.1 (2024/10/18) this was called When user starts using keyboard/gamepad, we hide mouse hovering highlight until mouse is touched again.
2140-
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
2140+
bool NavMousePosDirty; // When set we will update mouse position if io.ConfigNavMoveSetMousePos is set (not enabled by default)
2141+
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid
21412142
ImGuiID NavId; // Focused item for navigation
2143+
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusedWindow'
21422144
ImGuiID NavFocusScopeId; // Focused focus scope (e.g. selection code often wants to "clear other items" when landing on an item of the same scope)
21432145
ImGuiNavLayer NavLayer; // Focused layer (main scrolling layer, or menu/title bar layer)
21442146
ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && (IsKeyPressed(ImGuiKey_Space) || IsKeyDown(ImGuiKey_Enter) || IsKeyPressed(ImGuiKey_NavGamepadActivate)) ? NavId : 0, also set when calling ActivateItem()
@@ -2152,8 +2154,6 @@ struct ImGuiContext
21522154
ImGuiActivateFlags NavNextActivateFlags;
21532155
ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS CAN ONLY BE ImGuiInputSource_Keyboard or ImGuiInputSource_Mouse
21542156
ImGuiSelectionUserData NavLastValidSelectionUserData; // Last valid data passed to SetNextItemSelectionUser(), or -1. For current window. Not reset when focusing an item that doesn't have selection data.
2155-
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid
2156-
bool NavMousePosDirty; // When set we will update mouse position if io.ConfigNavMoveSetMousePos is set (not enabled by default)
21572157

21582158
// Navigation: Init & Move Requests
21592159
bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest this is to perform early out in ItemAdd()
@@ -3101,7 +3101,7 @@ namespace ImGui
31013101
IMGUI_API bool BeginComboPreview();
31023102
IMGUI_API void EndComboPreview();
31033103

3104-
// Gamepad/Keyboard Navigation
3104+
// Keyboard/Gamepad Navigation
31053105
IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit);
31063106
IMGUI_API void NavInitRequestApplyResult();
31073107
IMGUI_API bool NavMoveRequestButNoResultYet();

0 commit comments

Comments
 (0)