diff --git a/BeefLibs/Beefy2D/src/BFApp.bf b/BeefLibs/Beefy2D/src/BFApp.bf index 6c341123..d1518b0a 100644 --- a/BeefLibs/Beefy2D/src/BFApp.bf +++ b/BeefLibs/Beefy2D/src/BFApp.bf @@ -332,6 +332,22 @@ namespace Beefy } } + public Point? CursorScreenPos + { + get + { + for (var window in mWindows) + { + if (var widgetWindow = window as WidgetWindow) + { + if (widgetWindow.mHasMouseInside) + return .(widgetWindow.mClientMouseX + widgetWindow.mClientX, widgetWindow.mClientMouseY + widgetWindow.mClientY); + } + } + return null; + } + } + public static void Startup(String[] args, Action startupCallback) { /*string[] newArgs = new string[args.Length + 1]; diff --git a/BeefLibs/Beefy2D/src/BFWindow.bf b/BeefLibs/Beefy2D/src/BFWindow.bf index a4cdf220..b553a2ab 100644 --- a/BeefLibs/Beefy2D/src/BFWindow.bf +++ b/BeefLibs/Beefy2D/src/BFWindow.bf @@ -5,6 +5,7 @@ using System.Diagnostics; using Beefy.gfx; using Beefy.sys; using System.IO; +using Beefy.geom; #if MONOTOUCH using MonoTouch; @@ -327,6 +328,9 @@ namespace Beefy static void Static_NativeDragDropFileDelegate(void* window, char8* filePath) { GetBFWindow(window).DragDropFile(StringView(filePath)); } #endif + public Rect ClientRect => .(mClientX, mClientY, mClientWidth, mClientHeight); + public Rect WindowRect => .(mX, mY, mWindowWidth, mWindowHeight); + public this() { } diff --git a/BeefLibs/Beefy2D/src/geom/Rect.bf b/BeefLibs/Beefy2D/src/geom/Rect.bf index 32beb6ed..8c9de8bf 100644 --- a/BeefLibs/Beefy2D/src/geom/Rect.bf +++ b/BeefLibs/Beefy2D/src/geom/Rect.bf @@ -97,6 +97,14 @@ namespace Beefy.geom public T CenterX => mX + mWidth / 2; public T CenterY => mY + mHeight / 2; + public static Rect operator implicit (Rect value) + where T : operator implicit TOther + where TOther : operator TOther + TOther, operator TOther - TOther, operator TOther * TOther, operator TOther / TOther, operator -TOther, operator TOther / int8, IIsNaN, operator implicit int8 + where int : operator TOther <=> TOther + { + return .(value.mX, value.mY, value.mWidth, value.mHeight); + } + public this(T x = default, T y = default, T width = default, T height = default) { mX = x; diff --git a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf index 66c68f20..34e0e81c 100644 --- a/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf +++ b/BeefLibs/Beefy2D/src/theme/dark/DarkTooltip.bf @@ -33,7 +33,7 @@ namespace Beefy.theme.dark public bool mAllowResize; public bool mHasClosed; public Insets mRelWidgetMouseInsets ~ delete _; - public bool mAllowMouseInsideSelf; + public Insets mAllowMouseInsideInsets ~ delete _; public bool mAllowMouseOutside; public int mAutoCloseDelay; public bool mIsClipped; @@ -162,7 +162,7 @@ namespace Beefy.theme.dark int32 relX = x - mWidgetWindow.mX; int32 relY = y - mWidgetWindow.mY; - if ((relX >= mWidgetWindow.mWindowWidth - GS!(18)) && (relY >= mWidgetWindow.mWindowHeight - GS!(18))) + if ((relX >= mWidgetWindow.mWindowWidth - GS!(22)) && (relY >= mWidgetWindow.mWindowHeight - GS!(22))) return BFWindowBase.HitTestResult.BottomRight; return BFWindowBase.HitTestResult.Client; } @@ -256,13 +256,31 @@ namespace Beefy.theme.dark mRelWidgetMouseInsets?.ApplyTo(ref checkRect); if ((mRelWidget.mWidgetWindow != null) && (mRelWidget.mWidgetWindow.mHasMouseInside)) { - //checkRect.Inflate(8, 8); if (checkRect.Contains(mRelWidget.mWidgetWindow.mClientMouseX, mRelWidget.mWidgetWindow.mClientMouseY)) return; } + if (mAllowMouseInsideInsets != null) + { + if (mWidgetWindow.mHasMouseInside) + return; - if ((mWidgetWindow.mHasMouseInside) && (mAllowMouseInsideSelf)) - return; + Rect clientRect = mWidgetWindow.ClientRect; + mAllowMouseInsideInsets.ApplyTo(ref clientRect); + + var cursorScreenPos = BFApp.sApp.CursorScreenPos; + if (cursorScreenPos != null) + { + if (clientRect.Contains((.)cursorScreenPos.Value.x, (.)cursorScreenPos.Value.y)) + return; + } + + NOP!(); + + /*var screenX = (int32)rootX + mWidgetWindow.mClientX; + var screenY = (int32)rootY + mWidgetWindow.mClientY; + if (clientRect.Contains(screenX, screenY)) + return;*/ + } var checkWindow = BFApp.sApp.FocusedWindow; if ((checkWindow != null) && (checkWindow.HasParent(mWidgetWindow))) diff --git a/IDE/src/ui/PanelHeader.bf b/IDE/src/ui/PanelHeader.bf index 8d0ed6d9..8c1da1e9 100644 --- a/IDE/src/ui/PanelHeader.bf +++ b/IDE/src/ui/PanelHeader.bf @@ -141,7 +141,7 @@ namespace IDE.ui var editWidget = new WatchStringEdit(mTooltipText, null); tooltip.mRelWidgetMouseInsets = new Insets(0, 0, GS!(-8), 0); - tooltip.mAllowMouseInsideSelf = true; + tooltip.mAllowMouseInsideInsets = new .(); tooltip.AddWidget(editWidget); tooltip.mOnResized.Add(new (widget) => editWidget.Resize(GS!(6), GS!(6), widget.mWidth - GS!(6) * 2, widget.mHeight - GS!(6) * 2)); tooltip.mOnResized(tooltip); diff --git a/IDE/src/ui/WatchPanel.bf b/IDE/src/ui/WatchPanel.bf index dfd1b387..7c41a6e2 100644 --- a/IDE/src/ui/WatchPanel.bf +++ b/IDE/src/ui/WatchPanel.bf @@ -1941,7 +1941,7 @@ namespace IDE.ui if (tooltip != null) { tooltip.mRelWidgetMouseInsets = new Insets(0, 0, GS!(-8), 0); - tooltip.mAllowMouseInsideSelf = true; + tooltip.mAllowMouseInsideInsets = new .(GS!(-12), GS!(-12), GS!(-4), GS!(-4)); tooltip.AddWidget(watchStringEdit); tooltip.mOnResized.Add(new (widget) => watchStringEdit.Resize(GS!(6), GS!(6), widget.mWidth - GS!(6) * 2, widget.mHeight - GS!(6) * 2)); tooltip.mOnResized(tooltip);