Skip to content

Commit 355cb58

Browse files
committed
Merge branch 'master' into docking, incl conflict merge in BeginMenuBar() for ocornut#8267
# Conflicts: # imgui_widgets.cpp
2 parents 64e738c + 8a1613a commit 355cb58

File tree

8 files changed

+149
-109
lines changed

8 files changed

+149
-109
lines changed

docs/CHANGELOG.txt

+15-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ Breaking changes:
5454

5555
Other changes:
5656

57-
- ImDrawList: texture baked storage for thick line reduced from ~64x64 to ~32x32. (#3245)
5857
- imgui_freetype: fixed issue where glyph advances would incorrectly be
5958
snapped to pixels. Effectively it would only be noticeable when hinting
6059
is disabled with ImGuiFreeTypeBuilderFlags_NoHinting, as hinting itself
@@ -68,11 +67,24 @@ Other changes:
6867
- Windows: legacy SetWindowFontScale() is properly inherited by nested child
6968
windows. Note that an upcoming major release should make this obsolete,
7069
but in the meanwhile it works better now. (#2701, #8138, #1018)
70+
- Windows, Style: Fixed small rendering issues with menu bar, resize grip and
71+
scrollbar when using thick border sizes. (#8267, #7887)
7172
- ColorEdit, ColorPicker: Fixed alpha preview broken in 1.91.7. (#8336, #8241). [@PathogenDavid]
7273
- Tabs, Style: reworked selected overline rendering to better accommodate
7374
for rounded tabs. Reduced default thickness (style.TabBarOverlineSize),
7475
increased default rounding (style.TabRounding). (#8334) [@Kian738, @ocornut]
7576
styles as the current look is not right (but ImGuiCol_TabSelectedOverline stays the same).
77+
- Debug Tools: Tweaked font preview.
78+
- ImDrawList: texture baked storage for thick line reduced from ~64x64 to ~32x32. (#3245)
79+
- Fonts: IndexLookup[] table hold 16-bit values even in ImWchar32 mode,
80+
as it accounts for number of glyphs in same font. This is favorable to
81+
CalcTextSize() calls touching less memory.
82+
- Fonts: OversampleH/OversampleV defaults to 0 for automatic selection.
83+
- OversampleH == 0 --> use 1 or 2 depending on font size and use of PixelSnapH.
84+
- OversampleV == 0 --> always use 1.
85+
This also
86+
- ImFontAtlas: made calling ClearFonts() call ClearInputData(), as calling
87+
one without the other is never correct. (#8174, #6556, #6336, #4723)
7688
- Examples: DirectX12: Reduced number of frame in flight from 3 to 2 in
7789
provided example, to reduce latency.
7890
- Backends+Examples: Vulkan: better handle VK_SUBOPTIMAL_KHR being returned by
@@ -139,6 +151,8 @@ Other changes:
139151
the label (not only the highlight/frame) also spans all columns. This is
140152
useful for table rows where you know nothing else is submitted. (#8318, #3565)
141153
Obviously best used with ImGuiTableFlags_NoBordersInBodyUntilResize.
154+
- Selectable: Fixed horizontal label alignment when combined with using
155+
ImGuiSelectableFlags_SpanAllColumns. (#8338)
142156
- Drags: Added ImGuiSliderFlags_NoSpeedTweaks flag to disable keyboard
143157
modifiers altering the tweak speed. Useful if you want to alter tweak speed
144158
yourself based on your own logic. (#8223)

docs/FONTS.md

-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ ImGui::PopFont();
110110
**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):**
111111
```cpp
112112
ImFontConfig config;
113-
config.OversampleH = 2;
114-
config.OversampleV = 1;
115113
config.GlyphExtraSpacing.x = 1.0f;
116114
ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config);
117115
```

imgui.cpp

+70-56
Original file line numberDiff line numberDiff line change
@@ -7033,7 +7033,7 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
70337033
if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
70347034
{
70357035
float y = window->Pos.y + window->TitleBarHeight - 1;
7036-
window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), border_col, g.Style.FrameBorderSize);
7036+
window->DrawList->AddLine(ImVec2(window->Pos.x + border_size * 0.5f, y), ImVec2(window->Pos.x + window->Size.x - border_size * 0.5f, y), border_col, g.Style.FrameBorderSize);
70377037
}
70387038
}
70397039

@@ -7130,9 +7130,9 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
71307130
{
71317131
ImRect menu_bar_rect = window->MenuBarRect();
71327132
menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them.
7133-
window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawFlags_RoundCornersTop);
7133+
window->DrawList->AddRectFilled(menu_bar_rect.Min, menu_bar_rect.Max, GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawFlags_RoundCornersTop);
71347134
if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y)
7135-
window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
7135+
window->DrawList->AddLine(menu_bar_rect.GetBL() + ImVec2(window_border_size * 0.5f, 0.0f), menu_bar_rect.GetBR() - ImVec2(window_border_size * 0.5f, 0.0f), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
71367136
}
71377137

71387138
// Docking: Unhide tab bar (small triangle in the corner), drag from small triangle to quickly undock
@@ -7172,9 +7172,10 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
71727172
continue;
71737173
const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n];
71747174
const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN);
7175-
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size)));
7176-
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size)));
7177-
window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12);
7175+
const float border_inner = IM_ROUND(window_border_size * 0.5f);
7176+
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(border_inner, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, border_inner)));
7177+
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, border_inner) : ImVec2(border_inner, resize_grip_draw_size)));
7178+
window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + border_inner), corner.y + grip.InnerDir.y * (window_rounding + border_inner)), window_rounding, grip.AngleMin12, grip.AngleMax12);
71787179
window->DrawList->PathFillConvex(col);
71797180
}
71807181
}
@@ -21986,18 +21987,24 @@ void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, co
2198621987
// [DEBUG] Display details for a single font, called by ShowStyleEditor().
2198721988
void ImGui::DebugNodeFont(ImFont* font)
2198821989
{
21989-
bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)",
21990+
bool opened = TreeNode(font, "Font: \"%s\": %.2f px, %d glyphs, %d sources(s)",
2199021991
font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount);
21991-
SameLine();
21992-
if (SmallButton("Set as default"))
21993-
GetIO().FontDefault = font;
21994-
if (!opened)
21995-
return;
2199621992

