| 4401 | } |
| 4402 | |
| 4403 | void ImGui::Initialize() |
| 4404 | { |
| 4405 | ImGuiContext& g = *GImGui; |
| 4406 | IM_ASSERT(!g.Initialized && !g.SettingsLoaded); |
| 4407 | |
| 4408 | // Add .ini handle for ImGuiWindow and ImGuiTable types |
| 4409 | { |
| 4410 | ImGuiSettingsHandler ini_handler; |
| 4411 | ini_handler.TypeName = "Window"; |
| 4412 | ini_handler.TypeHash = ImHashStr("Window"); |
| 4413 | ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll; |
| 4414 | ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen; |
| 4415 | ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine; |
| 4416 | ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll; |
| 4417 | ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll; |
| 4418 | AddSettingsHandler(&ini_handler); |
| 4419 | } |
| 4420 | TableSettingsAddSettingsHandler(); |
| 4421 | |
| 4422 | // Setup default localization table |
| 4423 | LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_COUNTOF(GLocalizationEntriesEnUS)); |
| 4424 | |
| 4425 | // Setup default ImGuiPlatformIO clipboard/IME handlers. |
| 4426 | g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations |
| 4427 | g.PlatformIO.Platform_SetClipboardTextFn = Platform_SetClipboardTextFn_DefaultImpl; |
| 4428 | g.PlatformIO.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl; |
| 4429 | g.PlatformIO.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl; |
| 4430 | |
| 4431 | // Create default viewport |
| 4432 | ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)(); |
| 4433 | viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID; |
| 4434 | g.Viewports.push_back(viewport); |
| 4435 | g.TempBuffer.resize(1024 * 3 + 1, 0); |
| 4436 | |
| 4437 | // Build KeysMayBeCharInput[] lookup table (1 bit per named key) |
| 4438 | for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1)) |
| 4439 | if ((key >= ImGuiKey_0 && key <= ImGuiKey_9) || (key >= ImGuiKey_A && key <= ImGuiKey_Z) || (key >= ImGuiKey_Keypad0 && key <= ImGuiKey_Keypad9) |
| 4440 | || key == ImGuiKey_Tab || key == ImGuiKey_Space || key == ImGuiKey_Apostrophe || key == ImGuiKey_Comma || key == ImGuiKey_Minus || key == ImGuiKey_Period |
| 4441 | || key == ImGuiKey_Slash || key == ImGuiKey_Semicolon || key == ImGuiKey_Equal || key == ImGuiKey_LeftBracket || key == ImGuiKey_RightBracket || key == ImGuiKey_GraveAccent |
| 4442 | || key == ImGuiKey_KeypadDecimal || key == ImGuiKey_KeypadDivide || key == ImGuiKey_KeypadMultiply || key == ImGuiKey_KeypadSubtract || key == ImGuiKey_KeypadAdd || key == ImGuiKey_KeypadEqual) |
| 4443 | g.KeysMayBeCharInput.SetBit(key); |
| 4444 | |
| 4445 | #ifdef IMGUI_HAS_DOCK |
| 4446 | #endif |
| 4447 | |
| 4448 | // Print a debug message when running with debug feature IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS because it is very slow. |
| 4449 | // DO NOT COMMENT OUT THIS MESSAGE. IT IS DESIGNED TO REMIND YOU THAT IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS SHOULD ONLY BE TEMPORARILY ENABLED. |
| 4450 | #ifdef IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS |
| 4451 | DebugLog("IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS is enabled.\nMust disable after use! Otherwise Dear ImGui will run slower.\n"); |
| 4452 | #endif |
| 4453 | |
| 4454 | // ImDrawList/ImFontAtlas are designed to function without ImGui, and 99% of it works without an ImGui context. |
| 4455 | // But this link allows us to facilitate/handle a few edge cases better. |
| 4456 | ImFontAtlas* atlas = g.IO.Fonts; |
| 4457 | g.DrawListSharedData.Context = &g; |
| 4458 | RegisterFontAtlas(atlas); |
| 4459 | |
| 4460 | g.Initialized = true; |
no test coverage detected