Skip to content

Commit 636a860

Browse files
committed
Updated ImGui.
1 parent 56dd9f4 commit 636a860

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

3rdparty/dear-imgui/imgui.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15493,6 +15493,18 @@ static void MetricsHelpMarker(const char* desc)
1549315493
// [DEBUG] List fonts in a font atlas and display its texture
1549415494
void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
1549515495
{
15496+
ImGuiContext& g = *GImGui;
15497+
15498+
Text("Read ");
15499+
SameLine(0, 0);
15500+
TextLinkOpenURL("https://www.dearimgui.com/faq/");
15501+
SameLine(0, 0);
15502+
Text(" for details on font loading.");
15503+
15504+
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
15505+
Checkbox("Show font preview", &cfg->ShowFontPreview);
15506+
15507+
// Font list
1549615508
for (ImFont* font : atlas->Fonts)
1549715509
{
1549815510
PushID(font);
@@ -15501,7 +15513,6 @@ void ImGui::ShowFontAtlas(ImFontAtlas* atlas)
1550115513
}
1550215514
if (TreeNode("Font Atlas", "Font Atlas (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight))
1550315515
{
15504-
ImGuiContext& g = *GImGui;
1550515516
PushStyleVar(ImGuiStyleVar_ImageBorderSize, ImMax(1.0f, g.Style.ImageBorderSize));
1550615517
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));
1550715518
PopStyleVar();
@@ -16292,16 +16303,21 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
1629216303
// [DEBUG] Display details for a single font, called by ShowStyleEditor().
1629316304
void ImGui::DebugNodeFont(ImFont* font)
1629416305
{
16306+
ImGuiContext& g = *GImGui;
16307+
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
1629516308
bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
1629616309
font->Sources ? font->Sources[0].Name : "", font->FontSize, font->Glyphs.Size, font->SourcesCount);
1629716310

1629816311
// Display preview text
1629916312
if (!opened)
1630016313
Indent();
1630116314
Indent();
16302-
PushFont(font);
16303-
Text("The quick brown fox jumps over the lazy dog");
16304-
PopFont();
16315+
if (cfg->ShowFontPreview)
16316+
{
16317+
PushFont(font);
16318+
Text("The quick brown fox jumps over the lazy dog");
16319+
PopFont();
16320+
}
1630516321
if (!opened)
1630616322
{
1630716323
Unindent();

3rdparty/dear-imgui/imgui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ struct ImFont
35403540
IMGUI_API void ClearOutputData();
35413541
IMGUI_API void GrowIndex(int new_size);
35423542
IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x);
3543-
IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built.
3543+
IMGUI_API void AddRemapChar(ImWchar from_codepoint, ImWchar to_codepoint, bool overwrite_dst);// , bool overwrite_dst = true); // Makes 'from_codepoint' character points to 'to_codepoint' character. Currently needs to be called AFTER fonts have been built.
35443544
IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last);
35453545
};
35463546

3rdparty/dear-imgui/imgui_demo.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Index of this file:
8282
// [SECTION] DemoWindowWidgetsDisableBlocks()
8383
// [SECTION] DemoWindowWidgetsDragAndDrop()
8484
// [SECTION] DemoWindowWidgetsDragsAndSliders()
85+
// [SECTION] DemoWindowWidgetsFonts()
8586
// [SECTION] DemoWindowWidgetsImages()
8687
// [SECTION] DemoWindowWidgetsListBoxes()
8788
// [SECTION] DemoWindowWidgetsMultiComponents()
@@ -1719,6 +1720,24 @@ static void DemoWindowWidgetsDragsAndSliders()
17191720
}
17201721
}
17211722

1723+
//-----------------------------------------------------------------------------
1724+
// [SECTION] DemoWindowWidgetsFonts()
1725+
//-----------------------------------------------------------------------------
1726+
1727+
// Forward declare ShowFontAtlas() which isn't worth putting in public API yet
1728+
namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); }
1729+
1730+
static void DemoWindowWidgetsFonts()
1731+
{
1732+
IMGUI_DEMO_MARKER("Widgets/Fonts");
1733+
if (ImGui::TreeNode("Fonts"))
1734+
{
1735+
ImFontAtlas* atlas = ImGui::GetIO().Fonts;
1736+
ImGui::ShowFontAtlas(atlas);
1737+
ImGui::TreePop();
1738+
}
1739+
}
1740+
17221741
//-----------------------------------------------------------------------------
17231742
// [SECTION] DemoWindowWidgetsImages()
17241743
//-----------------------------------------------------------------------------
@@ -4182,6 +4201,7 @@ static void DemoWindowWidgets(ImGuiDemoWindowData* demo_data)
41824201

41834202
DemoWindowWidgetsDragAndDrop();
41844203
DemoWindowWidgetsDragsAndSliders();
4204+
DemoWindowWidgetsFonts();
41854205
DemoWindowWidgetsImages();
41864206
DemoWindowWidgetsListBoxes();
41874207
DemoWindowWidgetsMultiComponents();

3rdparty/dear-imgui/imgui_draw.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,19 +3885,19 @@ void ImFont::AddGlyph(const ImFontConfig* src, ImWchar codepoint, float x0, floa
38853885
MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + pad) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + pad);
38863886
}
38873887

3888-
void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
3888+
void ImFont::AddRemapChar(ImWchar from_codepoint, ImWchar to_codepoint, bool overwrite_dst)
38893889
{
38903890
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
38913891
unsigned int index_size = (unsigned int)IndexLookup.Size;
38923892

3893-
if (dst < index_size && IndexLookup.Data[dst] == (ImU16)-1 && !overwrite_dst) // 'dst' already exists
3893+
if (from_codepoint < index_size && IndexLookup.Data[from_codepoint] == (ImU16)-1 && !overwrite_dst) // 'from_codepoint' already exists
38943894
return;
3895-
if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op
3895+
if (to_codepoint >= index_size && from_codepoint >= index_size) // both 'from_codepoint' and 'to_codepoint' don't exist -> no-op
38963896
return;
38973897

3898-
GrowIndex(dst + 1);
3899-
IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImU16)-1;
3900-
IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f;
3898+
GrowIndex(from_codepoint + 1);
3899+
IndexLookup[from_codepoint] = (to_codepoint < index_size) ? IndexLookup.Data[to_codepoint] : (ImU16)-1;
3900+
IndexAdvanceX[from_codepoint] = (to_codepoint < index_size) ? IndexAdvanceX.Data[to_codepoint] : 1.0f;
39013901
}
39023902

39033903
// Find glyph, return fallback if missing

3rdparty/dear-imgui/imgui_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,7 @@ struct ImGuiMetricsConfig
20202020
int ShowTablesRectsType = -1;
20212021
int HighlightMonitorIdx = -1;
20222022
ImGuiID HighlightViewportID = 0;
2023+
bool ShowFontPreview = true;
20232024
};
20242025

20252026
struct ImGuiStackLevelInfo

0 commit comments

Comments
 (0)