mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Experiment: ImGuiKey is now a typed enum, allowing ImGuiKey_XXX symbols to be named in debuggers. (#4921, #4537)
May affect binding generators.
This commit is contained in:
10
imgui.cpp
10
imgui.cpp
@ -1356,14 +1356,14 @@ void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native
|
||||
if (key == ImGuiKey_None)
|
||||
return;
|
||||
IM_ASSERT(ImGui::IsNamedKey(key)); // >= 512
|
||||
IM_ASSERT(native_legacy_index == -1 || ImGui::IsLegacyKey(native_legacy_index)); // >= 0 && <= 511
|
||||
IM_ASSERT(native_legacy_index == -1 || ImGui::IsLegacyKey((ImGuiKey)native_legacy_index)); // >= 0 && <= 511
|
||||
IM_UNUSED(native_keycode); // Yet unused
|
||||
IM_UNUSED(native_scancode); // Yet unused
|
||||
|
||||
// Build native->imgui map so old user code can still call key functions with native 0..511 values.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
const int legacy_key = (native_legacy_index != -1) ? native_legacy_index : native_keycode;
|
||||
if (!ImGui::IsLegacyKey(legacy_key))
|
||||
if (!ImGui::IsLegacyKey((ImGuiKey)legacy_key))
|
||||
return;
|
||||
KeyMap[legacy_key] = key;
|
||||
KeyMap[key] = legacy_key;
|
||||
@ -4057,7 +4057,7 @@ static void ImGui::UpdateKeyboardInputs()
|
||||
{
|
||||
// Backend used new io.AddKeyEvent() API: Good! Verify that old arrays are never written to externally.
|
||||
for (int n = 0; n < ImGuiKey_LegacyNativeKey_END; n++)
|
||||
IM_ASSERT((io.KeysDown[n] == false || IsKeyDown(n)) && "Backend needs to either only use io.AddKeyEvent(), either only fill legacy io.KeysDown[] + io.KeyMap[]. Not both!");
|
||||
IM_ASSERT((io.KeysDown[n] == false || IsKeyDown((ImGuiKey)n)) && "Backend needs to either only use io.AddKeyEvent(), either only fill legacy io.KeysDown[] + io.KeyMap[]. Not both!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -7749,12 +7749,12 @@ ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
|
||||
}
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
int ImGui::GetKeyIndex(ImGuiKey key)
|
||||
ImGuiKey ImGui::GetKeyIndex(ImGuiKey key)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(IsNamedKey(key));
|
||||
const ImGuiKeyData* key_data = GetKeyData(key);
|
||||
return (int)(key_data - g.IO.KeysData);
|
||||
return (ImGuiKey)(key_data - g.IO.KeysData);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user