1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Beefy 2D updates

This commit is contained in:
Brian Fiete 2025-02-02 18:21:15 -08:00
parent cbba8399ec
commit e0529caee0
2 changed files with 22 additions and 12 deletions

View file

@ -262,6 +262,7 @@ namespace Beefy.geom
} }
} }
typealias RectI32 = Rect<int32>;
typealias Rect = Rect<float>; typealias Rect = Rect<float>;
typealias RectD = Rect<double>; typealias RectD = Rect<double>;
} }

View file

@ -96,6 +96,21 @@ namespace Beefy.theme.dark
Detach(); Detach();
} }
public static Point CalcSize(StringView text, float x = 0, float y = 0)
{
var font = DarkTheme.sDarkTheme.mSmallFont;
float minWidth = 0;
float minHeight = 0;
BFApp.sApp.GetWorkspaceRectFrom((.)x, (.)y, 0, 0, var workspaceX, var workspaceY, var workspaceWidth, var workspaceHeight);
FontMetrics fontMetrics = .();
float height = font.Draw(null, text, x, y, 0, 0, FontOverflowMode.Overflow, &fontMetrics);
float tooltipWidth = Math.Max(fontMetrics.mMaxWidth + GS!(32), minWidth);
float tooltipHeight = Math.Clamp(height + GS!(16), minHeight, workspaceHeight);
return .(tooltipWidth, tooltipHeight);
}
void Attach(Widget widget) void Attach(Widget widget)
{ {
if (mRelWidget != null) if (mRelWidget != null)
@ -251,12 +266,15 @@ namespace Beefy.theme.dark
if (mAllowMouseOutside) if (mAllowMouseOutside)
return; return;
Rect widgetRect = .(0, 0, mRelWidget.mWidth, mRelWidget.mHeight);
mRelWidgetMouseInsets?.ApplyTo(ref widgetRect);
float rootX; float rootX;
float rootY; float rootY;
mRelWidget.SelfToRootTranslate(0, 0, out rootX, out rootY); mRelWidget.SelfToRootTranslate(widgetRect.mX, widgetRect.mY, out rootX, out rootY);
Rect checkRect = Rect(rootX, rootY, mRelWidget.mWidth, mRelWidget.mHeight); Rect checkRect = Rect(rootX, rootY, widgetRect.mWidth, widgetRect.mHeight);
mRelWidgetMouseInsets?.ApplyTo(ref checkRect);
if ((mRelWidget.mWidgetWindow != null) && (mRelWidget.mWidgetWindow.mHasMouseInside)) if ((mRelWidget.mWidgetWindow != null) && (mRelWidget.mWidgetWindow.mHasMouseInside))
{ {
if (checkRect.Contains(mRelWidget.mWidgetWindow.mClientMouseX, mRelWidget.mWidgetWindow.mClientMouseY)) if (checkRect.Contains(mRelWidget.mWidgetWindow.mClientMouseX, mRelWidget.mWidgetWindow.mClientMouseY))
@ -444,15 +462,6 @@ namespace Beefy.theme.dark
SetLastMouseWidget(null); SetLastMouseWidget(null);
sMouseStillTicks = -1; sMouseStillTicks = -1;
} }
if (numOverWidgets > 1)
{
//int a = 0;
Debug.WriteLine("numOverWidgets > 1");
}
//Debug.Assert(numOverWidgets <= 1);
} }
} }
} }