|
@@ -257,6 +257,7 @@
|
|
|
- you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance.
|
|
|
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
|
|
|
- removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
|
|
|
+ - 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
|
|
|
- 2018/01/11 (1.60) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
|
|
|
- 2018/01/11 (1.60) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
|
|
|
- 2018/01/03 (1.60) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
|
|
@@ -547,11 +548,15 @@
|
|
|
|
|
|
Q: How can I load a different font than the default? (default is an embedded version of ProggyClean.ttf, rendered at size 13)
|
|
|
A: Use the font atlas to load the TTF/OTF file you want:
|
|
|
-
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
|
|
|
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
|
|
|
|
|
|
+ New programmers: remember that in C/C++ and most programming languages if you want to use a backslash \ in a string literal you need to write a double backslash "\\":
|
|
|
+ io.Fonts->AddFontFromFileTTF("MyDataFolder\MyFontFile.ttf", size_in_pixels); // WRONG
|
|
|
+ io.Fonts->AddFontFromFileTTF("MyDataFolder\\MyFontFile.ttf", size_in_pixels); // CORRECT
|
|
|
+ io.Fonts->AddFontFromFileTTF("MyDataFolder/MyFontFile.ttf", size_in_pixels); // ALSO CORRECT
|
|
|
+
|
|
|
Q: How can I easily use icons in my application?
|
|
|
A: The most convenient and practical way is to merge an icon font such as FontAwesome inside you main font. Then you can refer to icons within your
|
|
|
strings. Read 'How can I load multiple fonts?' and the file 'misc/fonts/README.txt' for instructions and useful header files.
|
|
@@ -2636,6 +2641,7 @@ ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas)
|
|
|
ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas);
|
|
|
if (GImGui == NULL)
|
|
|
SetCurrentContext(ctx);
|
|
|
+ Initialize(ctx);
|
|
|
return ctx;
|
|
|
}
|
|
|
|
|
@@ -3280,6 +3286,7 @@ void ImGui::NewFrame()
|
|
|
|
|
|
// Check user data
|
|
|
// (We pass an error message in the assert expression as a trick to get it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
|
|
+ IM_ASSERT(g.Initialized);
|
|
|
IM_ASSERT(g.IO.DeltaTime >= 0.0f && "Need a positive DeltaTime (zero is tolerated but will cause some timing issues)");
|
|
|
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value");
|
|
|
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
|
@@ -3294,9 +3301,13 @@ void ImGui::NewFrame()
|
|
|
if (g.IO.NavFlags & ImGuiNavFlags_EnableKeyboard)
|
|
|
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
|
|
|
|
|
- // Initialize on first frame
|
|
|
- if (!g.Initialized)
|
|
|
- Initialize(&g);
|
|
|
+ // Load settings on first frame
|
|
|
+ if (!g.SettingsLoaded)
|
|
|
+ {
|
|
|
+ IM_ASSERT(g.SettingsWindows.empty());
|
|
|
+ LoadIniSettingsFromDisk(g.IO.IniFilename);
|
|
|
+ g.SettingsLoaded = true;
|
|
|
+ }
|
|
|
|
|
|
g.Time += g.IO.DeltaTime;
|
|
|
g.FrameCount += 1;
|
|
@@ -3602,6 +3613,7 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSetting
|
|
|
void ImGui::Initialize(ImGuiContext* context)
|
|
|
{
|
|
|
ImGuiContext& g = *context;
|
|
|
+ IM_ASSERT(!g.Initialized && !g.SettingsLoaded);
|
|
|
g.LogClipboard = IM_NEW(ImGuiTextBuffer)();
|
|
|
|
|
|
// Add .ini handle for ImGuiWindow type
|
|
@@ -3613,9 +3625,6 @@ void ImGui::Initialize(ImGuiContext* context)
|
|
|
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
|
|
|
g.SettingsHandlers.push_front(ini_handler);
|
|
|
|
|
|
- // Load .ini file
|
|
|
- IM_ASSERT(g.SettingsWindows.empty());
|
|
|
- LoadIniSettingsFromDisk(g.IO.IniFilename);
|
|
|
g.Initialized = true;
|
|
|
}
|
|
|
|
|
@@ -3765,6 +3774,7 @@ static void LoadIniSettingsFromMemory(const char* buf_readonly)
|
|
|
}
|
|
|
}
|
|
|
ImGui::MemFree(buf);
|
|
|
+ g.SettingsLoaded = true;
|
|
|
}
|
|
|
|
|
|
static void SaveIniSettingsToDisk(const char* ini_filename)
|