1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

More lenient mouse behavior for multiline string popup

This commit is contained in:
Brian Fiete 2024-12-29 09:00:06 -08:00
parent cac67b8288
commit e300800ca0
6 changed files with 53 additions and 7 deletions

View file

@ -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];

View file

@ -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<int32> ClientRect => .(mClientX, mClientY, mClientWidth, mClientHeight);
public Rect<int32> WindowRect => .(mX, mY, mWindowWidth, mWindowHeight);
public this()
{
}

View file

@ -97,6 +97,14 @@ namespace Beefy.geom
public T CenterX => mX + mWidth / 2;
public T CenterY => mY + mHeight / 2;
public static Rect<T> operator implicit <TOther>(Rect<TOther> 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;

View file

@ -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<float> 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)))

View file

@ -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);

View file

@ -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);