Browse Source
Merge pull request #3018 from AvaloniaUI/fix-osx-popup-positioning
Fix osx popup positioning
pull/3024/head
danwalmsley
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
22 additions and
5 deletions
-
src/Avalonia.Controls/Primitives/PopupPositioning/ManagedPopupPositionerPopupImplHelper.cs
-
src/Avalonia.Native/AvaloniaNativePlatform.cs
-
src/Avalonia.Native/OsxManagedPopupPositionerPopupImplHelper.cs
-
src/Avalonia.Native/PopupImpl.cs
|
|
|
@ -32,7 +32,7 @@ namespace Avalonia.Controls.Primitives.PopupPositioning |
|
|
|
{ |
|
|
|
// Popup positioner operates with abstract coordinates, but in our case they are pixel ones
|
|
|
|
var point = _parent.PointToScreen(default); |
|
|
|
var size = PixelSize.FromSize(_parent.ClientSize, _parent.Scaling); |
|
|
|
var size = TranslateSize(_parent.ClientSize); |
|
|
|
return new Rect(point.X, point.Y, size.Width, size.Height); |
|
|
|
|
|
|
|
} |
|
|
|
@ -43,8 +43,8 @@ namespace Avalonia.Controls.Primitives.PopupPositioning |
|
|
|
_moveResize(new PixelPoint((int)devicePoint.X, (int)devicePoint.Y), virtualSize, _parent.Scaling); |
|
|
|
} |
|
|
|
|
|
|
|
public Point TranslatePoint(Point pt) => pt * _parent.Scaling; |
|
|
|
public virtual Point TranslatePoint(Point pt) => pt * _parent.Scaling; |
|
|
|
|
|
|
|
public Size TranslateSize(Size size) => size * _parent.Scaling; |
|
|
|
public virtual Size TranslateSize(Size size) => size * _parent.Scaling; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
using System; |
|
|
|
using System.Diagnostics.Contracts; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using Avalonia.Controls.Platform; |
|
|
|
using Avalonia.Input; |
|
|
|
|
|
|
|
@ -0,0 +1,18 @@ |
|
|
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
using Avalonia.Controls.Primitives.PopupPositioning; |
|
|
|
using Avalonia.Platform; |
|
|
|
|
|
|
|
namespace Avalonia.Native |
|
|
|
{ |
|
|
|
class OsxManagedPopupPositionerPopupImplHelper : ManagedPopupPositionerPopupImplHelper |
|
|
|
{ |
|
|
|
public OsxManagedPopupPositionerPopupImplHelper(IWindowBaseImpl parent, MoveResizeDelegate moveResize) : base(parent, moveResize) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
public override Point TranslatePoint(Point pt) => pt; |
|
|
|
|
|
|
|
public override Size TranslateSize(Size size) => size; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -22,7 +22,7 @@ namespace Avalonia.Native |
|
|
|
{ |
|
|
|
Init(factory.CreatePopup(e), factory.CreateScreens()); |
|
|
|
} |
|
|
|
PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(parent, MoveResize)); |
|
|
|
PopupPositioner = new ManagedPopupPositioner(new OsxManagedPopupPositionerPopupImplHelper(parent, MoveResize)); |
|
|
|
} |
|
|
|
|
|
|
|
private void MoveResize(PixelPoint position, Size size, double scaling) |
|
|
|
|