Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New IO keyboard/mouse/gamepad event API (1.87) recap #4921

Closed
ocornut opened this issue Jan 20, 2022 · 40 comments
Closed

New IO keyboard/mouse/gamepad event API (1.87) recap #4921

ocornut opened this issue Jan 20, 2022 · 40 comments

Comments

@ocornut
Copy link
Owner

ocornut commented Jan 20, 2022

EDIT 2022/11/15: Dear ImGui 1.89 made ImGuiKey a strongly-typed enum, which broke backward compatibility with using legacy backend-specific indices (e.g. IsKeyPressed(GLFW_KEY_A) needs casting IsKeyPressing((ImGuiKey)GLFW_KEY_A). I am not entirely sure this was the right decision as this is unusually breaking, but fix is trivial and should encourage moving to new API so leaving the strongly-typed enum for now.


EDIT 2022/02/29: We discovered a backward-compatibility regression in 18700:

  • Direct legacy reads from io.KeysDown[] won't work with new backends.
  • And in particular io.KeysDown[GetKeyIndex[XXX]) will buffer overflow in old and new backends.
    Reads via IsKeyDown() function are always working, this only affect direct array access This was fixed in 18708 (commit 5659db5)

(This is a followup on #4858 now that things have settled)

We (@thedmd @ocornut) have completely revamped IO API in 1.87 (the way backend communicate with dear imgui to submit inputs)

All backends have been updated to use new API.

Both user code and old backends should be backward compatible (apart from a few rare edge cases) but we encourage you to transition.

Additions:

  • New functions: io.AddKeyEvent(), io.AddKeyAnalogEvent(), io.AddKeyModsEvent() removed jan 27, io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent(), io.SetKeyEventNativeData() (for legacy support).
  • New enums: ImGuiKey now contains a full keyset (e.g. ImGuiKey_F1) this allow using full range of keyboard inputs in a portable manner, which was previously impossible as we encouraged use of native indices. This will make it easier for people to share code/extensions publicly or across multiple codebases.
  • New enums: ImGuiKey also contains gamepad axises/buttons ImGuiKey_GamepadDpadUp) unifying input sources.
  • Input queue now trickle conflicting inputs over multiple frames (unless io.ConfigInputTrickleEventQueue == false) which massively improve input experience with low framerate.
  • Both SDL and GLFW backends have been fixed to submit translated keys, so ImGuiKey_A will be submitted when pressing the key which user would need to press to emit an "A" character, allowing for translated shortcuts.

Those changes will constitute the bulk of 1.87.
If you want to help, please upgrade today :)

Transition Guide

If you are using a standard backend (RECOMMENDED) just update it to latest!
If you have are using a custom backend:

Keyboard:

  • Backend writing to io.KeyMap[], io.KeysDown[] -> backend should call io.AddKeyEvent()
  • If your backend now call io.AddKeyEvent() and you want legacy user code to still work with legacy indices, also call io.SetKeyEventNativeData().
  • User code calling IsKeyPressed(MY_NATIVE_KEY_XXX) -> call IsKeyPressed(ImGuiKey_XXX) (OLD CODE WILL STILL WORK*)
  • User code calling IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) -> call IsKeyPressed(ImGuiKey_XXX) (OLD CODE WILL STILL WORK*)
  • All keyboard related functions taking int user_key_index now take ImGuiKey key: IsKeyDown(), IsKeyPressed(), IsKeyReleased(), GetKeyPressedAmount().
  • Basically the trick we took advantage of is that we previously only supported native keycode from 0 to 511, so ImGuiKey values can still express a legacy native keycode, and new named keys are all >= 512. Luckily that old constraint allowed us to save the day!
  • Added GetKeyName() helper function.
  • Obsoleted GetKeyIndex(): it is now unnecessary and will now return the same value.
  • For all new calls to IO functions, the Dear ImGui context should be bound/current.

(* until IMGUI_DISABLE_OBSOLETE_KEYIO is set. In a few versions, IMGUI_DISABLE_OBSOLETE_FUNCTIONS will automatically set it)
(since 1.90, defining IMGUI_DISABLE_OBSOLETE_FUNCTIONS automatically defines IMGUI_DISABLE_OBSOLETE_KEYIO.)
(* and unless the backend forgot to call io.SetKeyEventNativeData())

Mouse:

  • Backend writing to io.MousePos -> backend should call io.AddMousePosEvent()
  • Backend writing to io.MouseDown[] -> backend should call io.AddMouseButtonEvent()
  • Backend writing to io.MouseWheel, io.MouseWheelH -> backend should call io.AddMouseWheelEvent()
  • (Docking Branch w/ Multi-viewports) Backend writing to io.MouseHoveredViewport-> backend should call io.AddMouseViewportEvent()
  • For all new calls to IO functions, the Dear ImGui context should be bound/current.

Gamepad/Nav:

  • Backend writing to io.NavInputs[] -> backend should call io.AddKeyEvent()/io.AddKeyAnalogEvent() with ImGuiKey_GamepadXXX values.

What is input queue trickling?

TL;DR; if you submit "Key A went down, then went up, then went down, then went up" during the same Dear ImGui frame, previously events would be missed and it was the application/backend responsibility to submit those events wisely. We moved that responsibility to the core library now. Because most of Dear ImGui code and widgets are reading inputs levels (rather than events), we spread those events over multiple frames when necessary. This makes dear imgui easier to use at low framerate (e.g. 10 FPS).

Backends polling inputs vs handling events

One gotcha is that if you submit events it is preferable to submit then in the right order.
If you transition to new API make sure you are submitting events in the order they come from your OS / platform layer. Normally this should be the default. But because we are punks, our old backends had a tendency to be polling some input state instead of reacting to events, which effectively "lost" their order (e.g. which have changed first, Mouse Position or Mouse Button state?). We have now transitioned all standard backends to be reacting on events rather than polling. If you used your own backend maybe you already behaved better.

Demo

You can see pressed keys in the demo + drawing a small section of a keyboard for no other reason that it being fun.
image

Reference changes (e.g. to platform backends)

ALWAYS REFER TO FINAL VERSION AS SOME MINOR STUFF MAY HAVE BEEN RENAMED/CHANGED SINCE THE INTERMEDIARY COMMITS. Those references commits are here to help understanding what changed, if you need to update a custom backend.

Core lib

  • Core: Rename ImGuiKey_KeyPadEnter > ImGuiKey_KeypadEnter (afffcd5)
  • Core: Add extra keys, io.AddKeyEvent() and more (3b66929, bf08c13)
  • Core: Add io.AddKeyModsEvent() and updated all Backends accordingly. (790132a, e8172fd)
  • Core: Add AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() api + updated all Backends. (b8e56dc)
  • Core: Add Input Queue with automatic trickling of fast events. (7374b96, 90a6961, 7ad42ff)
  • Core: Add AddKeyAnalogEvent() and support for ImGuiKey_GamepadXXXX. (f33bb99)

Win32 backend

  • Win32: update to use io.AddKeyEvent(), add full key map (746c9f7)
  • Win32: maintain MouseButtonsDown mask instead of using IsAnyMouseDown() which will be obsoleted (7f8a89c)
  • Win32: reorganize to update mouse inputs using WM_MOUSEMOVE/WM_MOUSELEAVE instead of polling so we can submit events in the right order + fallback to provide it when focused but not hovered/captured + update MousePos before Key Modifiers (bf4de2a)
  • Win32: update to use AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent(). (b8e56dc)
  • Win32: add full gamepad support using io.AddKeyEvent(), io.AddKeyAnalogEvent(), stopped writing to io.NavInputs[]. (9f8c599)