2199721993
// Display preview text
21994+
if (!opened)
21995+
Indent();
21996+
Indent();
2199821997
PushFont(font);
2199921998
Text("The quick brown fox jumps over the lazy dog");
2200021999
PopFont();
22000+
if (!opened)
22001+
{
22002+
Unindent();
22003+
Unindent();
22004+
return;
22005+
}
22006+
if (SmallButton("Set as default"))
22007+
GetIO().FontDefault = font;
2200122008

2200222009
// Display details
2200322010
SetNextItemWidth(GetFontSize() * 8);
@@ -22016,62 +22023,69 @@ void ImGui::DebugNodeFont(ImFont* font)
2201622023
Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt);
2201722024
for (int config_i = 0; config_i < font->ConfigDataCount; config_i++)
2201822025
if (font->ConfigData)
22019-
if (const ImFontConfig* cfg = &font->ConfigData[config_i])
22020-
BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
22021-
config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
22026+
{
22027+
const ImFontConfig* cfg = &font->ConfigData[config_i];
22028+
int oversample_h, oversample_v;
22029+
ImFontAtlasBuildGetOversampleFactors(cfg, &oversample_h, &oversample_v);
22030+
BulletText("Input %d: \'%s\', Oversample: (%d=>%d,%d=>%d), PixelSnapH: %d, Offset: (%.1f,%.1f)",
22031+
config_i, cfg->Name, cfg->OversampleH, oversample_h, cfg->OversampleV, oversample_v, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y);
22032+
}
2202222033

2202322034
// Display all glyphs of the fonts in separate pages of 256 characters
22024-
if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
22025-
{
22026-
ImDrawList* draw_list = GetWindowDrawList();
22027-
const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
22028-
const float cell_size = font->FontSize * 1;
22029-
const float cell_spacing = GetStyle().ItemSpacing.y;
22030-
for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
22031-
{
22032-
// Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
22033-
// This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
22034-
// is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
22035-
if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
22035+
{
22036+
if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size))
22037+
{
22038+
ImDrawList* draw_list = GetWindowDrawList();
22039+
const ImU32 glyph_col = GetColorU32(ImGuiCol_Text);
22040+
const float cell_size = font->FontSize * 1;
22041+
const float cell_spacing = GetStyle().ItemSpacing.y;
22042+
for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256)
2203622043
{
22037-
base += 8192 - 256;
22038-
continue;
22039-
}
22040-
22041-
int count = 0;
22042-
for (unsigned int n = 0; n < 256; n++)
22043-
if (font->FindGlyphNoFallback((ImWchar)(base + n)))
22044-
count++;
22045-
if (count <= 0)
22046-
continue;
22047-
if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
22048-
continue;
22044+
// Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k)
22045+
// This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT
22046+
// is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here)
22047+
if (!(base & 8191) && font->IsGlyphRangeUnused(base, base + 8191))
22048+
{
22049+
base += 8192 - 256;
22050+
continue;
22051+
}
2204922052

22050-
// Draw a 16x16 grid of glyphs
22051-
ImVec2 base_pos = GetCursorScreenPos();
22052-
for (unsigned int n = 0; n < 256; n++)
22053-
{
22054-
// We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
22055-
// available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
22056-
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
22057-
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
22058-
const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
22059-
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
22060-
if (!glyph)
22053+
int count = 0;
22054+
for (unsigned int n = 0; n < 256; n++)
22055+
if (font->FindGlyphNoFallback((ImWchar)(base + n)))
22056+
count++;
22057+
if (count <= 0)
2206122058
continue;
22062-
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
22063-
if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
22059+
if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph"))
22060+
continue;
22061+
22062+
// Draw a 16x16 grid of glyphs
22063+
ImVec2 base_pos = GetCursorScreenPos();
22064+
for (unsigned int n = 0; n < 256; n++)
2206422065
{
22065-
DebugNodeFontGlyph(font, glyph);
22066-
EndTooltip();
22066+
// We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions
22067+
// available here and thus cannot easily generate a zero-terminated UTF-8 encoded string.
22068+
ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing));
22069+
ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size);
22070+
const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n));
22071+
draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50));
22072+
if (!glyph)
22073+
continue;
22074+
font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n));
22075+
if (IsMouseHoveringRect(cell_p1, cell_p2) && BeginTooltip())
22076+
{
22077+
DebugNodeFontGlyph(font, glyph);
22078+
EndTooltip();
22079+
}
2206722080
}
22081+
Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
22082+
TreePop();
2206822083
}
22069-
Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16));
2207022084
TreePop();
2207122085
}
22072-
TreePop();
2207322086
}
2207422087
TreePop();
22088+
Unindent();
2207522089
}
2207622090

2207722091
void ImGui::DebugNodeFontGlyph(ImFont*, const ImFontGlyph* glyph)

0 commit comments

Comments
 (0)