//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.86: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
//---- Disable all of Dear ImGui or don't implement standard windows.
//---- Disable all of Dear ImGui or don't implement standard windows.
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
IM_ASSERT(key>=ImGuiKey_NamedKey_BEGIN&&key<ImGuiKey_NamedKey_END&&"Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code.");
// Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]!
// Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]!
// Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]!
// Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]!
boolImGui::IsKeyDown(intuser_key_index)
boolImGui::IsKeyDown(ImGuiKeykey)
{
{
if(user_key_index<0)
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
IM_ASSERT(key>=ImGuiKey_NamedKey_BEGIN&&key<ImGuiKey_NamedKey_END&&"Support for user key indices was dropped in favor of ImGuiKey. Please update backend & user code.");
IM_ASSERT(key>=ImGuiKey_NamedKey_BEGIN&&key<ImGuiKey_NamedKey_END&&"Support for user key indices was dropped in favor of ImGuiKey. Please update backend & user code.");
IM_ASSERT(key>=ImGuiKey_NamedKey_BEGIN&&key<ImGuiKey_NamedKey_END&&"Support for user key indices was dropped in favor of ImGuiKey. Please update backend & user code.");
IM_ASSERT(key>=ImGuiKey_NamedKey_BEGIN&&key<ImGuiKey_NamedKey_END&&"Support for user key indices was dropped in favor of ImGuiKey. Please update backend & user code.");
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)");
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)");
// Check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only added in 1.60 WIP)
// Check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only added in 1.60 WIP)
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space]!=-1&&"ImGuiKey_Space is not mapped, required for keyboard navigation.");
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space]!=-1&&"ImGuiKey_Space is not mapped, required for keyboard navigation.");
#endif
// Check: the io.ConfigWindowsResizeFromEdges option requires backend to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
// Check: the io.ConfigWindowsResizeFromEdges option requires backend to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d",g.HoveredIdPreviousFrame,g.HoveredIdTimer,g.HoveredIdAllowOverlap);// Not displaying g.HoveredId as it is update mid-frame
Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d",g.HoveredIdPreviousFrame,g.HoveredIdTimer,g.HoveredIdAllowOverlap);// Not displaying g.HoveredId as it is update mid-frame
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
// Without IMGUI_DISABLE_OBSOLETE_KEYIO:
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
// - For 'ImGuiKey key' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
IMGUI_APIintGetKeyIndex(ImGuiKeyimgui_key);// map ImGuiKey_* values into user's key index. == io.KeyMap[key]
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
IMGUI_APIboolIsKeyDown(intuser_key_index);// is key being held. == io.KeysDown[user_key_index].
// With: IMGUI_DISABLE_OBSOLETE_KEYIO:
IMGUI_APIboolIsKeyPressed(intuser_key_index,boolrepeat=true);// was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
// - `ImGuiKey key` will assert when key < 512 will be passed, previously reserved as user keys indices
IMGUI_APIboolIsKeyReleased(intuser_key_index);// was key released (went from Down to !Down)?
// - GetKeyIndex() is pass-through and therefore deprecated (gone if IMGUI_DISABLE_OBSOLETE_KEYIO is defined)
IMGUI_APIintGetKeyPressedAmount(intkey_index,floatrepeat_delay,floatrate);// uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
IMGUI_APIintGetKeyIndex(ImGuiKeykey);// map ImGuiKey_* values into user's key index. == io.KeyMap[key]
#endif
IMGUI_APIconstchar*GetKeyName(ImGuiKeykey);// returns English name of the key
IMGUI_APIboolIsKeyDown(ImGuiKeykey);// is key being held. == io.KeysData[key - ImGuiKey_FirstKey].Down.
IMGUI_APIboolIsKeyPressed(ImGuiKeykey,boolrepeat=true);// was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate
IMGUI_APIboolIsKeyReleased(ImGuiKeykey);// was key released (went from Down to !Down)?
IMGUI_APIintGetKeyPressedAmount(intkey,floatrepeat_delay,floatrate);// uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate
IMGUI_APIvoidCaptureKeyboardFromApp(boolwant_capture_keyboard_value=true);// attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
IMGUI_APIvoidCaptureKeyboardFromApp(boolwant_capture_keyboard_value=true);// attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call.
// Inputs Utilities: Mouse
// Inputs Utilities: Mouse
@ -1349,10 +1356,17 @@ enum ImGuiSortDirection_
ImGuiSortDirection_Descending=2// Descending = 9->0, Z->A etc.
ImGuiSortDirection_Descending=2// Descending = 9->0, Z->A etc.
};
};
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
enumImGuiKey_
enumImGuiKey_
{
{
ImGuiKey_Tab,
ImGuiKey_None=0,
// Reserve range used by legacy io.KeyMap[]. Prior to 1.86 we required user to fill io.KeysDown[512] using their own native index.
// We are ditching this method but keeping a legacy path for user code doing e.g. IsKeyPressed(MY_NATIVE_KEY_CODE)
ImGuiKey_LegacyNativeKey_BEGIN=0,
ImGuiKey_LegacyNativeKey_END=512,// First index after valid range
ImGuiKey_NamedKey_BEGIN=512,
ImGuiKey_Tab=512,
ImGuiKey_LeftArrow,
ImGuiKey_LeftArrow,
ImGuiKey_RightArrow,
ImGuiKey_RightArrow,
ImGuiKey_UpArrow,
ImGuiKey_UpArrow,
@ -1367,14 +1381,110 @@ enum ImGuiKey_
ImGuiKey_Space,
ImGuiKey_Space,
ImGuiKey_Enter,
ImGuiKey_Enter,
ImGuiKey_Escape,
ImGuiKey_Escape,
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 backlash)
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_KeypadEnter,
ImGuiKey_A,// for text edit CTRL+A: select all
ImGuiKey_KeypadEqual,
ImGuiKey_C,// for text edit CTRL+C: copy
ImGuiKey_LeftShift,
ImGuiKey_V,// for text edit CTRL+V: paste
ImGuiKey_LeftControl,
ImGuiKey_X,// for text edit CTRL+X: cut
ImGuiKey_LeftAlt,
ImGuiKey_Y,// for text edit CTRL+Y: redo
ImGuiKey_LeftSuper,
ImGuiKey_Z,// for text edit CTRL+Z: undo
ImGuiKey_RightShift,
ImGuiKey_COUNT
ImGuiKey_RightControl,
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_COUNT,// No valid ImGuiKey is ever greater than this value
boolKeysDown[512];// Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
floatNavInputs[ImGuiNavInput_COUNT];// Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
floatNavInputs[ImGuiNavInput_COUNT];// Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
// Input Functions
// Input Functions
IMGUI_APIvoidAddKeyEvent(ImGuiKeykey,booldown,intnative_keycode=-1,intnative_scancode=-1);// Notify Dear ImGui of key down/up event
IMGUI_APIvoidAddFocusEvent(boolfocused);// Queue an hosting application/platform windows gain or loss of focus
IMGUI_APIvoidAddFocusEvent(boolfocused);// Queue an hosting application/platform windows gain or loss of focus
IMGUI_APIvoidAddInputCharacter(unsignedintc);// Queue new character input
IMGUI_APIvoidAddInputCharacter(unsignedintc);// Queue new character input
IMGUI_APIvoidAddInputCharacterUTF16(ImWchar16c);// Queue new character input from an UTF-16 character, it can be a surrogate
IMGUI_APIvoidAddInputCharacterUTF16(ImWchar16c);// Queue new character input from an UTF-16 character, it can be a surrogate
@ -1903,6 +2019,16 @@ struct ImGuiIO
IMGUI_APIvoidClearInputCharacters();// [Internal] Clear the text input buffer manually
IMGUI_APIvoidClearInputCharacters();// [Internal] Clear the text input buffer manually
IMGUI_APIvoidClearInputKeys();// [Internal] Release all keys
IMGUI_APIvoidClearInputKeys();// [Internal] Release all keys
intKeyMap[ImGuiKey_COUNT];// [LEGACY] Input: map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. The first 512 are now unused and should be kept zero. Legacy backend will write into KeyMap[] using ImGuiKey_ indices which are always >512.
boolKeysDown[512];// [LEGACY] Input: Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys).
floatKeysDownDuration[512];// Duration the key has been down (<0.0f: not pressed, 0.0f: just pressed, >0.0f: time held)
ImGuiKeyDataKeysData[ImGuiKey_KeyIndex_COUNT];// Key state for all known keys.
floatKeysDownDurationPrev[512];// Duration the key has been down (from previous frame)
boolWantCaptureMouseUnlessPopupClose;// Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
boolWantCaptureMouseUnlessPopupClose;// Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup.
ImVec2MousePosPrev;// Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
ImVec2MousePosPrev;// Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid)
@ -2851,6 +2976,10 @@ struct ImGuiPlatformImeData
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
namespaceImGui
namespaceImGui
{
{
// OBSOLETED in 1.XX (from YYYY)
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
staticinlineintGetKeyIndex(ImGuiKeykey){IM_ASSERT(key>=ImGuiKey_NamedKey_BEGIN&&key<ImGuiKey_NamedKey_END&&"ImGuiKey and user_key_index was merged together and user_key_index is disabled by IMGUI_DISABLE_OBSOLETE_KEYIO. Please switch to ImGuiKey.");returnkey;}
#endif
// OBSOLETED in 1.86 (from November 2021)
// OBSOLETED in 1.86 (from November 2021)
IMGUI_APIvoidCalcListClipping(intitems_count,floatitems_height,int*out_items_display_start,int*out_items_display_end);// Calculate coarse clipping for large list of evenly sized items. Prefer using ImGuiListClipper.
IMGUI_APIvoidCalcListClipping(intitems_count,floatitems_height,int*out_items_display_start,int*out_items_display_end);// Calculate coarse clipping for large list of evenly sized items. Prefer using ImGuiListClipper.
ImGui::Text("Chars queue:");for(inti=0;i<io.InputQueueCharacters.Size;i++){ImWcharc=io.InputQueueCharacters[i];ImGui::SameLine();ImGui::Text("\'%c\' (0x%04X)",(c>''&&c<=255)?(char)c:'?',c);}// FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
ImGui::Text("Chars queue:");for(inti=0;i<io.InputQueueCharacters.Size;i++){ImWcharc=io.InputQueueCharacters[i];ImGui::SameLine();ImGui::Text("\'%c\' (0x%04X)",(c>''&&c<=255)?(char)c:'?',c);}// FIXME: We should convert 'c' to UTF-8 here but the functions are not public.
voidSetBitRange(intn,intn2){ImBitArraySetBitRange(Storage,n,n2);}// Works on range [n..n2)
voidSetBitRange(intn,intn2){ImBitArraySetBitRange(Storage,n,n2);}// Works on range [n..n2)
};
};
template<intBITCOUNT>
constintImBitArray<BITCOUNT>::Size;
// Helper: ImBitVector
// Helper: ImBitVector
// Store 1-bit per value.
// Store 1-bit per value.
@ -1553,7 +1556,7 @@ struct ImGuiContext
boolActiveIdUsingMouseWheel;// Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
boolActiveIdUsingMouseWheel;// Active widget will want to read mouse wheel. Blocks scrolling the underlying window.
ImU32ActiveIdUsingNavDirMask;// Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
ImU32ActiveIdUsingNavDirMask;// Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
ImU32ActiveIdUsingNavInputMask;// Active widget will want to read those nav inputs.
ImU32ActiveIdUsingNavInputMask;// Active widget will want to read those nav inputs.
ImU64 ActiveIdUsingKeyInputMask;// Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
ImBitArray<ImGuiKey_NamedKey_COUNT>ActiveIdUsingKeyInputMask;// Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
ImVec2ActiveIdClickOffset;// Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
ImVec2ActiveIdClickOffset;// Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
ImGuiWindow*ActiveIdWindow;
ImGuiWindow*ActiveIdWindow;
ImGuiInputSourceActiveIdSource;// Activating with mouse or nav (gamepad/keyboard)
ImGuiInputSourceActiveIdSource;// Activating with mouse or nav (gamepad/keyboard)
if(flags&(ImGuiInputTextFlags_CallbackCompletion|ImGuiInputTextFlags_AllowTabInput))// Disable keyboard tabbing out as we will use the \t character.
{
SetActiveIdUsingKey(ImGuiKey_Tab);
}
}
}
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.