mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
IO: Reorder enums, compact a little in header. Removed const from internal GetKeyData().
This commit is contained in:
parent
91ae56af45
commit
97b1ffcb3b
12
imgui.cpp
12
imgui.cpp
@ -7444,7 +7444,7 @@ bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool c
|
||||
return true;
|
||||
}
|
||||
|
||||
const ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
|
||||
ImGuiKeyData* ImGui::GetKeyData(ImGuiKey key)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
int index;
|
||||
@ -7476,15 +7476,15 @@ static const char* const GKeyNames[] =
|
||||
{
|
||||
"Tab", "LeftArrow", "RightArrow", "UpArrow", "DownArrow", "PageUp", "PageDown",
|
||||
"Home", "End", "Insert", "Delete", "Backspace", "Space", "Enter", "Escape",
|
||||
"LeftCtrl", "LeftShift", "LeftAlt", "LeftSuper", "RightCtrl", "RightShift", "RightAlt", "RightSuper", "Menu",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12",
|
||||
"Apostrophe", "Comma", "Minus", "Period", "Slash", "Semicolon", "Equal", "LeftBracket",
|
||||
"Backslash", "RightBracket", "GraveAccent", "CapsLock", "ScrollLock", "NumLock", "PrintScreen",
|
||||
"Pause", "Keypad0", "Keypad1", "Keypad2", "Keypad3", "Keypad4", "Keypad5", "Keypad6",
|
||||
"Keypad7", "Keypad8", "Keypad9", "KeypadDecimal", "KeypadDivide", "KeypadMultiply",
|
||||
"KeypadSubtract", "KeypadAdd", "KeypadEnter", "KeypadEqual", "LeftCtrl", "LeftShift",
|
||||
"LeftAlt", "LeftSuper", "RightCtrl", "RightShift", "RightAlt", "RightSuper", "Menu",
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
||||
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
||||
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12"
|
||||
"KeypadSubtract", "KeypadAdd", "KeypadEnter", "KeypadEqual"
|
||||
};
|
||||
IM_STATIC_ASSERT(ImGuiKey_NamedKey_COUNT == IM_ARRAYSIZE(GKeyNames));
|
||||
|
||||
|
116
imgui.h
116
imgui.h
@ -1342,8 +1342,8 @@ enum ImGuiSortDirection_
|
||||
|
||||
enum ImGuiKey_
|
||||
{
|
||||
ImGuiKey_None = 0,
|
||||
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
||||
ImGuiKey_None = 0,
|
||||
ImGuiKey_Tab = 512, // == ImGuiKey_NamedKey_BEGIN
|
||||
ImGuiKey_LeftArrow,
|
||||
ImGuiKey_RightArrow,
|
||||
ImGuiKey_UpArrow,
|
||||
@ -1358,32 +1358,33 @@ enum ImGuiKey_
|
||||
ImGuiKey_Space,
|
||||
ImGuiKey_Enter,
|
||||
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_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_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_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,
|
||||
@ -1391,78 +1392,21 @@ enum ImGuiKey_
|
||||
ImGuiKey_KeypadAdd,
|
||||
ImGuiKey_KeypadEnter,
|
||||
ImGuiKey_KeypadEqual,
|
||||
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_COUNT, // No valid ImGuiKey is ever greater than this value
|
||||
ImGuiKey_COUNT, // No valid ImGuiKey is ever greater than this value
|
||||
|
||||
// Legacy range used by legacy io.KeyMap[]. Prior to 1.87 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_LegacyNativeKey_END = 512,
|
||||
ImGuiKey_NamedKey_BEGIN = 512,
|
||||
ImGuiKey_NamedKey_END = ImGuiKey_COUNT,
|
||||
ImGuiKey_NamedKey_COUNT = ImGuiKey_NamedKey_END - ImGuiKey_NamedKey_BEGIN,
|
||||
#ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN // First key stored in KeysData[0]
|
||||
ImGuiKey_KeysData_SIZE = ImGuiKey_NamedKey_COUNT, // Size of KeysData[]: only hold named keys
|
||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_NamedKey_BEGIN // First key stored in KeysData[0]
|
||||
#else
|
||||
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_LegacyNativeKey_BEGIN // First key stored in KeysData[0]
|
||||
ImGuiKey_KeysData_SIZE = ImGuiKey_COUNT, // Size of KeysData[]: hold legacy 0..512 keycodes + named keys
|
||||
ImGuiKey_KeysData_OFFSET = ImGuiKey_LegacyNativeKey_BEGIN // First key stored in KeysData[0]
|
||||
#endif
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
@ -483,6 +483,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
"Here we expose them as read-only fields to avoid breaking interactions with your backend.");
|
||||
|
||||
// Make a local copy to avoid modifying actual backend flags.
|
||||
// FIXME: We don't use BeginDisabled() to keep label bright, maybe we need a BeginReadonly() equivalent..
|
||||
ImGuiBackendFlags backend_flags = io.BackendFlags;
|
||||
ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backend_flags, ImGuiBackendFlags_HasGamepad);
|
||||
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backend_flags, ImGuiBackendFlags_HasMouseCursors);
|
||||
@ -5637,7 +5638,7 @@ static void ShowDemoWindowColumns()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
namespace ImGui { extern const ImGuiKeyData* GetKeyData(ImGuiKey key); }
|
||||
namespace ImGui { extern ImGuiKeyData* GetKeyData(ImGuiKey key); }
|
||||
|
||||
static void ShowDemoWindowMisc()
|
||||
{
|
||||
@ -5702,9 +5703,9 @@ static void ShowDemoWindowMisc()
|
||||
#else
|
||||
struct funcs { static bool IsNativeDupe(ImGuiKey key) { return key < ImGuiKey_LegacyNativeKey_END && ImGui::GetIO().KeyMap[key] != -1; } }; // Hide Native<>ImGuiKey duplicates when both exists in the array
|
||||
#endif
|
||||
ImGui::Text("Keys down:"); for (int i = 0; i < ImGuiKey_KeysData_SIZE; i++) { ImGuiKey key = (ImGuiKey)(i + ImGuiKey_KeysData_OFFSET); if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (0x%X) (%.02f secs)", ImGui::GetKeyName(key), key, key, ImGui::GetKeyData(key)->DownDuration); } }
|
||||
ImGui::Text("Keys pressed:"); for (int i = 0; i < ImGuiKey_KeysData_SIZE; i++) { ImGuiKey key = (ImGuiKey)(i + ImGuiKey_KeysData_OFFSET); if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (0x%X)", ImGui::GetKeyName(key), key, key); } }
|
||||
ImGui::Text("Keys released:"); for (int i = 0; i < ImGuiKey_KeysData_SIZE; i++) { ImGuiKey key = (ImGuiKey)(i + ImGuiKey_KeysData_OFFSET); if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (0x%X)", ImGui::GetKeyName(key), key, key); } }
|
||||
ImGui::Text("Keys down:"); for (int i = 0; i < ImGuiKey_KeysData_SIZE; i++) { ImGuiKey key = (ImGuiKey)(i + ImGuiKey_KeysData_OFFSET); if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyDown(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d (%.02f secs)", ImGui::GetKeyName(key), key, ImGui::GetKeyData(key)->DownDuration); } }
|
||||
ImGui::Text("Keys pressed:"); for (int i = 0; i < ImGuiKey_KeysData_SIZE; i++) { ImGuiKey key = (ImGuiKey)(i + ImGuiKey_KeysData_OFFSET); if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyPressed(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||
ImGui::Text("Keys released:"); for (int i = 0; i < ImGuiKey_KeysData_SIZE; i++) { ImGuiKey key = (ImGuiKey)(i + ImGuiKey_KeysData_OFFSET); if (funcs::IsNativeDupe(key)) continue; if (ImGui::IsKeyReleased(key)) { ImGui::SameLine(); ImGui::Text("\"%s\" %d", ImGui::GetKeyName(key), key); } }
|
||||
ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : "");
|
||||
ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = 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.
|
||||
|
||||
|
@ -937,7 +937,6 @@ struct ImGuiInputEvent
|
||||
{
|
||||
ImGuiInputEventType Type;
|
||||
ImGuiInputSource Source;
|
||||
bool SubmittedByTestEngine;
|
||||
union
|
||||
{
|
||||
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
|
||||
@ -948,6 +947,7 @@ struct ImGuiInputEvent
|
||||
ImGuiInputEventText Text; // if Type == ImGuiInputEventType_Text
|
||||
ImGuiInputEventAppFocused AppFocused; // if Type == ImGuiInputEventType_Focus
|
||||
};
|
||||
bool AddedByTestEngine;
|
||||
|
||||
ImGuiInputEvent() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
@ -2640,7 +2640,7 @@ namespace ImGui
|
||||
// FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions.
|
||||
inline bool IsNamedKey(ImGuiKey key) { return key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END; }
|
||||
inline bool IsLegacyKey(ImGuiKey key) { return key >= ImGuiKey_LegacyNativeKey_BEGIN && key < ImGuiKey_LegacyNativeKey_END; }
|
||||
IMGUI_API const ImGuiKeyData* GetKeyData(ImGuiKey key);
|
||||
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiKey key);
|
||||
IMGUI_API void SetItemUsingMouseWheel();
|
||||
IMGUI_API void SetActiveIdUsingNavAndKeys();
|
||||
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
|
||||
|
Loading…
Reference in New Issue
Block a user