ImStrv: detect and fixed misuses of CalcTextSize() old signature. (9321)

For IMGUI_DISABLE_OBSOLETE_FUNCTIONS only.
This commit is contained in:
ocornut
2026-03-25 12:22:53 +01:00
parent 862420cec7
commit f110094bd4
4 changed files with 10 additions and 7 deletions

View File

@@ -1517,7 +1517,6 @@ bool ImGui::TextLink(ImStrv label)
ImGuiContext& g = *GImGui;
const ImGuiID id = window->GetID(label);
const ImStrv label_for_display(label.Begin, FindRenderedTextEnd(label));
ImVec2 pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset);
ImVec2 size = CalcTextSize(label_for_display, false);
@@ -5609,14 +5608,14 @@ bool ImGui::InputTextEx(ImStrv label, ImStrv hint, char* buf, int buf_size, cons
float rect_width = 0.0f;
if (line_selected_begin < line_selected_end)
rect_width += CalcTextSize(line_selected_begin, line_selected_end).x;
rect_width += CalcTextSize(ImStrv(line_selected_begin, line_selected_end)).x;
if (text_selected_begin <= p_eol && text_selected_end > p_eol && !p_eol_is_wrap)
rect_width += bg_eol_width; // So we can see selected empty lines
if (rect_width == 0.0f)
continue;
ImRect rect;
rect.Min.x = draw_pos.x - draw_scroll.x + CalcTextSize(p, line_selected_begin).x;
rect.Min.x = draw_pos.x - draw_scroll.x + CalcTextSize(ImStrv(p, line_selected_begin)).x;
rect.Min.y = draw_pos.y - draw_scroll.y + line_n * g.FontSize;
rect.Max.x = rect.Min.x + rect_width;
rect.Max.y = rect.Min.y + bg_offy_dn + g.FontSize;
@@ -5629,7 +5628,7 @@ bool ImGui::InputTextEx(ImStrv label, ImStrv hint, char* buf, int buf_size, cons
// Find render position for right alignment (single-line only)
if (g.ActiveId != id && (flags & ImGuiInputTextFlags_ElideLeft) && !render_cursor && !render_selection)
draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - CalcTextSize(buf_display, NULL).x - style.FramePadding.x);
draw_pos.x = ImMin(draw_pos.x, frame_bb.Max.x - CalcTextSize(buf_display).x - style.FramePadding.x);
//draw_scroll.x = state->Scroll.x; // Preserve scroll when inactive?
// Render text