| 8073 | } |
| 8074 | |
| 8075 | ImGuiKeyRoutingData* ImGui::GetShortcutRoutingData(ImGuiKeyChord key_chord) |
| 8076 | { |
| 8077 | // Majority of shortcuts will be Key + any number of Mods |
| 8078 | // We accept _Single_ mod with ImGuiKey_None. |
| 8079 | // - Shortcut(ImGuiKey_S | ImGuiMod_Ctrl); // Legal |
| 8080 | // - Shortcut(ImGuiKey_S | ImGuiMod_Ctrl | ImGuiMod_Shift); // Legal |
| 8081 | // - Shortcut(ImGuiMod_Ctrl); // Legal |
| 8082 | // - Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift); // Not legal |
| 8083 | ImGuiContext& g = *GImGui; |
| 8084 | ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable; |
| 8085 | ImGuiKeyRoutingData* routing_data; |
| 8086 | if (key_chord & ImGuiMod_Shortcut) |
| 8087 | key_chord = ConvertShortcutMod(key_chord); |
| 8088 | ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_); |
| 8089 | ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_); |
| 8090 | if (key == ImGuiKey_None) |
| 8091 | key = ConvertSingleModFlagToKey(&g, mods); |
| 8092 | IM_ASSERT(IsNamedKey(key)); |
| 8093 | |
| 8094 | // Get (in the majority of case, the linked list will have one element so this should be 2 reads. |
| 8095 | // Subsequent elements will be contiguous in memory as list is sorted/rebuilt in NewFrame). |
| 8096 | for (ImGuiKeyRoutingIndex idx = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; idx != -1; idx = routing_data->NextEntryIndex) |
| 8097 | { |
| 8098 | routing_data = &rt->Entries[idx]; |
| 8099 | if (routing_data->Mods == mods) |
| 8100 | return routing_data; |
| 8101 | } |
| 8102 | |
| 8103 | // Add to linked-list |
| 8104 | ImGuiKeyRoutingIndex routing_data_idx = (ImGuiKeyRoutingIndex)rt->Entries.Size; |
| 8105 | rt->Entries.push_back(ImGuiKeyRoutingData()); |
| 8106 | routing_data = &rt->Entries[routing_data_idx]; |
| 8107 | routing_data->Mods = (ImU16)mods; |
| 8108 | routing_data->NextEntryIndex = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; // Setup linked list |
| 8109 | rt->Index[key - ImGuiKey_NamedKey_BEGIN] = routing_data_idx; |
| 8110 | return routing_data; |
| 8111 | } |
| 8112 | |
| 8113 | // Current score encoding (lower is highest priority): |
| 8114 | // - 0: ImGuiInputFlags_RouteGlobalHigh |
nothing calls this directly
no test coverage detected