This commit is contained in:
Branimir Karadžić 2018-09-13 09:27:01 -07:00
Родитель d1aba38a27
Коммит 62b16bbaf4
3 изменённых файлов: 19 добавлений и 19 удалений

4
3rdparty/dear-imgui/imgui.h поставляемый
Просмотреть файл

@ -1921,7 +1921,7 @@ struct ImFont
ImVec2 DisplayOffset; // = (0.f,0.f) // Offset font rendering by xx pixels
ImVector<ImFontGlyph> Glyphs; // // All glyphs.
ImVector<float> IndexAdvanceX; // // Sparse. Glyphs->AdvanceX in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
ImVector<unsigned short> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
ImVector<ImWchar> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
const ImFontGlyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
float FallbackAdvanceX; // == FallbackGlyph->AdvanceX
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
@ -1950,7 +1950,7 @@ struct ImFont
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const;
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const;
IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
// [Internal]

28
3rdparty/dear-imgui/imgui_draw.cpp поставляемый
Просмотреть файл

@ -1894,7 +1894,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
continue;
const int codepoint = range.first_unicode_codepoint_in_range + char_idx;
if (cfg.MergeMode && dst_font->FindGlyphNoFallback((unsigned short)codepoint))
if (cfg.MergeMode && dst_font->FindGlyphNoFallback((ImWchar)codepoint))
continue;
float char_advance_x_org = pc.xadvance;
@ -2316,21 +2316,21 @@ void ImFont::BuildLookupTable()
{
int codepoint = (int)Glyphs[i].Codepoint;
IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX;
IndexLookup[codepoint] = (unsigned short)i;
IndexLookup[codepoint] = (ImWchar)i;
}
// Create a glyph to handle TAB
// FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
if (FindGlyph((unsigned short)' '))
if (FindGlyph((ImWchar)' '))
{
if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times
Glyphs.resize(Glyphs.Size + 1);
ImFontGlyph& tab_glyph = Glyphs.back();
tab_glyph = *FindGlyph((unsigned short)' ');
tab_glyph = *FindGlyph((ImWchar)' ');
tab_glyph.Codepoint = '\t';
tab_glyph.AdvanceX *= 4;
IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
IndexLookup[(int)tab_glyph.Codepoint] = (unsigned short)(Glyphs.Size-1);
IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size-1);
}
FallbackGlyph = FindGlyphNoFallback(FallbackChar);
@ -2352,7 +2352,7 @@ void ImFont::GrowIndex(int new_size)
if (new_size <= IndexLookup.Size)
return;
IndexAdvanceX.resize(new_size, -1.0f);
IndexLookup.resize(new_size, (unsigned short)-1);
IndexLookup.resize(new_size, (ImWchar)-1);
}
// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero.
@ -2385,13 +2385,13 @@ void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst)
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
int index_size = IndexLookup.Size;
if (dst < index_size && IndexLookup.Data[dst] == (unsigned short)-1 && !overwrite_dst) // 'dst' already exists
if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists
return;
if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op
return;
GrowIndex(dst + 1);
IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (unsigned short)-1;
IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1;
IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f;
}
@ -2399,8 +2399,8 @@ const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const
{
if (c >= IndexLookup.Size)
return FallbackGlyph;
const unsigned short i = IndexLookup[c];
if (i == (unsigned short)-1)
const ImWchar i = IndexLookup[c];
if (i == (ImWchar)-1)
return FallbackGlyph;
return &Glyphs.Data[i];
}
@ -2409,8 +2409,8 @@ const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const
{
if (c >= IndexLookup.Size)
return NULL;
const unsigned short i = IndexLookup[c];
if (i == (unsigned short)-1)
const ImWchar i = IndexLookup[c];
if (i == (ImWchar)-1)
return NULL;
return &Glyphs.Data[i];
}
@ -2608,7 +2608,7 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
return text_size;
}
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const
{
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
return;
@ -2733,7 +2733,7 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
}
float char_width = 0.0f;
if (const ImFontGlyph* glyph = FindGlyph((unsigned short)c))
if (const ImFontGlyph* glyph = FindGlyph((ImWchar)c))
{
char_width = glyph->AdvanceX * scale;

6
3rdparty/dear-imgui/imgui_widgets.cpp поставляемый
Просмотреть файл

@ -838,7 +838,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
// Default to using texture ID as ID. User can still push string/integer prefixes.
// We could hash the size/uv to create a unique ID but that would prevent the user from animating UV.
PushID((void*)user_texture_id);
PushID((void*)(intptr_t)user_texture_id);
const ImGuiID id = window->GetID("#image");
PopID();
@ -2859,7 +2859,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t
if (c == '\r')
continue;
const float char_width = font->GetCharAdvance((unsigned short)c) * scale;
const float char_width = font->GetCharAdvance((ImWchar)c) * scale;
line_width += char_width;
}
@ -3712,7 +3712,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
else
{
ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true);
if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((unsigned short)' ') * 0.50f); // So we can see selected empty lines
if (rect_size.x <= 0.0f) rect_size.x = (float)(int)(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines
ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos +ImVec2(rect_size.x, bg_offy_dn));
rect.ClipWith(clip_rect);
if (rect.Overlaps(clip_rect))