Fixed mouse aiming within InputText() - broken during 01/18 merge

This commit is contained in:
ocornut 2015-01-23 00:02:44 +01:00
parent 7530f3c985
commit 32b8ad7381

View File

@ -232,7 +232,6 @@
ISSUES & TODO-LIST ISSUES & TODO-LIST
================== ==================
! input: mouse click on scrolling text input broken?
- misc: merge or clarify ImVec4 / ImGuiAabb, they are essentially duplicate containers - misc: merge or clarify ImVec4 / ImGuiAabb, they are essentially duplicate containers
- window: add horizontal scroll - window: add horizontal scroll
- window: fix resize grip rendering scaling along with Rounding style setting - window: fix resize grip rendering scaling along with Rounding style setting
@ -2069,7 +2068,16 @@ ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_tex
else else
text_display_end = text_end; text_display_end = text_end;
const ImVec2 text_size = window->Font()->CalcTextSizeA(window->FontSize(), FLT_MAX, wrap_width, text, text_display_end, NULL); ImFont* font = window->Font();
const float font_size = window->FontSize();
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
// Cancel out character spacing for the last character of a line (it is baked into glyph->XAdvance field)
const float font_scale = font_size / font->FontSize;
const float character_spacing_x = 1.0f * font_scale;
if (text_size.x > 0.0f)
text_size.x -= character_spacing_x;
return text_size; return text_size;
} }
@ -7153,11 +7161,6 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
text_size.y += line_height; text_size.y += line_height;
} }
// Cancel out character spacing for the last character of a line (it is baked into glyph->XAdvance field)
const float character_spacing_x = 1.0f * scale;
if (text_size.x > 0.0f)
text_size.x -= character_spacing_x;
if (remaining) if (remaining)
*remaining = s; *remaining = s;
@ -7205,11 +7208,6 @@ ImVec2 ImFont::CalcTextSizeW(float size, float max_width, const ImWchar* text_be
text_size.y += line_height; text_size.y += line_height;
} }
// Cancel out character spacing for the last character of a line (it is baked into glyph->XAdvance field)
const float character_spacing_x = 1.0f * scale;
if (text_size.x > 0.0f)
text_size.x -= character_spacing_x;
if (remaining) if (remaining)
*remaining = s; *remaining = s;