mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 22:26:34 +00:00
Renamed ImGuiNavFlags io.NavFlags to ImGuiConfigFlags io.ConfigFlags. (#787)
This commit is contained in:
parent
fc3c3de70d
commit
d98a5d54aa
@ -66,11 +66,11 @@ Other Changes:
|
||||
- Navigation: merged in the gamepad/keyboard navigation (about one million changes!). (#787, #323)
|
||||
The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
|
||||
- To use Keyboard Navigation:
|
||||
- Set io.NavFlags |= ImGuiNavFlags_EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
|
||||
- When keyboard navigation is active (io.NavActive + NavFlags_EnableKeyboard), the io.WantCaptureKeyboard flag will be set.
|
||||
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
|
||||
- When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag will be set.
|
||||
For more advanced uses, you may want to read from io.NavActive or io.NavVisible. Read imgui.cpp for more details.
|
||||
- To use Gamepad Navigation:
|
||||
- Set io.NavFlags |= ImGuiNavFlags_EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||
- See https://github.com/ocornut/imgui/issues/1599 for recommended gamepad mapping.
|
||||
- See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. Read imgui.cpp for more details.
|
||||
- Navigation: SetItemDefaultFocus() sets the navigation position in addition to scrolling. (#787)
|
||||
@ -78,7 +78,7 @@ Other Changes:
|
||||
- Navigation: Added window flags: ImGuiWindowFlags_NoNav (ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus).
|
||||
- Navigation: Style: Added ImGuiCol_NavHighlight, ImGuiCol_NavWindowingHighlight colors. (#787)
|
||||
- Navigation: TreeNode: Added ImGuiTreeNodeFlags_NavLeftJumpsBackHere flag to allow Nav Left direction to jump back to parent tree node from any of its child. (#1079)
|
||||
- Navigation: IO: Added io.NavFlags (input), io.NavActive (output), io.NavVisible (output). (#787)
|
||||
- Navigation: IO: Added io.ConfigFlags (input), io.NavActive (output), io.NavVisible (output). (#787)
|
||||
- Context: Removed the default global context and font atlas instances, which caused various problems to users of multiple contexts and DLL users. (#1565)
|
||||
YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. Existing apps will assert/crash without it.
|
||||
- Context: Removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions() and shared by all contexts. (#1565, #586, #992, #1007, #1558)
|
||||
|
@ -248,7 +248,7 @@ See the FAQ in imgui.cpp for answers.
|
||||
|
||||
<b>How do you use Dear ImGui on a platform that may not have a mouse or keyboard?</b>
|
||||
|
||||
You can control Dear ImGui with a gamepad, see the explanation in imgui.cpp about how to use the navigation feature (short version: map your gamepad inputs into the `io.NavInputs[]` array and set `io.NavFlags |= ImGuiNavFlags_EnableGamepad`).
|
||||
You can control Dear ImGui with a gamepad, see the explanation in imgui.cpp about how to use the navigation feature (short version: map your gamepad inputs into the `io.NavInputs[]` array and set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad`).
|
||||
|
||||
You can share your computer mouse seamlessy with your console/tablet/phone using [Synergy](http://synergy-project.org). This is the prefered solution for developer productivity. In particular, their [micro-synergy-client](https://github.com/symless/micro-synergy-client) repo there is _uSynergy.c_ sources for a small embeddable that you can use on any platform to connect to your host PC. You may also use a third party solution such as [Remote ImGui](https://github.com/JordiRos/remoteimgui).
|
||||
|
||||
|
@ -25,8 +25,8 @@ int main(int, char**)
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_ImplAllegro5_Init(display);
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
|
@ -116,7 +116,7 @@ int main(int, char**)
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_MultiViewports;
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX10_Init(g_pd3dDevice);
|
||||
|
@ -117,9 +117,9 @@ int main(int, char**)
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.NavFlags |= ImGuiNavFlags_EnableKeyboard;
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_MultiViewports;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||
|
@ -290,7 +290,7 @@ int main(int, char**)
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_MultiViewports;
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT, DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
|
@ -78,9 +78,9 @@ int main(int, char**)
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX9_Init(g_pd3dDevice);
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
|
@ -3,7 +3,7 @@
|
||||
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Gamepad navigation mapping. Enable with 'io.NavFlags |= ImGuiNavFlags_EnableGamepad'.
|
||||
// [X] Gamepad navigation mapping. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||
@ -16,8 +16,8 @@
|
||||
// 2018-XX-XX: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-01-25: Inputs: Added gamepad support if ImGuiNavFlags_EnableGamepad is set.
|
||||
// 2018-01-25: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse by using navigation and ImGuiNavFlags_MoveMouse is set.
|
||||
// 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set.
|
||||
// 2018-01-25: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
|
||||
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
|
||||
// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
|
||||
// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
|
||||
@ -241,7 +241,7 @@ void ImGui_ImplGlfw_NewFrame()
|
||||
|
||||
// Gamepad navigation mapping [BETA]
|
||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||
if (io.NavFlags & ImGuiNavFlags_EnableGamepad)
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad)
|
||||
{
|
||||
// Update gamepad inputs
|
||||
#define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
|
||||
|
@ -3,7 +3,7 @@
|
||||
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Gamepad navigation mapping. Enable with 'io.NavFlags |= ImGuiNavFlags_EnableGamepad'.
|
||||
// [X] Gamepad navigation mapping. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||
|
@ -13,7 +13,7 @@
|
||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformInterface
|
||||
// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-02-06: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse by using navigation and ImGuiNavFlags_MoveMouse is set.
|
||||
// 2018-02-06: Inputs: Honoring the io.WantMoveMouse by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
|
||||
// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert.
|
||||
|
@ -19,8 +19,8 @@ int main(int, char**)
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_Marmalade_Init(true);
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
|
@ -30,9 +30,9 @@ int main(int, char**)
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_ImplGlfw_Init(window, true);
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
|
@ -34,11 +34,10 @@ int main(int, char**)
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_MultiViewports;
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
ImGui_ImplGlfw_Init(window, true);
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
|
||||
|
@ -37,9 +37,10 @@ int main(int, char**)
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
ImGui_ImplSDL2_Init(window, gl_context);
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
|
@ -38,7 +38,7 @@ int main(int, char**)
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_MultiViewports;
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
ImGui_ImplSDL2_Init(window, gl_context);
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
|
@ -612,8 +612,6 @@ int main(int, char**)
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard;
|
||||
|
||||
ImGui_ImplVulkan_InitData init_data = {};
|
||||
init_data.allocator = g_Allocator;
|
||||
@ -623,6 +621,9 @@ int main(int, char**)
|
||||
init_data.pipeline_cache = g_PipelineCache;
|
||||
init_data.descriptor_pool = g_DescriptorPool;
|
||||
init_data.check_vk_result = check_vk_result;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_ImplVulkan_Init(&init_data);
|
||||
ImGui_ImplSDL2_Init(window, NULL);
|
||||
|
||||
|
@ -615,7 +615,7 @@ int main(int, char**)
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
|
||||
ImGui_ImplVulkan_InitData init_data = {};
|
||||
init_data.allocator = g_Allocator;
|
||||
init_data.gpu = g_Gpu;
|
||||
@ -624,9 +624,11 @@ int main(int, char**)
|
||||
init_data.pipeline_cache = g_PipelineCache;
|
||||
init_data.descriptor_pool = g_DescriptorPool;
|
||||
init_data.check_vk_result = check_vk_result;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_ImplVulkan_Init(&init_data);
|
||||
ImGui_ImplGlfw_Init(window, true);
|
||||
//io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
|
27
imgui.cpp
27
imgui.cpp
@ -216,15 +216,15 @@
|
||||
- Ask questions and report issues at https://github.com/ocornut/imgui/issues/787
|
||||
- The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
|
||||
- Keyboard:
|
||||
- Set io.NavFlags |= ImGuiNavFlags_EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
|
||||
- When keyboard navigation is active (io.NavActive + NavFlags_EnableKeyboard), the io.WantCaptureKeyboard flag will be set.
|
||||
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
|
||||
- When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag will be set.
|
||||
For more advanced uses, you may want to read from:
|
||||
- io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set.
|
||||
- io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used).
|
||||
- or query focus information with e.g. IsWindowFocused(), IsItemFocused() etc. functions.
|
||||
Please reach out if you think the game vs navigation input sharing could be improved.
|
||||
- Gamepad:
|
||||
- Set io.NavFlags |= ImGuiNavFlags_EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||
- See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values:
|
||||
0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks.
|
||||
- We uses a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone.
|
||||
@ -234,11 +234,11 @@
|
||||
- Mouse:
|
||||
- PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
|
||||
- Consoles/Tablet/Phone users: Consider using Synergy host (on your computer) + uSynergy.c (in your console/tablet/phone app) to use your PC mouse/keyboard.
|
||||
- On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiNavFlags_MoveMouse flag in io.NavFlags.
|
||||
Enabling ImGuiNavFlags_MoveMouse instructs dear imgui to move your mouse cursor along with navigation movements.
|
||||
- On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavMoveMouse flag.
|
||||
Enabling ImGuiConfigFlags_NavMoveMouse instructs dear imgui to move your mouse cursor along with navigation movements.
|
||||
When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantMoveMouse' to notify you that it wants the mouse cursor to be moved.
|
||||
When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that.
|
||||
(If you set the ImGuiNavFlags_MoveMouse flag but don't honor 'io.WantMoveMouse' properly, imgui will misbehave as it will see your mouse as moving back and forth.)
|
||||
(If you set the NavMoveMouse flag but don't honor 'io.WantMoveMouse' properly, imgui will misbehave as it will see your mouse as moving back and forth!)
|
||||
(In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want
|
||||
to set a boolean to ignore your other external mouse positions until the external source is moved again.)
|
||||
|
||||
@ -859,7 +859,6 @@ ImGuiIO::ImGuiIO()
|
||||
DisplaySize = ImVec2(-1.0f, -1.0f);
|
||||
DeltaTime = 1.0f/60.0f;
|
||||
ConfigFlags = 0x00;
|
||||
NavFlags = 0x00;
|
||||
IniSavingRate = 5.0f;
|
||||
IniFilename = "imgui.ini";
|
||||
LogFilename = "imgui_log.txt";
|
||||
@ -2834,7 +2833,7 @@ static void ImGui::NavUpdateWindowing()
|
||||
bool apply_toggle_layer = false;
|
||||
|
||||
bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
|
||||
bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.NavFlags & ImGuiNavFlags_EnableKeyboard);
|
||||
bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
|
||||
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
||||
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavigable(g.Windows.Size - 1, -INT_MAX, -1))
|
||||
{
|
||||
@ -2989,7 +2988,7 @@ static void ImGui::NavUpdate()
|
||||
|
||||
// Update Keyboard->Nav inputs mapping
|
||||
memset(g.IO.NavInputs + ImGuiNavInput_InternalStart_, 0, (ImGuiNavInput_COUNT - ImGuiNavInput_InternalStart_) * sizeof(g.IO.NavInputs[0]));
|
||||
if (g.IO.NavFlags & ImGuiNavFlags_EnableKeyboard)
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
|
||||
{
|
||||
#define NAV_MAP_KEY(_KEY, _NAV_INPUT) if (g.IO.KeyMap[_KEY] != -1 && IsKeyDown(g.IO.KeyMap[_KEY])) g.IO.NavInputs[_NAV_INPUT] = 1.0f;
|
||||
NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
|
||||
@ -3061,7 +3060,7 @@ static void ImGui::NavUpdate()
|
||||
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
||||
{
|
||||
// Set mouse position given our knowledge of the nav widget position from last frame
|
||||
if (g.IO.NavFlags & ImGuiNavFlags_MoveMouse)
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavMoveMouse)
|
||||
{
|
||||
g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredMousePos();
|
||||
g.IO.WantMoveMouse = true;
|
||||
@ -3081,7 +3080,7 @@ static void ImGui::NavUpdate()
|
||||
NavUpdateWindowing();
|
||||
|
||||
// Set output flags for user application
|
||||
g.IO.NavActive = (g.IO.NavFlags & (ImGuiNavFlags_EnableGamepad | ImGuiNavFlags_EnableKeyboard)) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
|
||||
g.IO.NavActive = (g.IO.ConfigFlags & (ImGuiConfigFlags_NavEnableGamepad | ImGuiConfigFlags_NavEnableKeyboard)) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
|
||||
g.IO.NavVisible = (g.IO.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL) || g.NavInitRequest;
|
||||
|
||||
// Process NavCancel input (to close a popup, get back to parent, clear focus)
|
||||
@ -3544,7 +3543,7 @@ void ImGui::NewFrame()
|
||||
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
||||
|
||||
// Do a simple check for required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was super recently added in 1.60 WIP)
|
||||
if (g.IO.NavFlags & ImGuiNavFlags_EnableKeyboard)
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
|
||||
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
||||
|
||||
if (g.IO.ConfigFlags & ImGuiConfigFlags_MultiViewports)
|
||||
@ -3728,7 +3727,7 @@ void ImGui::NewFrame()
|
||||
g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
|
||||
else
|
||||
g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
|
||||
if (g.IO.NavActive && (g.IO.NavFlags & ImGuiNavFlags_EnableKeyboard) && !(g.IO.NavFlags & ImGuiNavFlags_NoCaptureKeyboard))
|
||||
if (g.IO.NavActive && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
|
||||
g.IO.WantCaptureKeyboard = true;
|
||||
|
||||
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : 0;
|
||||
@ -6421,7 +6420,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
float sc = g.Style.MouseCursorScale;
|
||||
ImVec2 ref_pos = (!g.NavDisableHighlight && g.NavDisableMouseHover) ? NavCalcPreferredMousePos() : g.IO.MousePos;
|
||||
ImRect rect_to_avoid;
|
||||
if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.NavFlags & ImGuiNavFlags_MoveMouse))
|
||||
if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavMoveMouse))
|
||||
rect_to_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
|
||||
else
|
||||
rect_to_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
|
||||
|
47
imgui.h
47
imgui.h
@ -98,7 +98,6 @@ typedef int ImGuiComboFlags; // flags: for BeginCombo()
|
||||
typedef int ImGuiFocusedFlags; // flags: for IsWindowFocused() // enum ImGuiFocusedFlags_
|
||||
typedef int ImGuiHoveredFlags; // flags: for IsItemHovered() etc. // enum ImGuiHoveredFlags_
|
||||
typedef int ImGuiInputTextFlags; // flags: for InputText*() // enum ImGuiInputTextFlags_
|
||||
typedef int ImGuiNavFlags; // flags: for io.NavFlags // enum ImGuiNavFlags_
|
||||
typedef int ImGuiSelectableFlags; // flags: for Selectable() // enum ImGuiSelectableFlags_
|
||||
typedef int ImGuiTreeNodeFlags; // flags: for TreeNode*(),CollapsingHeader()// enum ImGuiTreeNodeFlags_
|
||||
typedef int ImGuiWindowFlags; // flags: for Begin*() // enum ImGuiWindowFlags_
|
||||
@ -719,8 +718,8 @@ enum ImGuiKey_
|
||||
};
|
||||
|
||||
// [BETA] Gamepad/Keyboard directional navigation
|
||||
// Keyboard: Set io.NavFlags |= ImGuiNavFlags_EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
|
||||
// Gamepad: Set io.NavFlags |= ImGuiNavFlags_EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_EnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeyDown[] + io.KeyMap[] arrays.
|
||||
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_EnableGamepad to enable. Fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
|
||||
// Read instructions in imgui.cpp for more details.
|
||||
enum ImGuiNavInput_
|
||||
{
|
||||
@ -753,13 +752,25 @@ enum ImGuiNavInput_
|
||||
ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyMenu_
|
||||
};
|
||||
|
||||
// [BETA] Gamepad/Keyboard directional navigation flags, stored in io.NavFlags
|
||||
enum ImGuiNavFlags_
|
||||
// Configuration flags stored in io.ConfigFlags
|
||||
enum ImGuiConfigFlags_
|
||||
{
|
||||
ImGuiNavFlags_EnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeyDown[].
|
||||
ImGuiNavFlags_EnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[].
|
||||
ImGuiNavFlags_MoveMouse = 1 << 2, // Request navigation to allow moving the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantMoveMouse=true. If enabled you MUST honor io.WantMoveMouse requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth.
|
||||
ImGuiNavFlags_NoCaptureKeyboard = 1 << 3 // Do not set the io.WantCaptureKeyboard flag with io.NavActive is set.
|
||||
// Navigation
|
||||
ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeyDown[].
|
||||
ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui back-end to fill io.NavInputs[].
|
||||
ImGuiConfigFlags_NavMoveMouse = 1 << 2, // Request navigation to allow moving the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantMoveMouse=true. If enabled you MUST honor io.WantMoveMouse requests in your binding, otherwise ImGui will react as if the mouse is jumping around back and forth.
|
||||
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Do not set the io.WantCaptureKeyboard flag with io.NavActive is set.
|
||||
|
||||
// [BETA] Viewports
|
||||
ImGuiConfigFlags_MultiViewports = 1 << 4, // User enable multiple viewports (require io.PlatformInterface + io.RendererInterface)
|
||||
ImGuiConfigFlags_PlatformHasMouseHoveredViewport = 1 << 5, // Back-end knows how to set io.MouseHoveredViewport to the viewport directly under the mouse _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag and _REGARDLESS_ of whether another viewport is focused and may have mouse capture. This info is not easy to provide correctly with most high-level engines.
|
||||
ImGuiConfigFlags_PlatformHasWantMoveMouseSupport = 1 << 6, // Back-end honors io.WantMoveMouse request by updating the OS mouse cursor position (currently only used by ImGuiConfigFlags_NavMoveMouse feature, will be useful for widgets teleporting/wrapping the cursor)
|
||||
ImGuiConfigFlags_PlatformHasWindowAlpha = 1 << 7, // Back-end can have transparent windows
|
||||
|
||||
// Platform Info (strictly for the user/application)
|
||||
ImGuiConfigFlags_IsSRGB = 1 << 10, // Back-end is SRGB-aware (Storage flag to allow your back-end to communicate to shared widgets. Not used by core ImGui)
|
||||
ImGuiConfigFlags_IsTouchScreen = 1 << 11, // Back-end is using a touch screen instead of a mouse (Storage flag to allow your back-end to communicate to shared widgets. Not used by core ImGui)
|
||||
ImGuiConfigFlags_IsOnScreenKeyboard = 1 << 12 // Back-end uses an on-screen keyboard when io.WantTextInput is set.
|
||||
};
|
||||
|
||||
// Enumeration for PushStyleColor() / PopStyleColor()
|
||||
@ -913,19 +924,6 @@ enum ImGuiCond_
|
||||
#endif
|
||||
};
|
||||
|
||||
// [BETA] Configuration flags, mostly setup by imgui back-end, stored in io.ConfigFlags
|
||||
enum ImGuiConfigFlags_
|
||||
{
|
||||
ImGuiConfigFlags_MultiViewports = 1 << 0, // User enable multiple viewports (require io.PlatformInterface + io.RendererInterface)
|
||||
ImGuiConfigFlags_PlatformHasMouseHoveredViewport = 1 << 1, // Back-end knows how to set io.MouseHoveredViewport to the viewport directly under the mouse _IGNORING_ viewports with the ImGuiViewportFlags_NoInputs flag and _REGARDLESS_ of whether another viewport is focused and may have mouse capture. This info is not easy to provide correctly with most high-level engines.
|
||||
ImGuiConfigFlags_PlatformHasWantMoveMouseSupport = 1 << 2, // Back-end honors io.WantMoveMouse request by updating the OS mouse cursor position (currently only used by ImGuiNavFlags_MoveMouse feature, will be useful for widgets teleporting/wrapping the cursor)
|
||||
ImGuiConfigFlags_PlatformHasWindowAlpha = 1 << 3, // Back-end can have transparent windows
|
||||
|
||||
ImGuiConfigFlags_IsSRGB = 1 << 10, // Back-end is SRGB-aware (Storage flag to allow your back-end to communicate to shared widgets. Not used by core ImGui)
|
||||
ImGuiConfigFlags_IsTouchScreen = 1 << 11, // Back-end is using a touch screen instead of a mouse (Storage flag to allow your back-end to communicate to shared widgets. Not used by core ImGui)
|
||||
ImGuiConfigFlags_IsOnScreenKeyboard = 1 << 12 // Back-end uses an on-screen keyboard when io.WantTextInput is set.
|
||||
};
|
||||
|
||||
// (Optional) Setup required only if (io.ConfigFlags & ImGuiConfigFlags_EnableMultiViewport) is enabled
|
||||
struct ImGuiPlatformInterface
|
||||
{
|
||||
@ -1002,8 +1000,7 @@ struct ImGuiIO
|
||||
|
||||
ImVec2 DisplaySize; // <unset> // Main display size. Used e.g. to clamp windows positions. This is the default viewport. Use BeginViewport() for other viewports.
|
||||
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
|
||||
ImGuiConfigFlags ConfigFlags; // = 0 // Set ImGuiConfigFlags_. Features/options flags for ImGui back-ends.
|
||||
ImGuiNavFlags NavFlags; // = 0x00 // See ImGuiNavFlags_. Gamepad/keyboard navigation options.
|
||||
ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Back-end options, Gamepad/keyboard navigation options, etc.
|
||||
float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds.
|
||||
const char* IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving.
|
||||
const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
|
||||
@ -1082,7 +1079,7 @@ struct ImGuiIO
|
||||
bool WantCaptureMouse; // When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. This is set by ImGui when it wants to use your mouse (e.g. unclicked mouse is hovering a window, or a widget is active).
|
||||
bool WantCaptureKeyboard; // When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. This is set by ImGui when it wants to use your keyboard inputs.
|
||||
bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
|
||||
bool WantMoveMouse; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiNavFlags_MoveMouse flag is enabled in io.NavFlags.
|
||||
bool WantMoveMouse; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavMoveMouse flag is enabled.
|
||||
bool NavActive; // Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
|
||||
bool NavVisible; // Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
|
||||
float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
|
||||
|
@ -1806,9 +1806,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
|
||||
ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor);
|
||||
ImGui::SameLine(); ShowHelpMarker("Request ImGui to render a mouse cursor for you in software. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).");
|
||||
ImGui::CheckboxFlags("io.NavFlags: EnableGamepad", (unsigned int *)&io.NavFlags, ImGuiNavFlags_EnableGamepad);
|
||||
ImGui::CheckboxFlags("io.NavFlags: EnableKeyboard", (unsigned int *)&io.NavFlags, ImGuiNavFlags_EnableKeyboard);
|
||||
ImGui::CheckboxFlags("io.NavFlags: MoveMouse", (unsigned int *)&io.NavFlags, ImGuiNavFlags_MoveMouse);
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad);
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard);
|
||||
ImGui::CheckboxFlags("io.ConfigFlags: NavMoveMouse", (unsigned int *)&io.ConfigFlags, ImGuiConfigFlags_NavMoveMouse);
|
||||
ImGui::SameLine(); ShowHelpMarker("Request ImGui to move your move cursor when using gamepad/keyboard navigation. NewFrame() will change io.MousePos and set the io.WantMoveMouse flag, your backend will need to apply the new mouse position.");
|
||||
|
||||
if (ImGui::TreeNode("Keyboard, Mouse & Navigation State"))
|
||||
|
@ -683,8 +683,8 @@ struct ImGuiContext
|
||||
int NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later.
|
||||
int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing
|
||||
bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid
|
||||
bool NavMousePosDirty; // When set we will update mouse position if (NavFlags & ImGuiNavFlags_MoveMouse) if set (NB: this not enabled by default)
|
||||
bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (nb: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
|
||||
bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavMoveMouse) if set (NB: this not enabled by default)
|
||||
bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover)
|
||||
bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again.
|
||||
bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest
|
||||
bool NavInitRequest; // Init request for appearing window to select first item
|
||||
|
Loading…
Reference in New Issue
Block a user