From 76d997fca75bf97d44eb85861b44c359b2104e48 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 2 Feb 2021 14:58:01 -0800 Subject: [PATCH] Better word wrapping for hoverwatch --- BeefLibs/Beefy2D/src/gfx/Font.bf | 2 +- IDE/src/ui/HoverWatch.bf | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/BeefLibs/Beefy2D/src/gfx/Font.bf b/BeefLibs/Beefy2D/src/gfx/Font.bf index c626dd89..f40459a4 100644 --- a/BeefLibs/Beefy2D/src/gfx/Font.bf +++ b/BeefLibs/Beefy2D/src/gfx/Font.bf @@ -887,7 +887,7 @@ namespace Beefy.gfx if (fontMetrics != null) fontMetrics.mLineCount++; - drawHeight += Draw(g, StringView(workingStr, 0, checkIdx), useX, useY, justification, width, stringEndMode, fontMetrics); + drawHeight += Draw(g, StringView(workingStr, 0, checkIdx), useX, useY, justification, width, .Truncate, fontMetrics); useY += GetLineSpacing(); workingStr.Adjust(checkIdx); } diff --git a/IDE/src/ui/HoverWatch.bf b/IDE/src/ui/HoverWatch.bf index 50247f85..050c07b4 100644 --- a/IDE/src/ui/HoverWatch.bf +++ b/IDE/src/ui/HoverWatch.bf @@ -1257,6 +1257,8 @@ namespace IDE.ui if ((wantWordWrap) && (useWidth < wantWidth)) { + float actualMaxWidth = 0; + for (WatchListViewItem listViewItem in listView.GetRoot().mChildItems) { if (listViewItem.mLabel == null) @@ -1265,11 +1267,14 @@ namespace IDE.ui listView.mWordWrap = true; FontMetrics fontMetrics = .(); float nameHeight = font.Draw(null, listViewItem.mLabel, 0, 0, -1, useWidth - GS!(32), FontOverflowMode.Wrap, &fontMetrics); + actualMaxWidth = Math.Max(actualMaxWidth, fontMetrics.mMaxWidth); float addHeight = nameHeight - listViewItem.mSelfHeight; height += addHeight; } + useWidth = actualMaxWidth + GS!(32); + listView.mColumns[0].mWidth = useWidth - GS!(2); }