Merge remote-tracking branch 'origin/master' into 1.7
# Conflicts: # Source/Editor/Viewport/PrefabWindowViewport.cs # Source/Engine/Physics/PhysX/SimulationEventCallbackPhysX.cpp
This commit is contained in:
@@ -68,26 +68,12 @@ namespace FlaxEngine.GUI
|
||||
var parentWin = target.Root;
|
||||
if (parentWin == null)
|
||||
return;
|
||||
float dpiScale = target.RootWindow.DpiScale;
|
||||
var dpiScale = target.RootWindow.DpiScale;
|
||||
var dpiSize = Size * dpiScale;
|
||||
var locationWS = target.PointToWindow(location);
|
||||
var locationSS = parentWin.PointToScreen(locationWS);
|
||||
var monitorBounds = Platform.GetMonitorBounds(locationSS);
|
||||
var rightBottomMonitorBounds = monitorBounds.BottomRight;
|
||||
var rightBottomLocationSS = locationSS + dpiSize;
|
||||
|
||||
// Prioritize tooltip placement within parent window, fall back to virtual desktop
|
||||
if (rightBottomMonitorBounds.Y < rightBottomLocationSS.Y)
|
||||
{
|
||||
// Direction: up
|
||||
locationSS.Y -= dpiSize.Y;
|
||||
}
|
||||
if (rightBottomMonitorBounds.X < rightBottomLocationSS.X)
|
||||
{
|
||||
// Direction: left
|
||||
locationSS.X -= dpiSize.X;
|
||||
}
|
||||
_showTarget = target;
|
||||
WrapPosition(ref locationSS);
|
||||
|
||||
// Create window
|
||||
var desc = CreateWindowSettings.Default;
|
||||
@@ -106,6 +92,7 @@ namespace FlaxEngine.GUI
|
||||
desc.IsTopmost = true;
|
||||
desc.IsRegularWindow = false;
|
||||
desc.HasSizingFrame = false;
|
||||
desc.ShowAfterFirstPaint = true;
|
||||
_window = Platform.CreateWindow(ref desc);
|
||||
if (_window == null)
|
||||
throw new InvalidOperationException("Failed to create tooltip window.");
|
||||
@@ -192,11 +179,37 @@ namespace FlaxEngine.GUI
|
||||
}
|
||||
}
|
||||
|
||||
private void WrapPosition(ref Float2 locationSS, float flipOffset = 0.0f)
|
||||
{
|
||||
// Calculate popup direction
|
||||
var dpiScale = _showTarget.RootWindow.DpiScale;
|
||||
var dpiSize = Size * dpiScale;
|
||||
var monitorBounds = Platform.GetMonitorBounds(locationSS);
|
||||
var rightBottomMonitorBounds = monitorBounds.BottomRight;
|
||||
var rightBottomLocationSS = locationSS + dpiSize;
|
||||
|
||||
// Prioritize tooltip placement within parent window, fall back to virtual desktop
|
||||
if (rightBottomMonitorBounds.Y < rightBottomLocationSS.Y)
|
||||
{
|
||||
// Direction: up
|
||||
locationSS.Y -= dpiSize.Y + flipOffset;
|
||||
}
|
||||
if (rightBottomMonitorBounds.X < rightBottomLocationSS.X)
|
||||
{
|
||||
// Direction: left
|
||||
locationSS.X -= dpiSize.X + flipOffset * 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
// Auto hide if mouse leaves control area
|
||||
// Move window with mouse location
|
||||
var mousePos = Input.MouseScreenPosition;
|
||||
WrapPosition(ref mousePos, 10);
|
||||
_window.Position = mousePos + new Float2(15, 10);
|
||||
|
||||
// Auto hide if mouse leaves control area
|
||||
var location = _showTarget.PointFromScreen(mousePos);
|
||||
if (!_showTarget.OnTestTooltipOverControl(ref location))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user