ImStrv: detect and fixed misuses of CalcTextSize() old signature. (9321) For IMGUI_DISABLE_OBSOLETE_FUNCTIONS only.
diff --git a/imgui.cpp b/imgui.cpp index 3cab409..da2042a 100644 --- a/imgui.cpp +++ b/imgui.cpp
@@ -17200,7 +17200,7 @@ ImGuiContext& g = *GImGui; const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 label_size = CalcTextSize(label, true); ImVec2 pos = window->DC.CursorPos + ImVec2(0.0f, window->DC.CurrLineTextBaseOffset); ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x * 2.0f, label_size.y);
diff --git a/imgui.h b/imgui.h index 595b2ae..bc9be82 100644 --- a/imgui.h +++ b/imgui.h
@@ -1195,6 +1195,10 @@ inline IM_FMTLIST(3) bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) { return TreeNodeEx(ImStrv(str_id), flags, fmt, args); } inline void TreePush(const char* str_id) { TreePush(ImStrv(str_id)); } IM_MSVC_RUNTIME_CHECKS_RESTORE + + // Detect misuses (#9321) + // FIXME-IMSTR: Validate that syntax is ok for our minimum target. + ImVec2 CalcTextSize(ImStrv, const char*, bool hide_text_after_double_hash = false, float wrap_width = -1.0f) = delete; } //-----------------------------------------------------------------------------
diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 5c154d4..ab0b383 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp
@@ -3128,7 +3128,7 @@ for (int column_n = 0; column_n < table->ColumnsCount; column_n++) if (IM_BITARRAY_TESTBIT(table->EnabledMaskByIndex, column_n)) if (table->Columns[column_n].Flags & ImGuiTableColumnFlags_AngledHeader) - width = ImMax(width, CalcTextSize(TableGetColumnName(table, column_n), NULL, true).x); + width = ImMax(width, CalcTextSize(TableGetColumnName(table, column_n), true).x); return width + g.Style.CellPadding.y * 2.0f; // Swap padding } @@ -3537,7 +3537,7 @@ ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; - ImVec2 label_size = CalcTextSize(label, NULL, true); + ImVec2 label_size = CalcTextSize(label, true); ImGuiMenuColumns* offsets = &window->DC.MenuColumns; float checkmark_w = IM_TRUNC(g.FontSize * 1.20f); float min_w = offsets->DeclColumns(0.0f, label_size.x, 0.0f, checkmark_w); // Feedback for next frame
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 28e4f9b..b41ec56 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp
@@ -1517,7 +1517,6 @@ 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 @@ 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 @@ // 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