Internals: renamed IsModKey() -> IsLRModKey() and GetModForModKey() -> GetModForLRModKey() to be more explicit.

This commit is contained in:
ocornut 2024-08-19 18:28:56 +02:00
parent 61313a7589
commit fabceaf036
2 changed files with 7 additions and 7 deletions

View File

@ -8407,7 +8407,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// [SECTION] INPUTS // [SECTION] INPUTS
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// - GetModForModKey() [Internal] // - GetModForLRModKey() [Internal]
// - FixupKeyChord() [Internal] // - FixupKeyChord() [Internal]
// - GetKeyData() [Internal] // - GetKeyData() [Internal]
// - GetKeyIndex() [Internal] // - GetKeyIndex() [Internal]
@ -8470,7 +8470,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
// - Shortcut() [Internal] // - Shortcut() [Internal]
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static ImGuiKeyChord GetModForModKey(ImGuiKey key) static ImGuiKeyChord GetModForLRModKey(ImGuiKey key)
{ {
if (key == ImGuiKey_LeftCtrl || key == ImGuiKey_RightCtrl) if (key == ImGuiKey_LeftCtrl || key == ImGuiKey_RightCtrl)
return ImGuiMod_Ctrl; return ImGuiMod_Ctrl;
@ -8487,8 +8487,8 @@ ImGuiKeyChord ImGui::FixupKeyChord(ImGuiKeyChord key_chord)
{ {
// Add ImGuiMod_XXXX when a corresponding ImGuiKey_LeftXXX/ImGuiKey_RightXXX is specified. // Add ImGuiMod_XXXX when a corresponding ImGuiKey_LeftXXX/ImGuiKey_RightXXX is specified.
ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_); ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
if (IsModKey(key)) if (IsLRModKey(key))
key_chord |= GetModForModKey(key); key_chord |= GetModForLRModKey(key);
return key_chord; return key_chord;
} }
@ -8579,8 +8579,8 @@ const char* ImGui::GetKeyChordName(ImGuiKeyChord key_chord)
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
const ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_); const ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
if (IsModKey(key)) if (IsLRModKey(key))
key_chord &= ~GetModForModKey(key); // Return "Ctrl+LeftShift" instead of "Ctrl+Shift+LeftShift" key_chord &= ~GetModForLRModKey(key); // Return "Ctrl+LeftShift" instead of "Ctrl+Shift+LeftShift"
ImFormatString(g.TempKeychordName, IM_ARRAYSIZE(g.TempKeychordName), "%s%s%s%s%s", ImFormatString(g.TempKeychordName, IM_ARRAYSIZE(g.TempKeychordName), "%s%s%s%s%s",
(key_chord & ImGuiMod_Ctrl) ? "Ctrl+" : "", (key_chord & ImGuiMod_Ctrl) ? "Ctrl+" : "",
(key_chord & ImGuiMod_Shift) ? "Shift+" : "", (key_chord & ImGuiMod_Shift) ? "Shift+" : "",

View File

@ -3298,7 +3298,7 @@ namespace ImGui
inline bool IsGamepadKey(ImGuiKey key) { return key >= ImGuiKey_Gamepad_BEGIN && key < ImGuiKey_Gamepad_END; } inline bool IsGamepadKey(ImGuiKey key) { return key >= ImGuiKey_Gamepad_BEGIN && key < ImGuiKey_Gamepad_END; }
inline bool IsMouseKey(ImGuiKey key) { return key >= ImGuiKey_Mouse_BEGIN && key < ImGuiKey_Mouse_END; } inline bool IsMouseKey(ImGuiKey key) { return key >= ImGuiKey_Mouse_BEGIN && key < ImGuiKey_Mouse_END; }
inline bool IsAliasKey(ImGuiKey key) { return key >= ImGuiKey_Aliases_BEGIN && key < ImGuiKey_Aliases_END; } inline bool IsAliasKey(ImGuiKey key) { return key >= ImGuiKey_Aliases_BEGIN && key < ImGuiKey_Aliases_END; }
inline bool IsModKey(ImGuiKey key) { return key >= ImGuiKey_LeftCtrl && key <= ImGuiKey_RightSuper; } inline bool IsLRModKey(ImGuiKey key) { return key >= ImGuiKey_LeftCtrl && key <= ImGuiKey_RightSuper; }
ImGuiKeyChord FixupKeyChord(ImGuiKeyChord key_chord); ImGuiKeyChord FixupKeyChord(ImGuiKeyChord key_chord);
inline ImGuiKey ConvertSingleModFlagToKey(ImGuiKey key) inline ImGuiKey ConvertSingleModFlagToKey(ImGuiKey key)
{ {