GLFW backend

  • GLFW: submitting translated keys (100ede5)
  • GLFW: update to use io.AddKeyEvent(), add full key map (ecd212c)
  • GLFW: reorganize to update mouse inputs using glfwSetCursorPosCallback() (breaking if user install their callback themselves) instead of polling so we can submit events in the right order + fallback to provide it when focused but not hovered/captured + update MousePos before MouseButtons. (200a8f1)
  • GLFW: update to use AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent(). (b8e56dc)
  • GLFW: add full gamepad support using io.AddKeyEvent(), io.AddKeyAnalogEvent(), stopped writing to io.NavInputs[]. (3d85433)

SDL backend

  • SDL: update to use io.AddKeyEvent(), add full key map (fe646ea)
  • SDL: maintain MouseButtonsDown mask instead of using IsAnyMouseDown() which will be obsoleted (7f8a89c)
  • SDL: reorganize to update mouse inputs using SDL_MOUSEMOTION/SDL_WINDOWEVENT_LEAVE instead of polling so we can submit events in the right order + fallback to provide it when focused but not hovered/captured + update MousePos before MouseButtons (98ce013).
  • SDL: update to use AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent(). (b8e56dc)
  • SDL: add full gamepad support using io.AddKeyEvent(), io.AddKeyAnalogEvent(), stopped writing to io.NavInputs[]. (39c3412)

Other backends

  • OSX: update to use io.AddKeyEvent(), add full key map (ee436aa)
  • OSX: add full gamepad support using io.AddKeyEvent(), io.AddKeyAnalogEvent(), stopped writing to io.NavInputs[]. (5ea47d9)
  • Android: update to use io.AddKeyEvent(), add full key map (1797135)
  • Allegro: update to use io.AddKeyEvent(), add full key map (1bfe4a7)
  • GLUT: update to use io.AddKeyEvent(), add full key map (da1864d)

List of keys

ImGuiKey_None = 0,
ImGuiKey_Tab = 512,             // == ImGuiKey_NamedKey_BEGIN
ImGuiKey_LeftArrow,
ImGuiKey_RightArrow,
ImGuiKey_UpArrow,
ImGuiKey_DownArrow,
ImGuiKey_PageUp,
ImGuiKey_PageDown,
ImGuiKey_Home,
ImGuiKey_End,
ImGuiKey_Insert,
ImGuiKey_Delete,
ImGuiKey_Backspace,
ImGuiKey_Space,
ImGuiKey_Enter,
ImGuiKey_Escape,
ImGuiKey_LeftCtrl,
ImGuiKey_LeftShift,
ImGuiKey_LeftAlt,
ImGuiKey_LeftSuper,
ImGuiKey_RightCtrl,
ImGuiKey_RightShift,
ImGuiKey_RightAlt,
ImGuiKey_RightSuper,
ImGuiKey_Menu,
ImGuiKey_0,
ImGuiKey_1,
ImGuiKey_2,
ImGuiKey_3,
ImGuiKey_4,
ImGuiKey_5,
ImGuiKey_6,
ImGuiKey_7,
ImGuiKey_8,
ImGuiKey_9,
ImGuiKey_A,
ImGuiKey_B,
ImGuiKey_C,
ImGuiKey_D,
ImGuiKey_E,
ImGuiKey_F,
ImGuiKey_G,
ImGuiKey_H,
ImGuiKey_I,
ImGuiKey_J,
ImGuiKey_K,
ImGuiKey_L,
ImGuiKey_M,
ImGuiKey_N,
ImGuiKey_O,
ImGuiKey_P,
ImGuiKey_Q,
ImGuiKey_R,
ImGuiKey_S,
ImGuiKey_T,
ImGuiKey_U,
ImGuiKey_V,
ImGuiKey_W,
ImGuiKey_X,
ImGuiKey_Y,
ImGuiKey_Z,
ImGuiKey_F1,
ImGuiKey_F2,
ImGuiKey_F3,
ImGuiKey_F4,
ImGuiKey_F5,
ImGuiKey_F6,
ImGuiKey_F7,
ImGuiKey_F8,
ImGuiKey_F9,
ImGuiKey_F10,
ImGuiKey_F11,
ImGuiKey_F12,
ImGuiKey_F13, 
ImGuiKey_F14, 
ImGuiKey_F15, 
ImGuiKey_F16, 
ImGuiKey_F17, 
ImGuiKey_F18,
ImGuiKey_F19, 
ImGuiKey_F20, 
ImGuiKey_F21, 
ImGuiKey_F22, 
ImGuiKey_F23, 
ImGuiKey_F24,
ImGuiKey_Apostrophe,        // '
ImGuiKey_Comma,             // ,
ImGuiKey_Minus,             // -
ImGuiKey_Period,            // .
ImGuiKey_Slash,             // /
ImGuiKey_Semicolon,         // ;
ImGuiKey_Equal,             // =
ImGuiKey_LeftBracket,       // [
ImGuiKey_Backslash,         // \ (this text inhibit multiline comment caused by backslash)
ImGuiKey_RightBracket,      // ]
ImGuiKey_GraveAccent,       // `
ImGuiKey_CapsLock,
ImGuiKey_ScrollLock,
ImGuiKey_NumLock,
ImGuiKey_PrintScreen,
ImGuiKey_Pause,
ImGuiKey_Keypad0,
ImGuiKey_Keypad1,
ImGuiKey_Keypad2,
ImGuiKey_Keypad3,
ImGuiKey_Keypad4,
ImGuiKey_Keypad5,
ImGuiKey_Keypad6,
ImGuiKey_Keypad7,
ImGuiKey_Keypad8,
ImGuiKey_Keypad9,
ImGuiKey_KeypadDecimal,
ImGuiKey_KeypadDivide,
ImGuiKey_KeypadMultiply,
ImGuiKey_KeypadSubtract,
ImGuiKey_KeypadAdd,
ImGuiKey_KeypadEnter,
ImGuiKey_KeypadEqual,
ImGuiKey_AppBack,               // Available on some keyboard/mouses. Often referred as "Browser Back"
ImGuiKey_AppForward,

// Gamepad (some of those are expected to be analog values from 0.0f to 1.0f) ..............// NAVIGATION action
ImGuiKey_GamepadStart,          // Menu (Xbox)          + (Switch)      Start/Options (PS)  // --
ImGuiKey_GamepadBack,           // View (Xbox)          - (Switch)      Share (PS)          // --
ImGuiKey_GamepadFaceUp,         // Y (Xbox)             X (Switch)      Triangle (PS)       // -> ImGuiNavInput_Input
ImGuiKey_GamepadFaceDown,       // A (Xbox)             B (Switch)      Cross (PS)          // -> ImGuiNavInput_Activate
ImGuiKey_GamepadFaceLeft,       // X (Xbox)             Y (Switch)      Square (PS)         // -> ImGuiNavInput_Menu
ImGuiKey_GamepadFaceRight,      // B (Xbox)             A (Switch)      Circle (PS)         // -> ImGuiNavInput_Cancel
ImGuiKey_GamepadDpadUp,         // D-pad Up                                                 // -> ImGuiNavInput_DpadUp
ImGuiKey_GamepadDpadDown,       // D-pad Down                                               // -> ImGuiNavInput_DpadDown
ImGuiKey_GamepadDpadLeft,       // D-pad Left                                               // -> ImGuiNavInput_DpadLeft
ImGuiKey_GamepadDpadRight,      // D-pad Right                                              // -> ImGuiNavInput_DpadRight
ImGuiKey_GamepadL1,             // L Bumper (Xbox)      L (Switch)      L1 (PS)             // -> ImGuiNavInput_FocusPrev + ImGuiNavInput_TweakSlow
ImGuiKey_GamepadR1,             // R Bumper (Xbox)      R (Switch)      R1 (PS)             // -> ImGuiNavInput_FocusNext + ImGuiNavInput_TweakFast
ImGuiKey_GamepadL2,             // L Trigger (Xbox)     ZL (Switch)     L2 (PS) [Analog]
ImGuiKey_GamepadR2,             // R Trigger (Xbox)     ZR (Switch)     R2 (PS) [Analog]
ImGuiKey_GamepadL3,             // L Thumbstick (Xbox)  L3 (Switch)     L3 (PS)
ImGuiKey_GamepadR3,             // R Thumbstick (Xbox)  R3 (Switch)     R3 (PS)
ImGuiKey_GamepadLStickUp,       // [Analog]                                                 // -> ImGuiNavInput_LStickUp
ImGuiKey_GamepadLStickDown,     // [Analog]                                                 // -> ImGuiNavInput_LStickDown
ImGuiKey_GamepadLStickLeft,     // [Analog]                                                 // -> ImGuiNavInput_LStickLeft
ImGuiKey_GamepadLStickRight,    // [Analog]                                                 // -> ImGuiNavInput_LStickRight
ImGuiKey_GamepadRStickUp,       // [Analog]
ImGuiKey_GamepadRStickDown,     // [Analog]
ImGuiKey_GamepadRStickLeft,     // [Analog]
ImGuiKey_GamepadRStickRight,    // [Analog]

