mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-15 07:48:25 +00:00
InputText: moved blocks so same text rendering code is now used for active and inactive states.
(ignore whitespace to visualize this change easily)
This commit is contained in:
@@ -5493,10 +5493,14 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color);
|
draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find render position for right alignment (single-line only)
|
||||||
|
if (g.ActiveId != id && flags & ImGuiInputTextFlags_ElideLeft)
|
||||||
|
draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - CalcTextSize(buf_display, NULL).x - style.FramePadding.x);
|
||||||
|
//draw_scroll.x = state->Scroll.x; // Preserve scroll when inactive?
|
||||||
|
|
||||||
// Render text
|
// Render text
|
||||||
// We test for 'buf_display_max_length' as a way to avoid some pathological cases (e.g. single-line 1 MB string) which would make ImDrawList crash.
|
|
||||||
// FIXME-OPT: Multiline could submit a smaller amount of contents to AddText() since we already iterated through it.
|
|
||||||
if ((is_multiline || (buf_display_end - buf_display) < buf_display_max_length) && (text_col & IM_COL32_A_MASK) && (line_visible_n0 < line_visible_n1))
|
if ((is_multiline || (buf_display_end - buf_display) < buf_display_max_length) && (text_col & IM_COL32_A_MASK) && (line_visible_n0 < line_visible_n1))
|
||||||
g.Font->RenderText(draw_window->DrawList, g.FontSize,
|
g.Font->RenderText(draw_window->DrawList, g.FontSize,
|
||||||
draw_pos - draw_scroll + ImVec2(0.0f, line_visible_n0 * g.FontSize),
|
draw_pos - draw_scroll + ImVec2(0.0f, line_visible_n0 * g.FontSize),
|
||||||
@@ -5505,7 +5509,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
line_index->get_line_end(buf_display, line_visible_n1 - 1),
|
line_index->get_line_end(buf_display, line_visible_n1 - 1),
|
||||||
wrap_width, ImDrawTextFlags_WrapKeepBlanks);
|
wrap_width, ImDrawTextFlags_WrapKeepBlanks);
|
||||||
|
|
||||||
// Draw blinking cursor
|
// Render blinking cursor
|
||||||
if (render_cursor)
|
if (render_cursor)
|
||||||
{
|
{
|
||||||
state->CursorAnim += io.DeltaTime;
|
state->CursorAnim += io.DeltaTime;
|
||||||
@@ -5528,23 +5532,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
ime_data->ViewportId = window->Viewport->ID;
|
ime_data->ViewportId = window->Viewport->ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Find render position for right alignment (single-line only)
|
|
||||||
if (flags & ImGuiInputTextFlags_ElideLeft)
|
|
||||||
draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - CalcTextSize(buf_display, NULL).x - style.FramePadding.x);
|
|
||||||
|
|
||||||
// Render text only (no selection, no cursor)
|
|
||||||
//draw_scroll.x = state->Scroll.x; // Preserve scroll when inactive?
|
|
||||||
if ((is_multiline || (buf_display_end - buf_display) < buf_display_max_length) && (text_col & IM_COL32_A_MASK) && (line_visible_n0 < line_visible_n1))
|
|
||||||
g.Font->RenderText(draw_window->DrawList, g.FontSize,
|
|
||||||
draw_pos - draw_scroll + ImVec2(0.0f, line_visible_n0 * g.FontSize),
|
|
||||||
text_col, clip_rect.AsVec4(),
|
|
||||||
line_index->get_line_begin(buf_display, line_visible_n0),
|
|
||||||
line_index->get_line_end(buf_display, line_visible_n1 - 1),
|
|
||||||
wrap_width, ImDrawTextFlags_WrapKeepBlanks);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_password && !is_displaying_hint)
|
if (is_password && !is_displaying_hint)
|
||||||
PopPasswordFont();
|
PopPasswordFont();
|
||||||
|
Reference in New Issue
Block a user