Moved colored implementation to their own functions

To minimise source code modifications, colored input text has been moved to their own functions.
The ImFont is still modified tho.
This commit is contained in:
Nemirtingas
2019-08-03 14:37:03 +02:00
parent 804355fa54
commit d2a75db930
6 changed files with 845 additions and 16 deletions

View File

@ -2816,8 +2816,6 @@ void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
void ImFont::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, bool cpu_fine_clip) const
{
ImU32 color_bkp = col;
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.
@ -2876,10 +2874,10 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col
if (*s == 1)
{
++s;
unsigned char color[4];
for (int i = 0; i < 4; ++i, s+=2)
for (int i = 0; i < 4; ++i, s += 2)
{
if (s[0] >= '0' && s[0] <= '9')
color[i] = (s[0] - '0') * 16;