mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Nav: internals: renaming ImGuiInputSource so it is not specific to nav. Comments.
This commit is contained in:
		| @@ -1,6 +1,8 @@ | ||||
| # See http://editorconfig.org to read about the EditorConfig format. | ||||
| # - Automatically supported by VS2017+ and most common IDE or text editors. | ||||
| # - For older VS2010 to VS2015, install https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig | ||||
| # - In theory automatically supported by VS2017+ and most common IDE or text editors. | ||||
| # - In practice VS2019 stills gets trailing whitespaces wrong :( | ||||
| #   - Suggest install to trim whitespaces: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer | ||||
| #   - Alternative for older VS2010 to VS2015: https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig | ||||
|  | ||||
| # top-most EditorConfig file | ||||
| root = true | ||||
|   | ||||
							
								
								
									
										22
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -5395,9 +5395,9 @@ static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& s | ||||
|     if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window) | ||||
|     { | ||||
|         ImVec2 nav_resize_delta; | ||||
|         if (g.NavInputSource == ImGuiInputSource_NavKeyboard && g.IO.KeyShift) | ||||
|         if (g.NavInputSource == ImGuiInputSource_Keyboard && g.IO.KeyShift) | ||||
|             nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); | ||||
|         if (g.NavInputSource == ImGuiInputSource_NavGamepad) | ||||
|         if (g.NavInputSource == ImGuiInputSource_Gamepad) | ||||
|             nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down); | ||||
|         if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f) | ||||
|         { | ||||
| @@ -8931,17 +8931,17 @@ static void ImGui::NavUpdate() | ||||
|     // (do it before we map Keyboard input!) | ||||
|     bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; | ||||
|     bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; | ||||
|     if (nav_gamepad_active && g.NavInputSource != ImGuiInputSource_NavGamepad) | ||||
|     if (nav_gamepad_active && g.NavInputSource != ImGuiInputSource_Gamepad) | ||||
|     { | ||||
|         if (io.NavInputs[ImGuiNavInput_Activate] > 0.0f || io.NavInputs[ImGuiNavInput_Input] > 0.0f || io.NavInputs[ImGuiNavInput_Cancel] > 0.0f || io.NavInputs[ImGuiNavInput_Menu] > 0.0f | ||||
|             || io.NavInputs[ImGuiNavInput_DpadLeft] > 0.0f || io.NavInputs[ImGuiNavInput_DpadRight] > 0.0f || io.NavInputs[ImGuiNavInput_DpadUp] > 0.0f || io.NavInputs[ImGuiNavInput_DpadDown] > 0.0f) | ||||
|             g.NavInputSource = ImGuiInputSource_NavGamepad; | ||||
|             g.NavInputSource = ImGuiInputSource_Gamepad; | ||||
|     } | ||||
|  | ||||
|     // Update Keyboard->Nav inputs mapping | ||||
|     if (nav_keyboard_active) | ||||
|     { | ||||
|         #define NAV_MAP_KEY(_KEY, _NAV_INPUT)  do { if (IsKeyDown(io.KeyMap[_KEY])) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0) | ||||
|         #define NAV_MAP_KEY(_KEY, _NAV_INPUT)  do { if (IsKeyDown(io.KeyMap[_KEY])) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_Keyboard; } } while (0) | ||||
|         NAV_MAP_KEY(ImGuiKey_Space,     ImGuiNavInput_Activate ); | ||||
|         NAV_MAP_KEY(ImGuiKey_Enter,     ImGuiNavInput_Input    ); | ||||
|         NAV_MAP_KEY(ImGuiKey_Escape,    ImGuiNavInput_Cancel   ); | ||||
| @@ -9155,7 +9155,7 @@ static void ImGui::NavUpdate() | ||||
|     // When using gamepad, we project the reference nav bounding box into window visible area. | ||||
|     // This is to allow resuming navigation inside the visible area after doing a large amount of scrolling, since with gamepad every movements are relative | ||||
|     // (can't focus a visible object like we can with the mouse). | ||||
|     if (g.NavMoveRequest && g.NavInputSource == ImGuiInputSource_NavGamepad && g.NavLayer == ImGuiNavLayer_Main) | ||||
|     if (g.NavMoveRequest && g.NavInputSource == ImGuiInputSource_Gamepad && g.NavLayer == ImGuiNavLayer_Main) | ||||
|     { | ||||
|         ImGuiWindow* window = g.NavWindow; | ||||
|         ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1, 1), window->InnerRect.Max - window->Pos + ImVec2(1, 1)); | ||||
| @@ -9471,12 +9471,12 @@ static void ImGui::NavUpdateWindowing() | ||||
|             g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // FIXME-DOCK: Will need to use RootWindowDockStop | ||||
|             g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; | ||||
|             g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true; | ||||
|             g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad; | ||||
|             g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad; | ||||
|         } | ||||
|  | ||||
|     // Gamepad update | ||||
|     g.NavWindowingTimer += g.IO.DeltaTime; | ||||
|     if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad) | ||||
|     if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_Gamepad) | ||||
|     { | ||||
|         // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise | ||||
|         g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); | ||||
| @@ -9502,7 +9502,7 @@ static void ImGui::NavUpdateWindowing() | ||||
|     } | ||||
|  | ||||
|     // Keyboard: Focus | ||||
|     if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard) | ||||
|     if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_Keyboard) | ||||
|     { | ||||
|         // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise | ||||
|         g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f | ||||
| @@ -9524,9 +9524,9 @@ static void ImGui::NavUpdateWindowing() | ||||
|     if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove)) | ||||
|     { | ||||
|         ImVec2 move_delta; | ||||
|         if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift) | ||||
|         if (g.NavInputSource == ImGuiInputSource_Keyboard && !g.IO.KeyShift) | ||||
|             move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); | ||||
|         if (g.NavInputSource == ImGuiInputSource_NavGamepad) | ||||
|         if (g.NavInputSource == ImGuiInputSource_Gamepad) | ||||
|             move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down); | ||||
|         if (move_delta.x != 0.0f || move_delta.y != 0.0f) | ||||
|         { | ||||
|   | ||||
| @@ -818,9 +818,9 @@ enum ImGuiInputSource | ||||
| { | ||||
|     ImGuiInputSource_None = 0, | ||||
|     ImGuiInputSource_Mouse, | ||||
|     ImGuiInputSource_Nav, | ||||
|     ImGuiInputSource_NavKeyboard,   // Only used occasionally for storage, not tested/handled by most code | ||||
|     ImGuiInputSource_NavGamepad,    // " | ||||
|     ImGuiInputSource_Keyboard, | ||||
|     ImGuiInputSource_Gamepad, | ||||
|     ImGuiInputSource_Nav,               // Stored in g.ActiveIdSource only | ||||
|     ImGuiInputSource_COUNT | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -3931,7 +3931,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ | ||||
|     const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code; | ||||
|  | ||||
|     const bool user_clicked = hovered && io.MouseClicked[0]; | ||||
|     const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_NavKeyboard)); | ||||
|     const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_Keyboard)); | ||||
|     const bool user_scroll_finish = is_multiline && state != NULL && g.ActiveId == 0 && g.ActiveIdPreviousFrame == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); | ||||
|     const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ocornut
					ocornut