// Keyboard Modifiers
// - This is mirroring the data also written to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper, in a format allowing
//   them to be accessed via standard key API, allowing calls such as IsKeyPressed(), IsKeyReleased(), querying duration etc.
// - Code polling every keys (e.g. an interface to detect a key press for input mapping) might want to ignore those
//   and prefer using the real keys (e.g. ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl instead of ImGuiKey_ModCtrl).
// - In theory the value of keyboard modifiers should be roughly equivalent to a logical or of the equivalent left/right keys.
//   In practice: it's complicated; mods are often provided from different sources. Keyboard layout, IME, sticky keys and
//   backends tend to interfere and break that equivalence. The safer decision is to relay that ambiguity down to the end-user...
ImGuiKey_ModCtrl,
ImGuiKey_ModShift,
ImGuiKey_ModAlt,
ImGuiKey_ModSuper,

ImGuiKey_COUNT,                 // No valid ImGuiKey is ever greater than this value

Questions?

(Will be updated over time)

Q: It is ok to call io.AddXXXEvent() functions every frame with unchanged data?
A: Yes.

@ocornut ocornut changed the title New IO event API in 1.87: io.AddKeyEvent() io.AddMousePosEvent() etc full recap New IO keyboard/mouse/gamepad event API (1.87) recap Jan 20, 2022
@ocornut ocornut pinned this issue Jan 20, 2022
@RT2Code
Copy link

RT2Code commented Jan 23, 2022

Awesome changes! I'm in the process of updating my custom backend to this API, it will integrate much better in my callback based event system.

One thing though, If I understand correctly, ImGuiKey_Menu is supposed to represent this key : image

If yes, then the SDL backend should use SDLK_APPLICATION instead of SDLK_MENU.

@thedmd
Copy link
Contributor

thedmd commented Jan 23, 2022

Yes, this is a bug. It should be SDLK_APPLICATION.

@Flix01
Copy link

Flix01 commented Jan 25, 2022

[OT] Not sure if somebody's interested... but when I saw the new "keyboard rectangle" in imgui_demo.cpp, I've soon tried to "extend" it. Here is what I've done so far [gist link].

show/hide screenshot

image

@thedmd
Copy link
Contributor

thedmd commented Jan 27, 2022

I love it. I'm also so picky creature that I differentiate between ANSI and ISO layouts. :)

ocornut added a commit that referenced this issue Jan 27, 2022
…ified key enum system. Backends: update most. (#4921, #4858)

Sorry this is an unusual breaking but since we are WIP it is a good time to make a correction.
ocornut pushed a commit that referenced this issue Jan 27, 2022
@ocornut
Copy link
Owner Author

ocornut commented Jan 27, 2022

IMPORTANT: If you have updated backends between January 10 and January 27
We have made a breaking change to the new IO api c906c65
io.AddKeyModsEvent() was replaced with normal calls to io.AddKeyEvent() with ImGuiKey_ModXXX values.

All backends have been updated. This only applies to you if you updated standard or custom backend between January 10 and January 27. If you use standard backends, simply update. If you use a custom backend change code above.

@Flix01
Copy link

Flix01 commented Jan 31, 2022

...as far as I can see, in the glfw backend, when we "translate untranslated" keys, numbers in the keypad (= numpad) are converted to (or detected as) normal numbers of the main keyboard block (...well at least in my custom glfw backend).
If I comment out the "translation code" they are detected correctly.
This seems to affect only numbers (other keypad keys work correctly).
It's OK for me, but I'd like to know if this is the expected behavior...

@ocornut
Copy link
Owner Author

ocornut commented Jan 31, 2022

Not expected behavior; will fix soon! Thank you!

@PeterJohnson
Copy link

What's the recommended way to remap keys in the new API? From what I can tell, it looks like doing so after this change requires customizing the backend, whereas previously that could be done simply by modifying io.KeyMap to point to a different io.KeysDown?

@PathogenDavid
Copy link
Contributor

@PeterJohnson What/why were you remapping before? Everything in KeyMap was used for pretty well-established UI behaviors so it seems odd to me that you'd want to customize them in the first place.

@PeterJohnson
Copy link

For my use case, there is another application running on the system that has a global (system-wide) listener on the spacebar and Enter keys. While it's relatively easy to avoid the use of spacebar for numeric entry, the use of Enter for committing changes to InputText-based controls is hardcoded, so the easiest workaround was to provide users a way to remap another key (e.g. right ctrl) to the Enter key. Is not acceptable for my use case to commit the value for every keypress.

I agree this is a relatively unusual use case and modifying the backend (GLFW in my case) to support key remap is probably the right answer.

@PathogenDavid
Copy link
Contributor

PathogenDavid commented Feb 10, 2022

Ah yeah, the driver station? 😅 That makes sense.

I haven't tested it super thoroughly, but this might be good enough for your use-case:

//...
ImGui::NewFrame();

if (ImGui::IsKeyPressed(ImGuiKey_RightCtrl))
{
    io.AddKeyEvent(ImGuiKey_Enter, true);
    io.AddKeyEvent(ImGuiKey_Enter, false);
}

//...

Note that this will break using right control for shortcuts. (IE: Right Control + V to paste.)


If you want to truly remap it you could install your own glfwSetKeyCallback callback and handle the translation there.

Another alternative would be to manipulate ImGuiIO::KeysData instead, but then you're mucking with Dear ImGui's internal state which is obviously not super ideal.

(Or like you said you could just modify the GLFW backend, but then you have to deal with merging changes all the time.)

(If you want me to elaborate on one of these alternatives it would be better to open a separate issue.)

@caxapexac
Copy link

@ocornut its really cool update but what about key/mouse intercompatibility #4858 (comment) ?

@ocornut
Copy link
Owner Author

ocornut commented Feb 21, 2022

We discovered a backward-compatibility regression in 1.87

  • Direct legacy reads from io.KeysDown[] won't work with new backends.
  • And in particular io.KeysDown[GetKeyIndex[XXX]) will buffer overflow in old and new backends.

Reads via IsKeyDown() function are working.

We'll see if we can come up with a fix. But changing your app to use IsKeyDown() will fix things.

ocornut added a commit that referenced this issue Feb 21, 2022
…4858)

