Skip to content

Commit cb82ed6

Browse files
committed
Handle breaking changes from dear imgui
1 parent 6945851 commit cb82ed6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

UImGuiTextUtilsTextMarkdown.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,27 @@ UImGui::TextUtils::WidgetState UImGui::TextUtils::renderWrappedTextGeneric(const
247247
Colour)>& render) noexcept
248248
{
249249
const float scale = ImGui::GetIO().FontGlobalScale;
250+
const float size = ImGui::GetFontSize();
250251
float widthAvail = ImGui::GetContentRegionAvail().x;
251252
const char* endLine = text;
252253

253254
if (widthAvail > 0.0f)
255+
#if IMGUI_VERSION_NUM > 19196
256+
endLine = ImGui::GetFont()->CalcWordWrapPosition(size * scale, text, end, widthAvail);
257+
#else
254258
endLine = ImGui::GetFont()->CalcWordWrapPositionA(scale, text, end, widthAvail);
259+
#endif
255260
if (endLine > text && endLine < end)
256261
{
257262
if (isPartOfWord(*endLine))
258263
{
259264
// Get maximum line width like this because dear imgui rc 1.90.9+ deprecated these
260265
const float nextLineWidth = (ImGui::GetContentRegionAvail() + ImGui::GetCursorScreenPos()).x;
266+
#if IMGUI_VERSION_NUM > 19196
267+
const char* nextLineEnd = ImGui::GetFont()->CalcWordWrapPosition(size * scale, text, end, nextLineWidth);
268+
#else
261269
const char* nextLineEnd = ImGui::GetFont()->CalcWordWrapPositionA(scale, text, end, nextLineWidth);
270+
#endif
262271
if (nextLineEnd == end || (nextLineEnd <= end && !isPartOfWord(*nextLineEnd)))
263272
endLine = text;
264273
}
@@ -281,7 +290,11 @@ UImGui::TextUtils::WidgetState UImGui::TextUtils::renderWrappedTextGeneric(const
281290
text = endLine;
282291
if (*text == ' ')
283292
++text;
293+
#if IMGUI_VERSION_NUM > 19196
294+
endLine = ImGui::GetFont()->CalcWordWrapPosition(size * scale, text, end, widthAvail);
295+
#else
284296
endLine = ImGui::GetFont()->CalcWordWrapPositionA(scale, text, end, widthAvail);
297+
#endif
285298
if (text == endLine)
286299
endLine++;
287300
ImGui::PushTextWrapPos(-1.0f);

0 commit comments

Comments
 (0)