mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 13:08:47 +02:00
Merge branch 'master' into docking
# Conflicts: # examples/imgui_impl_opengl3.cpp # imgui.cpp # imgui_draw.cpp # imgui_internal.h
This commit is contained in:
@ -1208,7 +1208,7 @@ void ImDrawListSplitter::ClearFreeMemory()
|
||||
{
|
||||
for (int i = 0; i < _Channels.Size; i++)
|
||||
{
|
||||
if (i == _Current)
|
||||
if (i == _Current)
|
||||
memset(&_Channels[i], 0, sizeof(_Channels[i])); // Current channel is a copy of CmdBuffer/IdxBuffer, don't destruct again
|
||||
_Channels[i]._CmdBuffer.clear();
|
||||
_Channels[i]._IdxBuffer.clear();
|
||||
@ -1313,7 +1313,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list)
|
||||
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
|
||||
{
|
||||
IM_ASSERT(idx >= 0 && idx < _Count);
|
||||
if (_Current == idx)
|
||||
if (_Current == idx)
|
||||
return;
|
||||
// Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
|
||||
memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer));
|
||||
@ -1432,6 +1432,7 @@ ImFontConfig::ImFontConfig()
|
||||
MergeMode = false;
|
||||
RasterizerFlags = 0x00;
|
||||
RasterizerMultiply = 1.0f;
|
||||
EllipsisChar = (ImWchar)-1;
|
||||
memset(Name, 0, sizeof(Name));
|
||||
DstFont = NULL;
|
||||
}
|
||||
@ -1624,6 +1625,9 @@ ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
||||
memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize);
|
||||
}
|
||||
|
||||
if (new_font_cfg.DstFont->EllipsisChar == (ImWchar)-1)
|
||||
new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar;
|
||||
|
||||
// Invalidate texture
|
||||
ClearTexData();
|
||||
return new_font_cfg.DstFont;
|
||||
@ -1658,6 +1662,7 @@ ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template)
|
||||
font_cfg.SizePixels = 13.0f * 1.0f;
|
||||
if (font_cfg.Name[0] == '\0')
|
||||
ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels);
|
||||
font_cfg.EllipsisChar = (ImWchar)0x0085;
|
||||
|
||||
const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85();
|
||||
const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault();
|
||||
@ -2202,6 +2207,23 @@ void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||
for (int i = 0; i < atlas->Fonts.Size; i++)
|
||||
if (atlas->Fonts[i]->DirtyLookupTables)
|
||||
atlas->Fonts[i]->BuildLookupTable();
|
||||
|
||||
// Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
|
||||
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
|
||||
// FIXME: Also note that 0x2026 is currently seldomly included in our font ranges. Because of this we are more likely to use three individual dots.
|
||||
for (int i = 0; i < atlas->Fonts.size(); i++)
|
||||
{
|
||||
ImFont* font = atlas->Fonts[i];
|
||||
if (font->EllipsisChar != (ImWchar)-1)
|
||||
continue;
|
||||
const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
|
||||
for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
|
||||
if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
|
||||
{
|
||||
font->EllipsisChar = ellipsis_variants[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve list of range (2 int per range, values are inclusive)
|
||||
@ -2471,6 +2493,7 @@ ImFont::ImFont()
|
||||
FontSize = 0.0f;
|
||||
FallbackAdvanceX = 0.0f;
|
||||
FallbackChar = (ImWchar)'?';
|
||||
EllipsisChar = (ImWchar)-1;
|
||||
DisplayOffset = ImVec2(0.0f, 0.0f);
|
||||
FallbackGlyph = NULL;
|
||||
ContainerAtlas = NULL;
|
||||
@ -3020,7 +3043,6 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
|
||||
// - RenderArrowPointingAt()
|
||||
// - RenderRectFilledRangeH()
|
||||
// - RenderRectFilledWithHole()
|
||||
// - RenderPixelEllipsis()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImGui::RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor)
|
||||
@ -3167,18 +3189,6 @@ void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect
|
||||
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawCornerFlags_BotRight);
|
||||
}
|
||||
|
||||
// FIXME: Rendering an ellipsis "..." is a surprisingly tricky problem for us... we cannot rely on font glyph having it,
|
||||
// and regular dot are typically too wide. If we render a dot/shape ourselves it comes with the risk that it wouldn't match
|
||||
// the boldness or positioning of what the font uses...
|
||||
void ImGui::RenderPixelEllipsis(ImDrawList* draw_list, ImVec2 pos, ImU32 col, int count)
|
||||
{
|
||||
ImFont* font = draw_list->_Data->Font;
|
||||
const float font_scale = draw_list->_Data->FontSize / font->FontSize;
|
||||
pos.y += (float)(int)(font->DisplayOffset.y + font->Ascent * font_scale + 0.5f - 1.0f);
|
||||
for (int dot_n = 0; dot_n < count; dot_n++)
|
||||
draw_list->AddRectFilled(ImVec2(pos.x + dot_n * 2.0f, pos.y), ImVec2(pos.x + dot_n * 2.0f + 1.0f, pos.y + 1.0f), col);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Decompression code
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user