InputText(): fixed cursor pixel-alignment when horizontally scrolled.

This commit is contained in:
ocornut 2015-09-19 13:48:27 +02:00
parent 0e86ed9361
commit ff12afbd18

View File

@ -7127,7 +7127,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
else else
{ {
edit_state.Id = id; edit_state.Id = id;
edit_state.ScrollX = 0.f; edit_state.ScrollX = 0.0f;
stb_textedit_initialize_state(&edit_state.StbState, !is_multiline); stb_textedit_initialize_state(&edit_state.StbState, !is_multiline);
if (!is_multiline && focus_requested_by_code) if (!is_multiline && focus_requested_by_code)
select_all = true; select_all = true;
@ -7447,9 +7447,9 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{ {
const float scroll_increment_x = size.x * 0.25f; const float scroll_increment_x = size.x * 0.25f;
if (cursor_offset.x < edit_state.ScrollX) if (cursor_offset.x < edit_state.ScrollX)
edit_state.ScrollX = ImMax(0.0f, cursor_offset.x - scroll_increment_x); edit_state.ScrollX = (float)(int)ImMax(0.0f, cursor_offset.x - scroll_increment_x);
else if (cursor_offset.x - size.x >= edit_state.ScrollX) else if (cursor_offset.x - size.x >= edit_state.ScrollX)
edit_state.ScrollX = cursor_offset.x - size.x + scroll_increment_x; edit_state.ScrollX = (float)(int)(cursor_offset.x - size.x + scroll_increment_x);
} }
else else
{ {