| 4256 | } |
| 4257 | |
| 4258 | void ImGui::Initialize() |
| 4259 | { |
| 4260 | ImGuiContext& g = *GImGui; |
| 4261 | IM_ASSERT(!g.Initialized && !g.SettingsLoaded); |
| 4262 | |
| 4263 | // Add .ini handle for ImGuiWindow and ImGuiTable types |
| 4264 | { |
| 4265 | ImGuiSettingsHandler ini_handler; |
| 4266 | ini_handler.TypeName = "Window"; |
| 4267 | ini_handler.TypeHash = ImHashStr("Window"); |
| 4268 | ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll; |
| 4269 | ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen; |
| 4270 | ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine; |
| 4271 | ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll; |
| 4272 | ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll; |
| 4273 | AddSettingsHandler(&ini_handler); |
| 4274 | } |
| 4275 | TableSettingsAddSettingsHandler(); |
| 4276 | |
| 4277 | // Setup default localization table |
| 4278 | LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_ARRAYSIZE(GLocalizationEntriesEnUS)); |
| 4279 | |
| 4280 | // Setup default ImGuiPlatformIO clipboard/IME handlers. |
| 4281 | g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations |
| 4282 | g.PlatformIO.Platform_SetClipboardTextFn = Platform_SetClipboardTextFn_DefaultImpl; |
| 4283 | g.PlatformIO.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl; |
| 4284 | g.PlatformIO.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl; |
| 4285 | |
| 4286 | // Create default viewport |
| 4287 | ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)(); |
| 4288 | viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID; |
| 4289 | g.Viewports.push_back(viewport); |
| 4290 | g.TempBuffer.resize(1024 * 3 + 1, 0); |
| 4291 | |
| 4292 | // Build KeysMayBeCharInput[] lookup table (1 bool per named key) |
| 4293 | for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1)) |
| 4294 | if ((key >= ImGuiKey_0 && key <= ImGuiKey_9) || (key >= ImGuiKey_A && key <= ImGuiKey_Z) || (key >= ImGuiKey_Keypad0 && key <= ImGuiKey_Keypad9) |
| 4295 | || key == ImGuiKey_Tab || key == ImGuiKey_Space || key == ImGuiKey_Apostrophe || key == ImGuiKey_Comma || key == ImGuiKey_Minus || key == ImGuiKey_Period |
| 4296 | || key == ImGuiKey_Slash || key == ImGuiKey_Semicolon || key == ImGuiKey_Equal || key == ImGuiKey_LeftBracket || key == ImGuiKey_RightBracket || key == ImGuiKey_GraveAccent |
| 4297 | || key == ImGuiKey_KeypadDecimal || key == ImGuiKey_KeypadDivide || key == ImGuiKey_KeypadMultiply || key == ImGuiKey_KeypadSubtract || key == ImGuiKey_KeypadAdd || key == ImGuiKey_KeypadEqual) |
| 4298 | g.KeysMayBeCharInput.SetBit(key); |
| 4299 | |
| 4300 | #ifdef IMGUI_HAS_DOCK |
| 4301 | #endif |
| 4302 | |
| 4303 | // Print a debug message when running with debug feature IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS because it is very slow. |
| 4304 | // DO NOT COMMENT OUT THIS MESSAGE. IT IS DESIGNED TO REMIND YOU THAT IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS SHOULD ONLY BE TEMPORARILY ENABLED. |
| 4305 | #ifdef IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS |
| 4306 | DebugLog("IMGUI_DEBUG_HIGHLIGHT_ALL_ID_CONFLICTS is enabled.\nMust disable after use! Otherwise Dear ImGui will run slower.\n"); |
| 4307 | #endif |
| 4308 | |
| 4309 | // ImDrawList/ImFontAtlas are designed to function without ImGui, and 99% of it works without an ImGui context. |
| 4310 | // But this link allows us to facilitate/handle a few edge cases better. |
| 4311 | ImFontAtlas* atlas = g.IO.Fonts; |
| 4312 | g.DrawListSharedData.Context = &g; |
| 4313 | RegisterFontAtlas(atlas); |
| 4314 | |
| 4315 | g.Initialized = true; |