+ Snuck in unrelated comments and removed the "fill once" comment (#5043)
@ocornut
Copy link
Owner Author

ocornut commented Feb 21, 2022

We discovered a backward-compatibility regression in 1.87

Fixed by commit 5659db5.

ocornut added a commit that referenced this issue Feb 22, 2022
@tom-seddon
Copy link
Contributor

I've raised an issue, that refers more vaguely to the extra key on the ISO-type keyboard layout. As that's the basic issue here I think: ISO-type keyboards have an extra key that ANSI-type keyboards don't, and there's no value in the enum to cover this.

Thanks,

--Tom

@onbings
Copy link

onbings commented Jan 3, 2024

Hello World,

Just some remarks/questions on the new keyboard api:

  • I can't see any entries in the enum ImGuiKey for at least the following keys: >,<,&,%,|,@
  • How do you manage keys with 2 or 3 symbols like the following one on my french keyboard ?
image - Do i need to manage the key presses to find the correct symbol (shift or altgr) + key ? Thanks for your time and help

@ocornut
Copy link
Owner Author

ocornut commented Jan 3, 2024

Keys are not Characters. They are meant to mostly associate to physical keys.
You can use the io.InputCharacters[] buffer for characters.
What you are trying to do? Please open new issues for it.

The complication comes from the fact that high-level systems such as GLFW and SDL and some Win32 layers don't expose characters when certain modifiers are pressed (e.g. CTRL) so it's complicated to use them for shortcut.

AnotherFoxGuy pushed a commit to RigsOfRods/rigs-of-rods that referenced this issue Feb 5, 2024
Status: builds and runs, but crashes when loading terrain (RenderingAPIException)

Codechanges:
 * ImGuiAngelscript: commented out some dead items, added (ImGuiKey) casts where needed, see ocornut/imgui#4921
 * GUI_RepositorySelector: updated thumbnail downloading to use new OGRE WorkQueue API, see https://github.com/OGRECave/ogre/blob/master/Docs/14-Notes.md#task-based-workqueue
 * Application.h, main.cpp: added ✉️ `MSG_NET_DOWNLOAD_REPOTHUMB_SUCCESS`, used instead of OGRE WorkQueue's `addMainThreadTask` for consistency across the various background threads in the codebase.
 * GodRaysManager, skyx/VClouds: build fix - RENDER_QUEUE_9 was removed from OGRE, using 8.
 * RttManager: rendersystem-specific `getProjectionMatrixRS()` was removed from OGRE, using portable  `getProjectionMatrix()`
 * TerrainGeometryManager: updated (simplified!) to match OGRE14 API.
 * FlexBody: `reorganiseBuffers()`: updated for OGRE14 - there's no 'optimalUsage' param anymore.
 * RTTLayer, DashBoardManager: build fix for MyGUI API change.
EffectiveOtter pushed a commit to EffectiveOtter/imnodes that referenced this issue Feb 9, 2024
EffectiveOtter pushed a commit to EffectiveOtter/imnodes that referenced this issue Feb 9, 2024
ocornut added a commit that referenced this issue Mar 8, 2024
@MacroController
Copy link

Hi there, although I'm loving the unification of inputs, I was wondering if there is a way to "capture" gamepad input only from a dear imgui window ?

  • If I call ImGui::IsKeyPressed(ImGuiKey_Q), it returns true when I press the Q keyboard key ONLY if the dear imgui window is focused
  • If I call ImGui::IsKeyPressed(ImGuiKey_GamepadL1), it returns true when I press the L1 gamepad button even if my dear imgui window is unfocused

@ocornut
Copy link
Owner Author

ocornut commented Mar 14, 2024

Hi there, although I'm loving the unification of inputs, I was wondering if there is a way to "capture" gamepad input only from a dear imgui window ?

  • If I call ImGui::IsKeyPressed(ImGuiKey_Q), it returns true when I press the Q keyboard key ONLY if the dear imgui window is focused
  • If I call ImGui::IsKeyPressed(ImGuiKey_GamepadL1), it returns true when I press the L1 gamepad button even if my dear imgui window is unfocused

Please open a new issue.
Also your statements seems wrong, you seem to be mixing up platform/os windows with dear imgui windows.

@ocornut ocornut mentioned this issue May 23, 2024
7 tasks
Intrets pushed a commit to Intrets/imgui that referenced this issue Jun 14, 2024
…consistency. Rework demo, Comments. Moved ImGuiKey_KeysData_OFFSET to internal.h (ocornut#4921, ocornut#6191)
ocornut added a commit that referenced this issue Jun 21, 2024
ocornut added a commit that referenced this issue Jul 2, 2024
…named to ImGuiKeyChord and ImGuiMod_XXX in 1.89). (#4921, #456)
Ciachociech added a commit to Ciachociech/imgui that referenced this issue Jul 24, 2024
* Version 1.90.8

* Version 1.90.9 WIP

* Internals: renamed HoveredIdDisabled to HoveredIdIsDisabled for consistency.

* Examples: GLFW+Vulkan: handle swap chain resize even without Vulkan returning VK_SUBOPTIMAL_KHR (ocornut#7671)

* Examples: SDL+Vulkan: handle swap chain resize even without Vulkan returning VK_SUBOPTIMAL_KHR (ocornut#7671)

* Removed old nested structure: renaming ImGuiStorage::ImGuiStoragePair type to ImGuiStoragePair (simpler for many languages).

* Internals: made ImLowerBound() accessible in internals + take a span. + rearrange child/popup/tooltips section.

Because upcoming rework of ImGuiSelectionBasicStorage will want to do a lower bound on a span.

* IO: do not disable io.ConfigWindowsResizeFromEdges when ImGuiBackendFlags_HasMouseCursors is not set by backend.

Amend 42bf149

* Style: (Breaking) renamed ImGuiCol_TabActive -> ImGuiCol_TabSelected, ImGuiCol_TabUnfocused -> ImGuiCol_TabDimmed, ImGuiCol_TabUnfocusedActive -> ImGuiCol_TabDimmedSelected.

Amend ocornut#261, ocornut#351

* TabBar, Style: added ImGuiTabBarFlags_DrawSelectedOverline and ImGuiCol_TabSelectedOverline, ImGuiCol_TabDimmedSelectedOverline.

* Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern. (ocornut#143)

Amend 0c6e260

* Drag and Drop: Fixes an issue when elapsing payload would be based on last payload frame instead of last drag source frame.

* Internals: added ImGuiContext::ContextName optionally used by debug log and to facilitate debugging.

* Drag and Drop: comments, debug log entries.

* Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceExtern assume a mouse button being pressed. (ocornut#143)

* Drag and Drop: (Breaking) renamed ImGuiDragDropFlags_SourceAutoExpirePayload to ImGuiDragDropFlags_PayloadAutoExpire. (ocornut#1725, ocornut#143)

* Drag and Drop: Added ImGuiDragDropFlags_PayloadNoCrossContext and ImGuiDragDropFlags_PayloadNoCrossProcess flags.

* Ignore .ini file with other suffixes.

* Fixed build warning.

* IO: added ClearInputMouse(). made ClearInputKeys() not clear mouse data. (ocornut#4921)

Amend 6aa408c

* IO: added ImGuiConfigFlags_NoKeyboard for consistency and convenience. (ocornut#4921)

# Conflicts:
#	imgui.h
#	imgui_demo.cpp

* Nav: CTRL+Tab overlay display context name if any.

* Internals: storing HoveredWindowBeforeClear for use by multi-context compositor drag and drop propagation.

# Conflicts:
#	imgui.cpp
#	imgui_internal.h

* (Breaking) Move ImGuiWindowFlags_NavFlattened to ImGuiChildFlags_NavFlattened. (ocornut#7687)

* Backends: SDL3: Follow SDL3 removal of keysym field in SDL_KeyboardEvent (ocornut#7729)

* Demo: Style Editor: clarify how _CalcCircleAutoSegmentCount() doesn't always get exact final segment count. (ocornut#7731)

* Backends: Vulkan: Remove Volk/ from volk.h #include directives (ocornut#7722, ocornut#6582, ocornut#4854)

* Metrics/Debugger: Browsing a Storage perform hover lookup on identifier.

* Viewports: Backported 'void* ImGuiViewport::PlatformHandle' from docking branch for use by backends.

* Backends: SDL3: Update for SDL_StartTextInput()/SDL_StopTextInput() API changes. (ocornut#7735)

* Examples: undo adding SDL3 example to Visual Studio sln.

* Backends: OSX: build fix. Amend 32f9dfc

* ImGuiStorage: tweak impl for BuildSortByKey().

* Inputs: fixed using Shortcut() or SetNextItemShortcut() within a disabled block bypassing the disabled state. (ocornut#7726)

* Tables: moved TableGetHoveredColumn() to public API. (ocornut#7715, ocornut#3740)

* Windows: BeginChild(): fixed a glitch when during a resize of a child window which is tightly close to the boundaries of its parent. (ocornut#7706)

* Nav: store NavJustMovedToIsTabbing + shuffle a few nav related fields.

(for usage by multi-select)

* Backends: OpenGL2, OpenGL3: ImGui_ImplOpenGL3_NewFrame() recreates font texture if it has been destroyed by ImGui_ImplOpenGL3_DestroyFontsTexture(). (ocornut#7748)

Analogous to change to Vulkan backend in 1.90.

* Backends: Win32: Fixed warning with old MinGW/GCC versions.

* Drags: added ImGuisliderFlags_WrapAround flag for DragInt(), DragFloat() etc. (ocornut#7749)

* Fix typo, rename ImGuisliderFlags_WrapAround flag to ImGuiSliderFlags_WrapAround. (ocornut#7752, ocornut#7749)

* Checkbox: minor tidying up to simplify work on multi-select branch.

* Backends: Allegro5: Correctly handle unstable bit in version checks (ocornut#7755)

* Backends: SDLRenderer3: Update for SDL_RenderGeometryRaw() API changes.

* Backends: SDL3: update for SDL_SetTextInputRect() -> SDL_SetTextInputArea() api change. (ocornut#7760, ocornut#7754)

* Examples: SDL3: Remove use of SDL_HINT_IME_NATIVE_UI.

* Disabled: Reworked 1.90.8 behavior of Begin() not inheriting current BeginDisabled() state. Only tooltip are clearing that state. (ocornut#211, ocornut#7640)

* imgui_freetype: fixed divide by zero while handling FT_PIXEL_MODE_BGRA glyphs. (ocornut#7267, ocornut#3369)

* IO: do not claim io.WantCaptureMouse=true on the mouse release frame of a button which was pressed over void.  (ocornut#1392)

* Version 1.90.9

* Version 1.91.0 WIP

* Backends: SDL3: Update for API changes: SDLK_x renames and SDLK_KP_x removals (ocornut#7761, ocornut#7762)

Also updated function signature in SDL2 backend to match and because it is expected we will use that data (as per ocornut#7672)

* Backends: SDL3: Updated comments (IME seems fixed in SDL3). Added SDL3 examples to Visual Studio solution.

* Debug Tools: Added IMGUI_DEBUG_LOG(), ImGui::DebugLog() in public API. (ocornut#5855)

* Debug Log: Added "Configure Outputs.." button. (ocornut#5855)

* Backends: SDL3: add default case to fix warnings. (ocornut#7763)

* Demo: changed style editor inline block to its own window.

* IO: added io.PlatformOpenInShellFn handler to open a link/folder/file in OS shell, added IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS. (ocornut#7660)

* (Breaking) IO, IME: renamed platform IME hook io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() and added explicit context.

* Commented out obsolete ImGuiModFlags and ImGuiModFlags_XXX values (renamed to ImGuiKeyChord and ImGuiMod_XXX in 1.89). (ocornut#4921, ocornut#456)

* Build fix for non Windows platforms.

* IO: disable default io.PlatformOpenInShellFn() implementation on iPhone, as compiler errors that system() is not available on iOS.

* Internals: added FontScale storage.

* Added TextLink(), TextLinkOpenURL() hyperlink widgets. (ocornut#7660)

* Internals: added FontScale storage (amend 0f63d3e).

* Backends: GLFW,SDL2: Added ioPlatformOpenInShellFn handler for web/Emscripten versions. (ocornut#7660)

* IO: amend PlatformOpenInShellFn specs to return a bool. (ocornut#7660)

Amend 8f36798

* Misc tweaks, comments.

* TreeNode: rename/rework ImGuiNavTreeNodeData system to be usable by more features. (ocornut#2920, ocornut#1131, ocornut#7553)

Reworked to it is easier during TreeNode code to request extra data to be stored.

* Fixed Unix version of PlatformOpenInShellFn_DefaultImpl. (ocornut#7772, ocornut#7660)

+ Enable on non-iPhone macOS builds

* DemosFix typo in help text in demo Tables/Borders (ocornut#7780)

The help text for flags had a "V" flag duplicated, this change corrects it to the missing "H" flag.

* Backends: Win32: fixed ImGuiMod_Super being mapped to VK_APPS instead of VK_LWIN||VK_RWIN (ocornut#7768, ocornut#4858, ocornut#2622)

Amend 0755767

The `ImGui_ImplWin32_UpdateKeyModifiers()` function maps `ImGuiMod_Super` to `VK_APPS`, the "Application" key located between the Right Windows (Super) and Right Control keys on the keyboard, see https://conemu.github.io/en/AppsKey.html

This means that when using `ImGui::GetIO().KeySuper` to try to get the down state of the `VK_RWIN` or `VK_LWIN` keys, it'll always return FALSE when either of those keys are held down, and only return TRUE when `VK_APPS` is held down.

* Backends: GLFW+Emscripten: (Breaking) Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback() to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWwindow* parameter. (ocornut#7647, ocornut#7600)

+ Fixed Emscripten warning when using mouse wheel on some setups.

* Backends: GLFW+Emscripten: Added support for GLFW3 contrib port. (ocornut#7647)

* Backends: GLFW+Emscripten: Fixed build (ocornut#7647)

* Examples: SDL3+OpenGL: Update for API changes: SDL_GL_DeleteContext() renamed to SDL_GL_DestroyContext().

* Fix definition check (ocornut#7793)

* Backends: SDL3: Update for API changes: SDL_GetProperty() change to SDL_GetPointerProperty(). (ocornut#7794)

* Backends: SDL3: fixed typo leading to PlatformHandleRaw not being set leading to SHOWNA path not working for multi-viewports.

* Internals: Added TreeNodeIsOpen() to facilitate discoverability. (ocornut#7553, ocornut#1131, ocornut#2958, ocornut#2079, ocornut#722)

* Added ImGuiDataType_Bool for convenience.

* Demo: Reworked "Property Editor" demo in a manner that more ressemble the tree data and struct description data that a real application would want to use.

* Added PushItemFlag(), PopItemFlag(), ImGuiItemFlags.

* (Breaking) Obsoleted PushButtonRepeat()/PopButtonRepeat() in favor of using new PushItemFlag()/PopItemFlag() with ImGuiItemFlags_ButtonRepeat.

* Added ImGuiItemFlags_AutoClosePopups as a replacement for internal's ImGuiItemFlags_SelectableDontClosePopup. (ocornut#1379, ocornut#1468, ocornut#2200, ocornut#4936, ocornut#5216, ocornut#7302, ocornut#7573)

* (Breaking) Renamed ImGuiSelectableFlags_DontClosePopups to ImGuiSelectableFlags_NoAutoClosePopups. (ocornut#1379, ocornut#1468, ocornut#2200, ocornut#4936, ocornut#5216, ocornut#7302, ocornut#7573)

* Obsoleted PushTabStop()/PopTabStop() in favor of using new PushItemFlag()/PopItemFlag() with ImGuiItemFlags_NoTabStop.

* Fixed pvs-studio warning.

* Demo: Property Editor: rearrange code + replace use of bool to proper ImGuiChildFlags.

Amend 46691d1

* Demo: Property Editor: add basic filter.

* Style: close button and collapse/window-menu button hover highlight made rectangular instead of round.

The reason they were round in the first place was to work better with rounded windows/frames.
However since the 4a81424 rework ocornut#6749 we can naturally use a tigher bounding box and it seems to work ok either way.

* Nav, Demo: comments.

* Clipper: added SeekCursorForItem() function, for use when using ImGuiListClipper::Begin(INT_MAX). (ocornut#1311)

Tagging ocornut#3609 just in case we made a mistake introducing a regression (but tests are passing and have been extended).

* TreeNode: Internals: facilitate dissociating item ID from storage ID (useful for 1861)

* Internals: rename recently added TreeNodeIsOpen() -> TreeNodeGetOpen(). (ocornut#7553, ocornut#1131, ocornut#2958, ocornut#2079, ocornut#722)

Amend ac7d6fb

* Backends: SDL3: Update for API changes: SDL_GetClipboardText() string ownership change. (ocornut#7801)

* MultiSelect: WIP range-select (ocornut#1861) (rebased six millions times)

* MultiSelect: Removed SelectableSpacing as I'm not sure it is of use for now (history insert)

* MultiSelect: Added IMGUI_HAS_MULTI_SELECT define. Fixed right-click toggling selection without clearing active id, could lead to MarkItemEdited() asserting. Fixed demo.

* MultiSelect: Demo sharing selection helper code. Fixed static analyzer warnings.

* MultiSelect: Renamed SetNextItemMultiSelectData() to SetNextItemSelectionUserData()

* MultiSelect: Transition to use FocusScope bits merged in master.

Preserve ability to shift+arrow into an item that is part of FocusScope but doesn't carry a selection without breaking selection.

* MultiSelect: Fix for TreeNode following merge of 011d475. Demo: basic test for tree nodes.

* MultiSelect: Fixed CTRL+A not testing focus scope id. Fixed CTRL+A not testing active id. Added demo code.

Comments.

* MultiSelect: Comments. Tweak demo.

* MultiSelect: Fix Selectable() ambiguous return value, clarify need to use IsItemToggledSelection().

* MultiSelect: Fix testing key mods from after the nav request (remove need to hold the mod longer)

* MultiSelect: Temporary fix/work-around for child/popup to not inherit MultiSelectEnabled flag, until we make mulit-select data stackable.

* MultiSelect: Fixed issue with Ctrl+click on TreeNode + amend demo to test drag and drop.

* MultiSelect: Demo: Add a simpler version.

* MultiSelect: Added ImGuiMultiSelectFlags_ClearOnEscape (unsure of best design), expose IsFocused for custom shortcuts.

* MultiSelect: Demo: Added pointer indirection and indent level.

This is to reduce noise for upcoming commits, ahead of adding a loop here.

* MultiSelect: Added ImGuiMultiSelectFlags_ClearOnClickWindowVoid. + Demo: showcase multiple selection scopes in same window.

* MultiSelect: Enter doesn't alter selection (unlike Space).

Fix for changes done in 5606.

* MultiSelect: Shallow tweaks/refactors.

Including moving IsFocused back internally for now.

* MultiSelect: Fixed needing to set RangeSrcPassedBy when not using clipper.

* MultiSelect: made SetNextItemSelectionData() optional to allow disjoint selection (e.g. with a CollapsingHeader between items). Amend demo.

* MultiSelect: Enter can alter selection if current item is not selected.

* MultiSelect: removed DragDropActive/preserve_existing_selection logic which seems unused + comments.

Can't find trace of early prototype for range-select but I couldn't find way to trigger this anymore. May be wrong. Will find out.

* MultiSelect: refactor before introducing persistant state pool and to facilitate adding recursion + debug log calls.

This is mostly the noisy/shallow stuff committed here, to get this out of the way.

* MultiSelect: (Breaking) Rename ImGuiMultiSelectData to ImGuiMultiSelectIO.

* MultiSelect: Demo tweak. Removed multi-scope from Advanced (too messy), made it a seperate mini-demo.

* MultiSelect: Internals rename of IO fields to avoid ambiguity with io/rw concepts + memset constructors, tweaks.

debug

* MultiSelect: (Breaking) Renamed 'RangeSrc -> 'RangeSrcItem', "RangeDst' -> 'RangeDstItem'

This is necessary to have consistent names in upcoming fields (NavIdItem etc.)

* MultiSelect: (Breaking) Renamed 'RangeValue' -> 'RangeSelected' + amend comments.

* MultiSelect: Remove ImGuiMultiSelectFlags_NoUnselect because I currently can't find use for this specific design.

And/or it seem partly broken.

* MultiSelect: Remove the need for using IsItemToggledSelection(). Update comments.

This is the simple version that past our tests. MultiSelectItemFooter() is in need of a cleanup.

* MultiSelect: Tidying up/simpllifying MultiSelectItemFooter().

Intended to be entirely a no-op, merely a transform of source code for simplification. But committing separatey from behavior change in previous change.

* MultiSelect: Clarify and better enforce lifetime of BeginMultiSelect() value.

* MultiSelect: Demo: first-draft of user-side deletion idioms.

(will need support from lib)

* MultiSelect: (Breaking) BeginMultiSelect() doesn't need two last params maintained by users. Moving some storage from user to core. Proper deletion demo.

* MultiSelect: Maintain NavIdSelected for user. Simplify deletion demo.

* MultiSelect: Further simplication of user code to support Deletion.

Provide standard RequestFocusItem storage.

* MultiSelect: Demo: Delete items from menu.

* MultiSelect: Fixed right-click handling in MultiSelectItemFooter() when not focused.

* MultiSelect: Cleanup unused comments/code.

* MultiSelect: (Breaking) Fix + Rename ImGuiMultiSelectFlags_NoMultiSelect to ImGuiMultiSelectFlags_SingleSelect as it seems easier to grasp.

Feature was broken by "Tidying up..." June 30 commit.

* MultiSelect: Comments, tweaks.

+ Alignment to reduce noise on next commit.

* MultiSelect: (Breaking) Use ImGuiSelectionUserData (= ImS64) instead of void* for selection user data.

Less confusing for most users, less casting.

* MultiSelect: move HasSelectionData to ImGuiItemFlags to facilitate copying around in standardized fieds.

Required/motivated to simplify support for ImGuiTreeNodeFlags_NavLeftJumpsBackHere (bc3c0ce) in this branch.

* MultiSelect: Tweak debug log to print decimal+hex values for item data.

Struggled to get standard PRIX64 to work on CI.

* MultiSelect: clear selection when leaving a scope with a nav directional request.

May need to clarify how to depends on actions being performed (e.g. click doesn't).
May become optional?

* MultiSelect: (Breaking) RequestSetRange's parameter are RangeFirstItem...RangeLastItem (which was always ordered unlike RangeSrcItem...RangeDstItme). Removed RangeDstItem. Removed RangeDirection.

* MultiSelect: Demo: rework ExampleSelection names to map better to typical user code + variety of Comments tweaks.

* MultiSelect: Demo: added simpler demo using Clipper. Clarify RangeSrcPassedBy doc.

* MultiSelect: (Breaking) Removed RangeSrcPassedBy in favor of favoring user to call IncludeByIndex(RangeSrcItem) which is easier/simpler to honor.

Especially as recent changes made it required to also update RangeSrcPassedBy after last clipper Step.
Should now be simpler.

* MultiSelect: Demo: rework ExampleSelection with an ExampleSelectionAdapter layer, allowing to share more code accross examples using different storage systems.

Not ideal way to showcase this demo but this is really more flexible.

* MultiSelect: Demo: Remove UserDataToIndex from ExampleSelectionAdapter.

Seems to make a better demo this way.

* MultiSelect: Demo: Make ExampleSelection use ImGuiID. More self-explanatory.

* MultiSelect: Demo: Deletion: Rework ApplyDeletionPreLoop to use adapter + fix PostLoop not using right value of RequestFocusItem.

Recovery made it transparent visually but user side selection would be empty for a frame before recovery.

* MultiSelect: Demo: Deletion: Various renames to clarify. Use adapter and item list in both ApplyDeletion functions.

This also minify the patch for an alternative/wip attmept at redesgining pre/post deletion logic. But turns out current attempt may be easier to grasp.

* Demo: Dual List Box: Added a dual list box (6648)

* MultiSelect: ImGuiMultiSelectIO's field are not used during loop anymore, stripping them out of comments.

* MultiSelect: moved RequestClear output so it'll match request list version better. Use Storage->RangeSrcItem in EndMultiSelect().

* MultiSelect: move shared logic to MultiSelectItemHeader().

No logic change AFAIK but added an indent level in MultiSelectItemHeader(). Logic changes will come in next commit.

* MultiSelect: Added ImGuiMultiSelectFlags_SelectOnClickRelease to allow dragging an unselected item without altering selection + update drag and drop demo.

* Demo: Assets Browser: Added assets browser demo.

* Demo: Assets Browser: store items, sorting, type overlay.

* MultiSelect: removed seemingly unnecessary block in BeginMultiSelect().

- EndIO.RangeSelected always set along with EndIO.RequestSetRange
- Trying to assert for the assignment making a difference when EndIO.RequestSetRange is already set couldn't find a case (tests passing).

* MultiSelect: clarified purpose and use of IsItemToggledSelection(). Added assert. Moved to multi-selection section of imgui.h.

* MultiSelect: added missing call on Shutdown(). Better reuse selection buffer.

* MultiSelect: (Breaking) io contains a ImVector<ImGuiSelectionRequest> list.

* MultiSelect: we don't need to ever write to EndIO.RangeSrcItem as this is not meant to be used.

* MultiSelect: added support for recovery in ErrorCheckEndWindowRecover().

* MultiSelect: use a single ImGuiMultiSelectIO buffer.

+ using local storage var in EndMultiSelect(), should be no-op.

* MultiSelect: simplify clearing ImGuiMultiSelectTempData.

* Demo: Assets Browser: add hit spacing, requierd for box-select patterns.

* MultiSelect: (breaking) renamed ImGuiMultiSelectFlags_ClearOnClickWindowVoid -> ImGuiMultiSelectFlags_ClearOnClickVoid. Added ImGuiMultiSelectFlags_ScopeWindow, ImGuiMultiSelectFlags_ScopeRect.

* MultiSelect: Box-Select: added support for ImGuiMultiSelectFlags_BoxSelect.

(v11)
FIXME: broken on clipping demo.

* MultiSelect: Box-Select: added scroll support.

* MultiSelect: Demo: rework and move selection adapter inside ExampleSelection.

* MultiSelect: added support for nested/stacked BeginMultiSelect().

Mimicking table logic, reusing amortized buffers.

* MultiSelect: remove ImGuiSelectionRequest/ImGuiMultiSelectIO details from public api to reduce confusion + comments.

* MultiSelect: move demo's ExampleSelection to main api as a convenient ImGuiSelectionBasicStorage for basic users.

* MultiSelect: reworked comments in imgui.h now that we have our own section.

* MultiSelect: Demo: Assets Browser: added deletion support. Store ID in selection. Moved QueueDeletion to local var to emphasis that this is a user extension.

* MultiSelect: Demo: Assets Browser: track scrolling target so we can roughly land on hovered item.

It's impossible to do this perfectly without some form of locking on item because as the hovered item X position changes it's easy to drift.

* MultiSelect: Box-Select: Fixed holes when using with clipper (in 1D list.)

Clipper accounts for Selectable() layout oddity as BoxSelect is sensitive to it.
Also tweaked scroll triggering region inward.
Rename ImGuiMultiSelectFlags_NoBoxSelectScroll to ImGuiMultiSelectFlags_BoxSelectNoScroll.
Fixed use with ImGuiMultiSelectFlags_SinglaSelect.

* MultiSelect: Box-Select: Added ImGuiMultiSelectFlags_BoxSelect2d support. Enabled in Asset Browser. Selectable() supports it.

* MultiSelect: Box-Select: Refactor into its own structure, designed for single-instance but closer to being reusable outside Multi-Select.

Kept same member names.

* MultiSelect: Box-Select: Refactor: Renames.

Split into two commits to facilite looking into previous one if needed.

* MultiSelect: Box-Select: Fixed scrolling on high framerates.

* MultiSelect: Box-Select: Further refactor to extra mode code away from multi-select function into box-select funcitons.

* MultiSelect: Fixed ImGuiSelectionBasicStorage::ApplyRequests() incorrectly maintaining selection size on SelectAll.

* MultiSelect: Comments + Assets Browser : Tweak colors.

* MultiSelect: Added ImGuiMultiSelectFlags_NoRangeSelect. Fixed ImGuiMultiSelectFlags_ScopeRect not querying proper window hover.

* MultiSelect: Box-Select: Fixed CTRL+drag from void clearing items.

* MultiSelect: Box-Select: Fixed initial drag from not claiming hovered id, preventing window behind to move for a frame.

* MultiSelect: Fixed ImGuiMultiSelectFlags_SelectOnClickRelease over tree node arrow.

* MultiSelect: (Breaking) merge ImGuiSelectionRequestType_Clear and ImGuiSelectionRequestType_SelectAll into ImGuiSelectionRequestType_SetAll., rename ImGuiSelectionRequest::RangeSelected to Selected.

The reasoning is that it makes it easier/faster to write an adhoc ImGuiMultiSelectIO handler (e.g. trying to apply multi-select to checkboxes)

* MultiSelect: Simplified ImGuiSelectionBasicStorage by using a single SetItemSelected() entry point.

* MultiSelect: Comments + tweaked location for widgets to test ImGuiItemFlags_IsMultiSelect to avoid misleading into thinking doing it before ItemAdd() is necessary.

* MultiSelect: Demo: make various child windows resizable, with synched heights for the dual list box demo.

* MultiSelect: added ImGuiMultiSelectFlags_NoAutoSelect, ImGuiMultiSelectFlags_NoAutoClear features + added Checkbox Demo

Refer to "widgets_multiselect_checkboxes" in imgui_test_suite.

* MultiSelect: Box-Select: fix preventing focus. amend determination of scope_hovered for decorated/non-child windows + avoid stealing NavId. (ocornut#7424)

* MultiSelect: Demo: use Shortcut().

Got rid of suggestion to move Delete signal processing to BeginMultiSelect(), seems unnecessary.

* RangeSelect/MultiSelect: (Breaking) Added current_selection_size to BeginMultiSelect().

Required for shortcut routing so we can e.g. have Escape be used to clear selection THEN to exit child window.

* MultiSelect: Box-Select: minor refactor, tidying up.

* MultiSelect: Box-Select: when dragging from void, first hit item sets NavId by simulating a press, so navigation can resume from that spot.

* MultiSelect: added GetMultiSelectState() + store LastSelectionSize as provided by user, convenient for quick debugging and testing.

* MultiSelect: Box-Select: fixed "when dragging from void" implementation messing with calling BeginMultiSelect() without a selection size.

* MultiSelect: (breaking) renamed ImGuiSelectionBasicStorage::AdapterData to UserData.

* MultiSelect: Box-Select: fixes for checkboxes support. Comments.

* MultiSelect: (breaking) renamed ImGuiMultiSelectFlags_BoxSelect -> ImGuiMultiSelectFlags_BoxSelect1d, ImGuiMultiSelectFlags_BoxSelect2d -> ImGuiMultiSelectFlags_BoxSelect.

ImGuiMultiSelectFlags_BoxSelect1d being an optimization it is the optional flag.

* MultiSelect: mark parent child window as navigable into, with highlight. Assume user will always submit interactive items.

* MultiSelect: (breaking) Added 'items_count' parameter to BeginMultiSelect(). Will enable extra features, and remove equivalent param from ImGuiSelectionBasicStorage::ApplyRequests(.

* MultiSelect: added ImGuiSelectionBasicStorage::GetStorageIdFromIndex() indirection to be easier on the reader.

Tempting to make it a virtual.

* MultiSelect: fixed ImGuiSelectionBasicStorage::Swap() helper.

* MultiSelect: added ImGuiSelectionExternalStorage helper. Simplify bool demo.

* MultiSelect: comments, header tweaks., simplication (some of it on wiki).

* MultiSelect: ImGuiSelectionBasicStorage: added GetNextSelectedItem() to abstract selection storage from user. Amend Assets Browser demo to handle drag and drop correctly.

* MultiSelect: ImGuiSelectionBasicStorage: rework to accept massive selections requests without flinching.

Batch modification + storage only keeps selected items.

* MultiSelect: ImGuiSelectionBasicStorage: simplify by removing compacting code (compacting may be opt-in?).

GetNextSelectedItem() wrapper gives us more flexibility to work on this kind of stuff now.

* MultiSelect: ImGuiSelectionBasicStorage: move function bodies to cpp file.

+ make ImGuiStorage::BuildSortByKey() less affected by msvc debug mode.

* Demo: Assets Browser: added a way to disable sorting and hide sorting options.

This is mostly designed to showcase that on very large sets (e.g. 1 million) most of the time is likely spent on sorting.

* MultiSelect: ImGuiSelectionBasicStorage: (breaking) rework GetNextSelectedItem() api to avoid ambiguity/failure when user uses a zero id.

* MultiSelect: provide RangeDirection to allow selection handler to handler backward shift+click.

* MultiSelect: ImGuiSelectionBasicStorage: added PreserveOrder, maintain implicit order data in storage.

Little tested but provided for completeness.

* MultiSelect: (breaking) renamed ImGuiMultiSelectFlags_BoxSelect -> ImGuiMultiSelectFlags_BoxSelect2d. Which include not assuming one flag imply the other.

Amend 2024/05/31 commit.

* MultiSelect: Shift+Tab doesn't enable Shift select on landing item.

* MultiSelect: added ImGuiMultiSelectFlags_NoAutoClearOnReselect + tweak flags comments. (ocornut#7424)

* MultiSelect: minor tidying up.

Checkbox() was reworked in master effectively fixing render clipping when culled by BoxSelect2d's UnclipMode.

* MultiSelect: added courtesy ImGuiMultiSelectFlags_NavWrapX flag so we can demo this until a nav api is designed.

* MultiSelect: Box-Select: uses SetActiveIdUsingAllKeyboardKeys() to avoid nav interference, much like most drag operations.

* MultiSelect: Box-Select: handle Esc to disable box-select.

This avoid remove a one-frame delay when finishing box-select, where Esc wouldn't be routed to selection but to child.

* MultiSelect: ImGuiSelectionBasicStorage: optimized for smaller insertion amounts in larger sets + fix caling batch select with same value.

* MultiSelect: Better document how TreeNode() is not trivially usable yet.

Will revert when the time is right.

* MultiSelect: added Changelog for the feature. Removed IMGUI_HAS_MULTI_SELECT.

* Demo: moved ExampleTreeNode, ExampleMemberInfo above in the demo file. Tidying up index.

+ change ExampleTreeNode::UID from ImGuiID to int to not suggest that the user ID needs to be of a certain type

* Demo: moved some fields inside a struct.

* Demo: moved menu bar code to its own function.

* MultiSelect: using ImGuiMultiSelectFlags_NoRangeSelect ensure never having to interpolate between two ImGuiSelectionUserData.

* Inputs: added SetItemKeyOwner(ImGuiKey key) in public API. (ocornut#456, ocornut#2637, ocornut#2620, ocornut#2891, ocornut#3370, ocornut#3724, ocornut#4828, ocornut#5108, ocornut#5242, ocornut#5641)

* Backends: SDL3: Update for API changes: SDL_GetGamepads() memory ownership change. (ocornut#7807)

* TabBar, Style: added style option for the size of the Tab-Bar Overline (ocornut#7804)

Amend 21bda2e.

* Added a comment hinting at how to set IMGUI_API for shared librairies on e.g. Linux, macOS (ocornut#7806)

* Demo: rework Property Editor.

* Nav: fixed c licking window decorations (e.g. resize borders) from losing focused item when within a child window using ImGuiChildFlags_NavFlattened.

In essence, using ImGuiFocusRequestFlags_RestoreFocusedChild here is a way to reduce changes caused by FocusWindow(), but it could be done more neatly.
See amended "nav_flattened" test.

* Demo: Property Editor: using ImGuiChildFlags_NavFlattened now that a bug is fixed. Fixed static analyzer.

* Backends: OpenGL3: Fixed unsupported option warning with apple clang (ocornut#7810)

* Internals, TreeNode: indent all render block into its own scope (aim is to add a is_visible test there later)

* Internals, TreeNode, Selectable: tweak span_all_columns paths for clarity.

* CollapsingHeader: left-side outer extend matches right-side one (moved left by one pixel)

Amend c3a348a

* Debug Log: fixed incorrect checkbox layout when partially clipped., doesn't parse 64-bits hex value as ImGuiID lookups.

* Groups, Tables: fixed EndGroup() failing to correctly capture current table occupied size. (ocornut#7543)

See "layout_group_endtable" test.

* MultiSelect: sequential SetRange merging not generally handled by box-select path, useful for others.

* MultiSelect: add internal MultiSelectAddSetAll() helper.

* MultiSelect: fixed an issue caused by previous commit.

Amend a285835. Breaks box-select.

---------

Co-authored-by: ocornut <omarcornut@gmail.com>
Co-authored-by: cfillion <cfillion@users.noreply.github.com>
Co-authored-by: Gary Geng <garygengxiao@gmail.com>
Co-authored-by: Martin Ejdestig <marejde@gmail.com>
Co-authored-by: Kevin Coghlan <mail@kevincoghlan.com>
Co-authored-by: Connor Clark <cjamcl@gmail.com>
Co-authored-by: Max Ortner <maxortner01@gmail.com>
Co-authored-by: Hugues Evrard <hevrard@users.noreply.github.com>
Co-authored-by: Aemony <10578344+Aemony@users.noreply.github.com>
Co-authored-by: Yan Pujante <ypujante@proton.me>
Co-authored-by: Cyao <94928179+cheyao@users.noreply.github.com>
Co-authored-by: wermi <32251376+wermipls@users.noreply.github.com>
Co-authored-by: Thomas Stehle <th.stehle@icloud.com>
ocornut added a commit that referenced this issue Jul 25, 2024
… two years ago. (#4921, #4858, #787, #1599, #323)

Use SetKeyOwner(ImGuiKey_Escape, g.ActiveId); instead. Amend 8b8a61b
@ocornut ocornut unpinned this issue Jul 30, 2024
ocornut added a commit that referenced this issue Aug 19, 2024
…own to be likely to input characters. (#7889, #4921, #4858)

Amend fa2b318. Refer to regression test "inputs_io_inputqueue" amended for IMGUI_VERSION_NUM >= 19102
ocornut added a commit that referenced this issue Oct 11, 2024
… is enabled. (#4921)

+ Retroactively add missing changelog item in 1.90
+ Backends: Vulkan: use GetTexID() for consistency.
ocornut added a commit that referenced this issue Nov 6, 2024
…avInputs[]. Remove IMGUI_DISABLE_OBSOLETE_KEYIO. (#4921)
@ocornut
Copy link
Owner Author

ocornut commented Nov 6, 2024

All pre 1.87 IO api support (which was mostly obsoleted in January/February 2022) was now removed with:

It's hopefully the very end of this specific task :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests