mirror of
https://github.com/ocornut/imgui.git
synced 2025-11-11 13:05:30 +00:00
Fonts: in ShowFontAtlas() preserve open-state for latest texture. Improve debug display.
This commit is contained in:
20
imgui.cpp
20
imgui.cpp
@@ -15420,7 +15420,8 @@ static void Platform_SetImeDataFn_DefaultImpl(ImGuiContext*, ImGuiViewport*, ImG
|
|||||||
// - RenderViewportsThumbnails() [Internal]
|
// - RenderViewportsThumbnails() [Internal]
|
||||||
// - DebugTextEncoding()
|
// - DebugTextEncoding()
|
||||||
// - MetricsHelpMarker() [Internal]
|
// - MetricsHelpMarker() [Internal]
|
||||||
// - ShowFontAtlas() [Internal]
|
// - ShowFontAtlas() [Internal but called by Demo!]
|
||||||
|
// - DebugNodeTexture() [Internal]
|
||||||
// - ShowMetricsWindow()
|
// - ShowMetricsWindow()
|
||||||
// - DebugNodeColumns() [Internal]
|
// - DebugNodeColumns() [Internal]
|
||||||
// - DebugNodeDrawList() [Internal]
|
// - DebugNodeDrawList() [Internal]
|
||||||
@@ -15722,18 +15723,20 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
|||||||
Text("incl. Discarded rects: %d, area: about %d px ~%dx%d px", atlas->Builder->RectsDiscardedCount, atlas->Builder->RectsDiscardedSurface, discarded_surface_sqrt, discarded_surface_sqrt);
|
Text("incl. Discarded rects: %d, area: about %d px ~%dx%d px", atlas->Builder->RectsDiscardedCount, atlas->Builder->RectsDiscardedSurface, discarded_surface_sqrt, discarded_surface_sqrt);
|
||||||
|
|
||||||
// Texture list
|
// Texture list
|
||||||
for (ImTextureData* tex : atlas->TexList)
|
// (ensure the last texture always use the same ID, so we can keep it open neatly)
|
||||||
|
for (int tex_n = 0; tex_n < atlas->TexList.Size; tex_n++)
|
||||||
{
|
{
|
||||||
PushID(tex);
|
if (tex_n == atlas->TexList.Size - 1)
|
||||||
DebugNodeTexture(tex);
|
SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
PopID();
|
DebugNodeTexture(atlas->TexList[tex_n], atlas->TexList.Size - 1 - tex_n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::DebugNodeTexture(ImTextureData* tex)
|
void ImGui::DebugNodeTexture(ImTextureData* tex, int int_id)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (TreeNode(tex, "Texture #%03d (%dx%d pixels)", tex->UniqueID, tex->Width, tex->Height))
|
PushID(int_id);
|
||||||
|
if (TreeNode("", "Texture #%03d (%dx%d pixels)", tex->UniqueID, tex->Width, tex->Height))
|
||||||
{
|
{
|
||||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||||
Checkbox("Show used rect", &cfg->ShowTextureUsedRect);
|
Checkbox("Show used rect", &cfg->ShowTextureUsedRect);
|
||||||
@@ -15748,12 +15751,13 @@ void ImGui::DebugNodeTexture(ImTextureData* tex)
|
|||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
|
|
||||||
char texid_desc[20];
|
char texid_desc[20];
|
||||||
Text("Format = %d", tex->Format);
|
Text("Format = %s (%d)", ImTextureDataGetFormatName(tex->Format), tex->Format);
|
||||||
Text("TexID = %s", FormatTextureIDForDebugDisplay(texid_desc, IM_ARRAYSIZE(texid_desc), tex->TexID));
|
Text("TexID = %s", FormatTextureIDForDebugDisplay(texid_desc, IM_ARRAYSIZE(texid_desc), tex->TexID));
|
||||||
Text("BackendUserData = %p", tex->BackendUserData);
|
Text("BackendUserData = %p", tex->BackendUserData);
|
||||||
Text("UseColors = %d", tex->UseColors);
|
Text("UseColors = %d", tex->UseColors);
|
||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::ShowMetricsWindow(bool* p_open)
|
void ImGui::ShowMetricsWindow(bool* p_open)
|
||||||
|
|||||||
@@ -2420,7 +2420,7 @@ ImFontConfig::ImFontConfig()
|
|||||||
// - ImTextureData::DestroyPixels()
|
// - ImTextureData::DestroyPixels()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static int GetTextureFormatBytesPerPixel(ImTextureFormat format)
|
int ImTextureDataGetFormatBytesPerPixel(ImTextureFormat format)
|
||||||
{
|
{
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
@@ -2431,13 +2431,24 @@ static int GetTextureFormatBytesPerPixel(ImTextureFormat format)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ImTextureDataGetFormatName(ImTextureFormat format)
|
||||||
|
{
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case ImTextureFormat_Alpha8: return "Alpha8";
|
||||||
|
case ImTextureFormat_RGBA32: return "RGBA32";
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImTextureData::Create(ImTextureFormat format, int w, int h)
|
void ImTextureData::Create(ImTextureFormat format, int w, int h)
|
||||||
{
|
{
|
||||||
DestroyPixels();
|
DestroyPixels();
|
||||||
Format = format;
|
Format = format;
|
||||||
Width = w;
|
Width = w;
|
||||||
Height = h;
|
Height = h;
|
||||||
BytesPerPixel = GetTextureFormatBytesPerPixel(format);
|
BytesPerPixel = ImTextureDataGetFormatBytesPerPixel(format);
|
||||||
UseColors = false;
|
UseColors = false;
|
||||||
Pixels = (unsigned char*)IM_ALLOC(Width * Height * BytesPerPixel);
|
Pixels = (unsigned char*)IM_ALLOC(Width * Height * BytesPerPixel);
|
||||||
IM_ASSERT(Pixels != NULL);
|
IM_ASSERT(Pixels != NULL);
|
||||||
@@ -2798,7 +2809,7 @@ void ImFontAtlasTextureBlockConvert(const unsigned char* src_pixels, ImTextureFo
|
|||||||
IM_ASSERT(src_pixels != NULL && dst_pixels != NULL);
|
IM_ASSERT(src_pixels != NULL && dst_pixels != NULL);
|
||||||
if (src_fmt == dst_fmt)
|
if (src_fmt == dst_fmt)
|
||||||
{
|
{
|
||||||
int line_sz = w * GetTextureFormatBytesPerPixel(src_fmt);
|
int line_sz = w * ImTextureDataGetFormatBytesPerPixel(src_fmt);
|
||||||
for (int ny = h; ny > 0; ny--, src_pixels += src_pitch, dst_pixels += dst_pitch)
|
for (int ny = h; ny > 0; ny--, src_pixels += src_pitch, dst_pixels += dst_pitch)
|
||||||
memcpy(dst_pixels, src_pixels, line_sz);
|
memcpy(dst_pixels, src_pixels, line_sz);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3625,7 +3625,7 @@ namespace ImGui
|
|||||||
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb);
|
||||||
IMGUI_API void DebugNodeFont(ImFont* font);
|
IMGUI_API void DebugNodeFont(ImFont* font);
|
||||||
IMGUI_API void DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph);
|
IMGUI_API void DebugNodeFontGlyph(ImFont* font, const ImFontGlyph* glyph);
|
||||||
IMGUI_API void DebugNodeTexture(ImTextureData* tex);
|
IMGUI_API void DebugNodeTexture(ImTextureData* tex, int int_id); // ID used to facilitate persisting the "current" texture.
|
||||||
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);
|
IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label);
|
||||||
IMGUI_API void DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label);
|
IMGUI_API void DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label);
|
||||||
IMGUI_API void DebugNodeTable(ImGuiTable* table);
|
IMGUI_API void DebugNodeTable(ImGuiTable* table);
|
||||||
@@ -3809,6 +3809,9 @@ IMGUI_API void ImFontAtlasTextureBlockFill(ImTextureData* dst_tex,
|
|||||||
IMGUI_API void ImFontAtlasTextureBlockCopy(ImTextureData* src_tex, int src_x, int src_y, ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h);
|
IMGUI_API void ImFontAtlasTextureBlockCopy(ImTextureData* src_tex, int src_x, int src_y, ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h);
|
||||||
IMGUI_API void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, int x, int y, int w, int h);
|
IMGUI_API void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, int x, int y, int w, int h);
|
||||||
|
|
||||||
|
IMGUI_API int ImTextureDataGetFormatBytesPerPixel(ImTextureFormat format);
|
||||||
|
IMGUI_API const char* ImTextureDataGetFormatName(ImTextureFormat format);
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
|
||||||
IMGUI_API void ImFontAtlasDebugLogTextureRequests(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasDebugLogTextureRequests(ImFontAtlas* atlas);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user