|
@@ -4821,6 +4821,15 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
if (is_password && !is_displaying_hint)
|
|
if (is_password && !is_displaying_hint)
|
|
PushPasswordFont();
|
|
PushPasswordFont();
|
|
|
|
|
|
|
|
+ // Word-wrapping: attempt to keep cursor in view while resizing frame/parent
|
|
|
|
+ // FIXME-WORDWRAP: It would be better to preserve same relative offset.
|
|
|
|
+ if (is_wordwrap && state != NULL && state->ID == id && state->WrapWidth != wrap_width)
|
|
|
|
+ {
|
|
|
|
+ state->CursorCenterY = true;
|
|
|
|
+ state->WrapWidth = wrap_width;
|
|
|
|
+ render_cursor = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Process mouse inputs and character inputs
|
|
// Process mouse inputs and character inputs
|
|
if (g.ActiveId == id)
|
|
if (g.ActiveId == id)
|
|
{
|
|
{
|
|
@@ -5414,6 +5423,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
}
|
|
}
|
|
|
|
|
|
// Scroll
|
|
// Scroll
|
|
|
|
+ float new_scroll_y = scroll_y;
|
|
if (render_cursor && state->CursorFollow)
|
|
if (render_cursor && state->CursorFollow)
|
|
{
|
|
{
|
|
// Horizontal scroll in chunks of quarter width
|
|
// Horizontal scroll in chunks of quarter width
|
|
@@ -5436,17 +5446,26 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|
{
|
|
{
|
|
// Test if cursor is vertically visible
|
|
// Test if cursor is vertically visible
|
|
if (cursor_offset.y - g.FontSize < scroll_y)
|
|
if (cursor_offset.y - g.FontSize < scroll_y)
|
|
- scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize);
|
|
|
|
|
|
+ new_scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize);
|
|
else if (cursor_offset.y - (inner_size.y - style.FramePadding.y * 2.0f) >= scroll_y)
|
|
else if (cursor_offset.y - (inner_size.y - style.FramePadding.y * 2.0f) >= scroll_y)
|
|
- scroll_y = cursor_offset.y - inner_size.y + style.FramePadding.y * 2.0f;
|
|
|
|
- const float scroll_max_y = ImMax((text_size.y + style.FramePadding.y * 2.0f) - inner_size.y, 0.0f);
|
|
|
|
- scroll_y = ImClamp(scroll_y, 0.0f, scroll_max_y);
|
|
|
|
- draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag
|
|
|
|
- draw_window->Scroll.y = scroll_y;
|
|
|
|
|
|
+ new_scroll_y = cursor_offset.y - inner_size.y + style.FramePadding.y * 2.0f;
|
|
}
|
|
}
|
|
-
|
|
|
|
state->CursorFollow = false;
|
|
state->CursorFollow = false;
|
|
}
|
|
}
|
|
|
|
+ if (state->CursorCenterY)
|
|
|
|
+ {
|
|
|
|
+ if (is_multiline)
|
|
|
|
+ new_scroll_y = cursor_offset.y - g.FontSize - (inner_size.y * 0.5f - style.FramePadding.y);
|
|
|
|
+ state->CursorCenterY = false;
|
|
|
|
+ render_cursor = false;
|
|
|
|
+ }
|
|
|
|
+ if (new_scroll_y != scroll_y)
|
|
|
|
+ {
|
|
|
|
+ const float scroll_max_y = ImMax((text_size.y + style.FramePadding.y * 2.0f) - inner_size.y, 0.0f);
|
|
|
|
+ scroll_y = ImClamp(new_scroll_y, 0.0f, scroll_max_y);
|
|
|
|
+ draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag
|
|
|
|
+ draw_window->Scroll.y = scroll_y;
|
|
|
|
+ }
|
|
|
|
|
|
// Draw selection
|
|
// Draw selection
|
|
const ImVec2 draw_scroll = ImVec2(state->Scroll.x, 0.0f);
|
|
const ImVec2 draw_scroll = ImVec2(state->Scroll.x, 0.0f);
|