1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 09:30:56 +01:00

ImFontAtlas: added ClearFonts(), making the different clear funcs more explicit (#224)

This commit is contained in:
ocornut 2015-05-12 14:53:29 +01:00
parent ad79db32c7
commit 9d9cf31972
2 changed files with 14 additions and 7 deletions

View File

@ -343,6 +343,7 @@
- columns: columns header to act as button (~sort op) and allow resize/reorder (github issue #125) - columns: columns header to act as button (~sort op) and allow resize/reorder (github issue #125)
- columns: user specify columns size (github issue #125) - columns: user specify columns size (github issue #125)
- popup: border options. richer api like BeginChild() perhaps? (github issue #197) - popup: border options. richer api like BeginChild() perhaps? (github issue #197)
- combo: sparse combo boxes (via function call?)
- combo: turn child handling code into pop up helper - combo: turn child handling code into pop up helper
- combo: contents should extends to fit label if combo widget is small - combo: contents should extends to fit label if combo widget is small
- combo/listbox: keyboard control. need inputtext like non-active focus + key handling. considering keybord for custom listbox (see github pr #203) - combo/listbox: keyboard control. need inputtext like non-active focus + key handling. considering keybord for custom listbox (see github pr #203)
@ -8384,10 +8385,8 @@ void ImFontAtlas::ClearTexData()
TexPixelsRGBA32 = NULL; TexPixelsRGBA32 = NULL;
} }
void ImFontAtlas::Clear() void ImFontAtlas::ClearFonts()
{ {
ClearInputData();
ClearTexData();
for (size_t i = 0; i < Fonts.size(); i++) for (size_t i = 0; i < Fonts.size(); i++)
{ {
Fonts[i]->~ImFont(); Fonts[i]->~ImFont();
@ -8396,6 +8395,13 @@ void ImFontAtlas::Clear()
Fonts.clear(); Fonts.clear();
} }
void ImFontAtlas::Clear()
{
ClearInputData();
ClearTexData();
ClearFonts();
}
void ImGui::GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size) void ImGui::GetDefaultFontData(const void** fnt_data, unsigned int* fnt_size, const void** png_data, unsigned int* png_size)
{ {
printf("GetDefaultFontData() is obsoleted in ImGui 1.30.\n"); printf("GetDefaultFontData() is obsoleted in ImGui 1.30.\n");
@ -9824,7 +9830,7 @@ void ImGui::ShowTestWindow(bool* opened)
ImGui::TreePop(); ImGui::TreePop();
} }
if (ImGui::TreeNode("Fonts")) if (ImGui::TreeNode("Fonts", "Fonts (%d)", (int)ImGui::GetIO().Fonts->Fonts.size()))
{ {
ImGui::TextWrapped("Tip: Load fonts with GetIO().Fonts->AddFontFromFileTTF()."); ImGui::TextWrapped("Tip: Load fonts with GetIO().Fonts->AddFontFromFileTTF().");
for (size_t i = 0; i < ImGui::GetIO().Fonts->Fonts.size(); i++) for (size_t i = 0; i < ImGui::GetIO().Fonts->Fonts.size(); i++)

View File

@ -979,8 +979,10 @@ struct ImFontAtlas
IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0);
IMGUI_API ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build() IMGUI_API ImFont* AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // Transfer ownership of 'ttf_data' to ImFontAtlas, will be deleted after Build()
IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // 'compressed_ttf_data' untouched and still owned by caller. Compress with binary_to_compressed_c.cpp IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImWchar* glyph_ranges = NULL, int font_no = 0); // 'compressed_ttf_data' untouched and still owned by caller. Compress with binary_to_compressed_c.cpp
IMGUI_API void ClearTexData(); // Saves RAM once the texture has been copied to graphics memory. IMGUI_API void ClearTexData(); // Clear the CPU-side texture data. Saves RAM once the texture has been copied to graphics memory.
IMGUI_API void Clear(); IMGUI_API void ClearInputData(); // Clear the input TTF data (inc sizes, glyph ranges)
IMGUI_API void ClearFonts(); // Clear the ImGui-side font data (glyphs storage, UV coordinates)
IMGUI_API void Clear(); // Clear all
// Retrieve texture data // Retrieve texture data
// User is in charge of copying the pixels into graphics memory, then call SetTextureUserID() // User is in charge of copying the pixels into graphics memory, then call SetTextureUserID()
@ -1011,7 +1013,6 @@ struct ImFontAtlas
struct ImFontAtlasData; struct ImFontAtlasData;
ImVector<ImFontAtlasData*> InputData; // Internal data ImVector<ImFontAtlasData*> InputData; // Internal data
IMGUI_API bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions. IMGUI_API bool Build(); // Build pixels data. This is automatically for you by the GetTexData*** functions.
IMGUI_API void ClearInputData(); // Clear the input TTF data.
IMGUI_API void RenderCustomTexData(int pass, void* rects); IMGUI_API void RenderCustomTexData(int pass, void* rects);
}; };