mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_osx.mm # backends/imgui_impl_sdl2.cpp # backends/imgui_impl_sdl3.cpp # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
6e94f6cefb
19 changed files with 197 additions and 156 deletions
|
|
@ -1675,8 +1675,7 @@ void ImDrawList::AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32
|
|||
// Accept null ranges
|
||||
if (text_begin == text_end || text_begin[0] == 0)
|
||||
return;
|
||||
if (text_end == NULL)
|
||||
text_end = text_begin + strlen(text_begin);
|
||||
// No need to strlen() here: font->RenderText() will do it and may early out.
|
||||
|
||||
// Pull default font/size from the shared ImDrawListSharedData instance
|
||||
if (font == NULL)
|
||||
|
|
@ -1699,7 +1698,7 @@ void ImDrawList::AddText(ImFont* font, float font_size, const ImVec2& pos, ImU32
|
|||
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||
{
|
||||
AddText(NULL, 0.0f, pos, col, text_begin, text_end);
|
||||
AddText(_Data->Font, _Data->FontSize, pos, col, text_begin, text_end);
|
||||
}
|
||||
|
||||
void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col)
|
||||
|
|
@ -3695,7 +3694,7 @@ ImFont::ImFont()
|
|||
Scale = 1.0f;
|
||||
Ascent = Descent = 0.0f;
|
||||
MetricsTotalSurface = 0;
|
||||
memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap));
|
||||
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
|
||||
}
|
||||
|
||||
ImFont::~ImFont()
|
||||
|
|
@ -3715,7 +3714,7 @@ void ImFont::ClearOutputData()
|
|||
DirtyLookupTables = true;
|
||||
Ascent = Descent = 0.0f;
|
||||
MetricsTotalSurface = 0;
|
||||
memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap));
|
||||
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
|
||||
}
|
||||
|
||||
static ImWchar FindFirstExistingGlyph(ImFont* font, const ImWchar* candidate_chars, int candidate_chars_count)
|
||||
|
|
@ -3738,7 +3737,7 @@ void ImFont::BuildLookupTable()
|
|||
IndexAdvanceX.clear();
|
||||
IndexLookup.clear();
|
||||
DirtyLookupTables = false;
|
||||
memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap));
|
||||
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
|
||||
GrowIndex(max_codepoint + 1);
|
||||
for (int i = 0; i < Glyphs.Size; i++)
|
||||
{
|
||||
|
|
@ -3747,8 +3746,8 @@ void ImFont::BuildLookupTable()
|
|||
IndexLookup[codepoint] = (ImWchar)i;
|
||||
|
||||
// Mark 4K page as used
|
||||
const int page_n = codepoint / 4096;
|
||||
Used4kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
|
||||
const int page_n = codepoint / 8192;
|
||||
Used8kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
|
||||
}
|
||||
|
||||
// Create a glyph to handle TAB
|
||||
|
|
@ -3810,15 +3809,15 @@ void ImFont::BuildLookupTable()
|
|||
}
|
||||
}
|
||||
|
||||
// API is designed this way to avoid exposing the 4K page size
|
||||
// API is designed this way to avoid exposing the 8K page size
|
||||
// e.g. use with IsGlyphRangeUnused(0, 255)
|
||||
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
|
||||
{
|
||||
unsigned int page_begin = (c_begin / 4096);
|
||||
unsigned int page_last = (c_last / 4096);
|
||||
unsigned int page_begin = (c_begin / 8192);
|
||||
unsigned int page_last = (c_last / 8192);
|
||||
for (unsigned int page_n = page_begin; page_n <= page_last; page_n++)
|
||||
if ((page_n >> 3) < sizeof(Used4kPagesMap))
|
||||
if (Used4kPagesMap[page_n >> 3] & (1 << (page_n & 7)))
|
||||
if ((page_n >> 3) < sizeof(Used8kPagesMap))
|
||||
if (Used8kPagesMap[page_n >> 3] & (1 << (page_n & 7)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -4131,15 +4130,15 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, const ImVec2& pos, Im
|
|||
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
|
||||
void ImFont::RenderText(ImDrawList* draw_list, float size, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip)
|
||||
{
|
||||
if (!text_end)
|
||||
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||
|
||||
// Align to be pixel perfect
|
||||
float x = IM_TRUNC(pos.x);
|
||||
float y = IM_TRUNC(pos.y);
|
||||
if (y > clip_rect.w)
|
||||
return;
|
||||
|
||||
if (!text_end)
|
||||
text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
|
||||
|
||||
const float scale = size / FontSize;
|
||||
const float line_height = FontSize * scale;
|
||||
const float origin_x = x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue