mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-26 12:27:30 +00:00
Demo: added basic Fonts section under main demo (same as Metrics one) for visibility.
This commit is contained in:
24
imgui.cpp
24
imgui.cpp
@@ -15491,6 +15491,18 @@ static void MetricsHelpMarker(const char* desc)
|
||||
// [DEBUG] List fonts in a font atlas and display its texture
|
||||
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
Text("Read ");
|
||||
SameLine(0, 0);
|
||||
TextLinkOpenURL("https://www.dearimgui.com/faq/");
|
||||
SameLine(0, 0);
|
||||
Text(" for details on font loading.");
|
||||
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
Checkbox("Show font preview", &cfg->ShowFontPreview);
|
||||
|
||||
// Font list
|
||||
for (ImFont* font : atlas->Fonts)
|
||||
{
|
||||
PushID(font);
|
||||
@@ -15499,7 +15511,6 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
|
||||
}
|
||||
if (TreeNode("Font Atlas", "Font Atlas (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
PushStyleVar(ImGuiStyleVar_ImageBorderSize, ImMax(1.0f, g.Style.ImageBorderSize));
|
||||
ImageWithBg(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), ImVec4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
PopStyleVar();
|
||||
@@ -16290,6 +16301,8 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
|
||||
// [DEBUG] Display details for a single font, called by ShowStyleEditor().
|
||||
void ImGui::DebugNodeFont(ImFont* font)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
|
||||
font->Sources ? font->Sources[0].Name : "", font->FontSize, font->Glyphs.Size, font->SourcesCount);
|
||||
|
||||
@@ -16297,9 +16310,12 @@ void ImGui::DebugNodeFont(ImFont* font)
|
||||
if (!opened)
|
||||
Indent();
|
||||
Indent();
|
||||
PushFont(font);
|
||||
Text("The quick brown fox jumps over the lazy dog");
|
||||
PopFont();
|
||||
if (cfg->ShowFontPreview)
|
||||
{
|
||||
PushFont(font);
|
||||
Text("The quick brown fox jumps over the lazy dog");
|
||||
PopFont();
|
||||
}
|
||||
if (!opened)
|
||||
{
|
||||
Unindent();
|
||||
|
||||
@@ -82,6 +82,7 @@ Index of this file:
|
||||
// [SECTION] DemoWindowWidgetsDisableBlocks()
|
||||
// [SECTION] DemoWindowWidgetsDragAndDrop()
|
||||
// [SECTION] DemoWindowWidgetsDragsAndSliders()
|
||||
// [SECTION] DemoWindowWidgetsFonts()
|
||||
// [SECTION] DemoWindowWidgetsImages()
|
||||
// [SECTION] DemoWindowWidgetsListBoxes()
|
||||
// [SECTION] DemoWindowWidgetsMultiComponents()
|
||||
@@ -1719,6 +1720,24 @@ static void DemoWindowWidgetsDragsAndSliders()
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] DemoWindowWidgetsFonts()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Forward declare ShowFontAtlas() which isn't worth putting in public API yet
|
||||
namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
|
||||
|
||||
static void DemoWindowWidgetsFonts()
|
||||
{
|
||||
IMGUI_DEMO_MARKER("Widgets/Fonts");
|
||||
if (ImGui::TreeNode("Fonts"))
|
||||
{
|
||||
ImFontAtlas* atlas = ImGui::GetIO().Fonts;
|
||||
ImGui::ShowFontAtlas(atlas);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] DemoWindowWidgetsImages()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -4182,6 +4201,7 @@ static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data)
|
||||
|
||||
DemoWindowWidgetsDragAndDrop();
|
||||
DemoWindowWidgetsDragsAndSliders();
|
||||
DemoWindowWidgetsFonts();
|
||||
DemoWindowWidgetsImages();
|
||||
DemoWindowWidgetsListBoxes();
|
||||
DemoWindowWidgetsMultiComponents();
|
||||
|
||||
@@ -2020,6 +2020,7 @@ struct ImGuiMetricsConfig
|
||||
int ShowTablesRectsType = -1;
|
||||
int HighlightMonitorIdx = -1;
|
||||
ImGuiID HighlightViewportID = 0;
|
||||
bool ShowFontPreview = true;
|
||||
};
|
||||
|
||||
struct ImGuiStackLevelInfo
|
||||
|
||||
Reference in New Issue
Block a user