mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Fonts: proof of concept support for user textures.
# Conflicts: # imgui.h # imgui_internal.h
This commit is contained in:
parent
91ed6e67b4
commit
39f6c793b3
3 changed files with 22 additions and 1 deletions
15
imgui.cpp
15
imgui.cpp
|
|
@ -5231,6 +5231,8 @@ static void ImGui::UpdateTexturesEndFrame()
|
||||||
tex->RefCount = (unsigned short)atlas->RefCount;
|
tex->RefCount = (unsigned short)atlas->RefCount;
|
||||||
g.PlatformIO.Textures.push_back(tex);
|
g.PlatformIO.Textures.push_back(tex);
|
||||||
}
|
}
|
||||||
|
for (ImTextureData* tex : g.UserTextures)
|
||||||
|
g.PlatformIO.Textures.push_back(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called once a frame. Followed by SetCurrentFont() which sets up the remaining data.
|
// Called once a frame. Followed by SetCurrentFont() which sets up the remaining data.
|
||||||
|
|
@ -8613,6 +8615,19 @@ void ImGui::UpdateFontsEndFrame()
|
||||||
PopFont();
|
PopFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::RegisterUserTexture(ImTextureData* tex)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
IM_ASSERT(tex->RefCount > 0);
|
||||||
|
g.UserTextures.push_back(tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::UnregisterUserTexture(ImTextureData* tex)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
g.UserTextures.find_erase(tex);
|
||||||
|
}
|
||||||
|
|
||||||
void ImGui::RegisterFontAtlas(ImFontAtlas* atlas)
|
void ImGui::RegisterFontAtlas(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
|
|
|
||||||
2
imgui.h
2
imgui.h
|
|
@ -3905,7 +3905,7 @@ struct ImGuiPlatformIO
|
||||||
|
|
||||||
// Textures list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
|
// Textures list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
|
||||||
// The ImGui_ImplXXXX_RenderDrawData() function of each backend generally access this via ImDrawData::Textures which points to this. The array is available here mostly because backends will want to destroy textures on shutdown.
|
// The ImGui_ImplXXXX_RenderDrawData() function of each backend generally access this via ImDrawData::Textures which points to this. The array is available here mostly because backends will want to destroy textures on shutdown.
|
||||||
ImVector<ImTextureData*> Textures; // List of textures used by Dear ImGui (most often 1).
|
ImVector<ImTextureData*> Textures; // List of textures used by Dear ImGui (most often 1) + contents of external texture list is automatically appended into this.
|
||||||
};
|
};
|
||||||
|
|
||||||
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function. Handler is called during EndFrame().
|
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function. Handler is called during EndFrame().
|
||||||
|
|
|
||||||
|
|
@ -2426,6 +2426,10 @@ struct ImGuiContext
|
||||||
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame. Will be applied at end of the frame. For some backends, this is required to have WantVisible=true in order to receive text message.
|
ImGuiPlatformImeData PlatformImeData; // Data updated by current frame. Will be applied at end of the frame. For some backends, this is required to have WantVisible=true in order to receive text message.
|
||||||
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler.
|
ImGuiPlatformImeData PlatformImeDataPrev; // Previous frame data. When changed we call the platform_io.Platform_SetImeDataFn() handler.
|
||||||
|
|
||||||
|
// Extensions
|
||||||
|
// FIXME: We could provide an API to register one slot in an array held in ImGuiContext?
|
||||||
|
ImVector<ImTextureData*> UserTextures; // List of textures created/managed by user or third-party extension. Automatically appended into platform_io.Textures[].
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
bool SettingsLoaded;
|
bool SettingsLoaded;
|
||||||
float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
|
float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero
|
||||||
|
|
@ -3108,6 +3112,8 @@ namespace ImGui
|
||||||
IMGUI_API void SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags);
|
IMGUI_API void SetNextWindowRefreshPolicy(ImGuiWindowRefreshFlags flags);
|
||||||
|
|
||||||
// Fonts, drawing
|
// Fonts, drawing
|
||||||
|
IMGUI_API void RegisterUserTexture(ImTextureData* tex); // Register external texture
|
||||||
|
IMGUI_API void UnregisterUserTexture(ImTextureData* tex);
|
||||||
IMGUI_API void RegisterFontAtlas(ImFontAtlas* atlas);
|
IMGUI_API void RegisterFontAtlas(ImFontAtlas* atlas);
|
||||||
IMGUI_API void UnregisterFontAtlas(ImFontAtlas* atlas);
|
IMGUI_API void UnregisterFontAtlas(ImFontAtlas* atlas);
|
||||||
IMGUI_API void SetCurrentFont(ImFont* font, float font_size);
|
IMGUI_API void SetCurrentFont(ImFont* font, float font_size);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue