mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
Fixed crash with long tooltip
This commit is contained in:
parent
07c2166321
commit
5934e27976
1 changed files with 18 additions and 7 deletions
|
@ -36,6 +36,7 @@ namespace Beefy.theme.dark
|
||||||
public bool mAllowMouseInsideSelf;
|
public bool mAllowMouseInsideSelf;
|
||||||
public bool mAllowMouseOutside;
|
public bool mAllowMouseOutside;
|
||||||
public int mAutoCloseDelay;
|
public int mAutoCloseDelay;
|
||||||
|
public bool mIsClipped;
|
||||||
|
|
||||||
public const float cShadowSize = 8;
|
public const float cShadowSize = 8;
|
||||||
|
|
||||||
|
@ -50,19 +51,26 @@ namespace Beefy.theme.dark
|
||||||
mText = new String(text);
|
mText = new String(text);
|
||||||
mAllowResize = allowResize;
|
mAllowResize = allowResize;
|
||||||
|
|
||||||
|
BFApp.sApp.GetWorkspaceRect(var workspaceX, var workspaceY, var workspaceWidth, var workspaceHeight);
|
||||||
|
float maxWidth = workspaceWidth - GS!(32);
|
||||||
|
|
||||||
FontMetrics fontMetrics = .();
|
FontMetrics fontMetrics = .();
|
||||||
float height = mFont.Draw(null, mText, x, y, 0, 0, FontOverflowMode.Overflow, &fontMetrics);
|
float height = mFont.Draw(null, mText, x, y, 0, 0, FontOverflowMode.Overflow, &fontMetrics);
|
||||||
mWidth = Math.Max(minWidth, fontMetrics.mMaxWidth + GS!(32));
|
mWidth = Math.Max(fontMetrics.mMaxWidth + GS!(32), minWidth);
|
||||||
mHeight = Math.Max(minHeight, height + GS!(16));
|
mHeight = Math.Clamp(height + GS!(16), minHeight, workspaceHeight);
|
||||||
|
|
||||||
|
if (mWidth > maxWidth)
|
||||||
|
{
|
||||||
|
mIsClipped = true;
|
||||||
|
mWidth = maxWidth;
|
||||||
|
}
|
||||||
|
|
||||||
float screenX;
|
float screenX;
|
||||||
float screenY;
|
float screenY;
|
||||||
relWidget.SelfToRootTranslate(x, y, out screenX, out screenY);
|
relWidget.SelfToRootTranslate(x, y, out screenX, out screenY);
|
||||||
screenX += relWidget.mWidgetWindow.mClientX;
|
screenX += relWidget.mWidgetWindow.mClientX;
|
||||||
screenY += relWidget.mWidgetWindow.mClientY;
|
screenY += relWidget.mWidgetWindow.mClientY;
|
||||||
//screenX -= 2;
|
|
||||||
//screenY += 14;
|
|
||||||
|
|
||||||
BFWindow.Flags windowFlags = BFWindow.Flags.ClientSized | BFWindow.Flags.PopupPosition | BFWindow.Flags.NoActivate | BFWindow.Flags.DestAlpha;
|
BFWindow.Flags windowFlags = BFWindow.Flags.ClientSized | BFWindow.Flags.PopupPosition | BFWindow.Flags.NoActivate | BFWindow.Flags.DestAlpha;
|
||||||
WidgetWindow widgetWindow = new WidgetWindow(relWidget.mWidgetWindow,
|
WidgetWindow widgetWindow = new WidgetWindow(relWidget.mWidgetWindow,
|
||||||
"Tooltip",
|
"Tooltip",
|
||||||
|
@ -170,7 +178,10 @@ namespace Beefy.theme.dark
|
||||||
g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Menu), 0, 0, mWidth, mHeight);
|
g.DrawBox(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Menu), 0, 0, mWidth, mHeight);
|
||||||
|
|
||||||
g.SetFont(mFont);
|
g.SetFont(mFont);
|
||||||
g.DrawString(mText, 0, GS!(5), FontAlign.Centered, mWidth);
|
if (mIsClipped)
|
||||||
|
g.DrawString(mText, GS!(8), GS!(5), .Left, mWidth - GS!(16), .Ellipsis);
|
||||||
|
else
|
||||||
|
g.DrawString(mText, 0, GS!(5), .Centered, mWidth);
|
||||||
|
|
||||||
if (mAllowResize)
|
if (mAllowResize)
|
||||||
g.Draw(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.ResizeGrabber), mWidth - GS!(22), mHeight - GS!(22));
|
g.Draw(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.ResizeGrabber), mWidth - GS!(22), mHeight - GS!(22));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue