MCPcopy Create free account
hub / github.com/cinder/Cinder / GetShortcutRoutingData

Method GetShortcutRoutingData

src/imgui/imgui.cpp:9399–9433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9397}
9398
9399ImGuiKeyRoutingData* ImGui::GetShortcutRoutingData(ImGuiKeyChord key_chord)
9400{
9401 // Majority of shortcuts will be Key + any number of Mods
9402 // We accept _Single_ mod with ImGuiKey_None.
9403 // - Shortcut(ImGuiKey_S | ImGuiMod_Ctrl); // Legal
9404 // - Shortcut(ImGuiKey_S | ImGuiMod_Ctrl | ImGuiMod_Shift); // Legal
9405 // - Shortcut(ImGuiMod_Ctrl); // Legal
9406 // - Shortcut(ImGuiMod_Ctrl | ImGuiMod_Shift); // Not legal
9407 ImGuiContext& g = *GImGui;
9408 ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
9409 ImGuiKeyRoutingData* routing_data;
9410 ImGuiKey key = (ImGuiKey)(key_chord & ~ImGuiMod_Mask_);
9411 ImGuiKey mods = (ImGuiKey)(key_chord & ImGuiMod_Mask_);
9412 if (key == ImGuiKey_None)
9413 key = ConvertSingleModFlagToKey(mods);
9414 IM_ASSERT(IsNamedKey(key));
9415
9416 // Get (in the majority of case, the linked list will have one element so this should be 2 reads.
9417 // Subsequent elements will be contiguous in memory as list is sorted/rebuilt in NewFrame).
9418 for (ImGuiKeyRoutingIndex idx = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; idx != -1; idx = routing_data->NextEntryIndex)
9419 {
9420 routing_data = &rt->Entries[idx];
9421 if (routing_data->Mods == mods)
9422 return routing_data;
9423 }
9424
9425 // Add to linked-list
9426 ImGuiKeyRoutingIndex routing_data_idx = (ImGuiKeyRoutingIndex)rt->Entries.Size;
9427 rt->Entries.push_back(ImGuiKeyRoutingData());
9428 routing_data = &rt->Entries[routing_data_idx];
9429 routing_data->Mods = (ImU16)mods;
9430 routing_data->NextEntryIndex = rt->Index[key - ImGuiKey_NamedKey_BEGIN]; // Setup linked list
9431 rt->Index[key - ImGuiKey_NamedKey_BEGIN] = routing_data_idx;
9432 return routing_data;
9433}
9434
9435// Current score encoding (lower is highest priority):
9436// - 0: ImGuiInputFlags_RouteGlobal | ImGuiInputFlags_RouteOverActive

Callers

nothing calls this directly

Calls 4

IsNamedKeyFunction · 0.85
ImGuiKeyRoutingDataClass · 0.85
push_backMethod · 0.45

Tested by

no test coverage detected