diff --git a/BeefLibs/Beefy2D/src/gfx/Font.bf b/BeefLibs/Beefy2D/src/gfx/Font.bf index 9771f020..c626dd89 100644 --- a/BeefLibs/Beefy2D/src/gfx/Font.bf +++ b/BeefLibs/Beefy2D/src/gfx/Font.bf @@ -862,6 +862,12 @@ namespace Beefy.gfx else if (stringEndMode == FontOverflowMode.Wrap) { int32 maxChars = (int32)GetCharCountToLength(workingStr, width); + if (maxChars == 0) + { + if (workingStr.IsEmpty) + break; + maxChars = 1; + } int32 checkIdx = maxChars; if (checkIdx < workingStr.Length) diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkListView.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkListView.bf index dda5dd7d..7cfd7388 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkListView.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkListView.bf @@ -332,7 +332,12 @@ namespace Beefy.theme.dark } using (g.PushColor(mTextColor ?? DarkTheme.COLOR_TEXT)) - g.DrawString(mLabel, labelX, 0, .Left, wantWidth, ((nextContentColumn != -1) || (listView.mEndInEllipsis)) ? .Ellipsis : .Overflow); + { + FontOverflowMode overflowMode = ((nextContentColumn != -1) || (listView.mEndInEllipsis)) ? .Ellipsis : .Overflow; + if (listView.mWordWrap) + overflowMode = .Wrap; + g.DrawString(mLabel, labelX, 0, .Left, wantWidth, overflowMode); + } } } @@ -893,6 +898,7 @@ namespace Beefy.theme.dark public Color mGridLinesColor = 0x0CFFFFFF; public bool mShowHeader = true; public bool mEndInEllipsis; + public bool mWordWrap; public float mLabelX = DarkTheme.sUnitSize; public float mChildIndent = DarkTheme.sUnitSize; public float mOpenButtonX = 0; diff --git a/IDE/src/ui/HoverWatch.bf b/IDE/src/ui/HoverWatch.bf index 65535639..81a7a920 100644 --- a/IDE/src/ui/HoverWatch.bf +++ b/IDE/src/ui/HoverWatch.bf @@ -168,15 +168,22 @@ namespace IDE.ui public override void Draw(Graphics g) { - using (g.PushColor(0x80000000)) - g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.DropShadow), 0, 0, mWidth + GS!(8), mHeight + GS!(8)); - - using (g.PushColor(0xFFFFFFFF)) - g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Menu), 0, 0, mWidth, mHeight); - - base.Draw(g); + + base.Draw(g); } + public override void DrawAll(Graphics g) + { + using (g.PushColor(0x80000000)) + g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.DropShadow), 0, 0, mWidth + GS!(8), mHeight + GS!(8)); + + using (g.PushColor(0xFFFFFFFF)) + g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Menu), 0, 0, mWidth, mHeight); + + using (g.PushClip(0, 0, mWidth - GS!(3), mHeight)) + base.DrawAll(g); + } + public override void Update() { base.Update(); @@ -1029,8 +1036,8 @@ namespace IDE.ui { minX = Math.Min(minX, childWidget.mX); minY = Math.Min(minY, childWidget.mY); - maxX = Math.Max(maxX, childWidget.mX + childWidget.mWidth + 8); - maxY = Math.Max(maxY, childWidget.mY + childWidget.mHeight + 8); + maxX = Math.Max(maxX, childWidget.mX + childWidget.mWidth + GS!(8)); + maxY = Math.Max(maxY, childWidget.mY + childWidget.mHeight + GS!(8)); } mContentWidget.mX = -minX; @@ -1088,6 +1095,8 @@ namespace IDE.ui bool hasLeftIcon = false; bool hasRightValues = false; + bool wantWordWrap = false; + listView.mLabelX = GS!(40); float childHeights = 0; for (WatchListViewItem listViewItem in listView.GetRoot().mChildItems) @@ -1100,6 +1109,10 @@ namespace IDE.ui if (listViewItem.mLabel == null) continue; + + if (listViewItem.mWatchEntry.mEvalStr.StartsWith(':')) + wantWordWrap = true; + //nameWidth = Math.Max(nameWidth, font.GetWidth(listViewItem.mLabel)); //TODO: FontMetrics fontMetrics = .(); @@ -1144,7 +1157,7 @@ namespace IDE.ui listView.mColumns[0].mWidth = nameWidth + listView.mLabelX + GS!(8); listView.mColumns[1].mWidth = valueWidth + GS!(10); - float width = listView.mColumns[0].mWidth + listView.mColumns[1].mWidth + GS!(8); + float wantWidth = listView.mColumns[0].mWidth + listView.mColumns[1].mWidth + GS!(8); float height = childHeights + GS!(6); float maxHeight = font.GetLineSpacing() * 12 + 6.001f; @@ -1201,7 +1214,7 @@ namespace IDE.ui }); } height = maxHeight; - width += GS!(20); + wantWidth += GS!(20); } int workspaceX; @@ -1220,7 +1233,7 @@ namespace IDE.ui maxWidth = Math.Min(maxWidth, mTextPanel.mWidgetWindow.mWindowWidth); } - width = Math.Min(width, maxWidth); + var useWidth = Math.Min(wantWidth, maxWidth); if (!listView.mIsReversed) { @@ -1237,12 +1250,30 @@ namespace IDE.ui if (wantsHorzResize) { if (mWidgetWindow != null) - width = Math.Max(width, mWidgetWindow.mMouseX - popupX + GS!(12)); + useWidth = Math.Max(useWidth, mWidgetWindow.mMouseX - popupX + GS!(12)); } else - width = listView.mWidth; + useWidth = listView.mWidth; - listView.Resize(popupX, popupY, width, height); + if ((wantWordWrap) && (useWidth < wantWidth)) + { + for (WatchListViewItem listViewItem in listView.GetRoot().mChildItems) + { + if (listViewItem.mLabel == null) + continue; + + listView.mWordWrap = true; + FontMetrics fontMetrics = .(); + float nameHeight = font.Draw(null, listViewItem.mLabel, 0, 0, -1, useWidth - GS!(32), FontOverflowMode.Wrap, &fontMetrics); + + float addHeight = nameHeight - listViewItem.mSelfHeight; + height += addHeight; + } + + listView.mColumns[0].mWidth = useWidth - GS!(2); + } + + listView.Resize(popupX, popupY, useWidth, height); ResizeWindow(); }