Browse Source
Merge branch 'master' into ShapedBufferPooling2
pull/9962/head
Benedikt Stebner
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with
32 additions and
11 deletions
-
samples/ControlCatalog/Pages/DialogsPage.xaml.cs
-
samples/ControlCatalog/Pages/NotificationsPage.xaml.cs
-
src/Avalonia.Base/Input/GestureRecognizers/ScrollGestureRecognizer.cs
-
src/Avalonia.Base/Input/ScrollGestureEventArgs.cs
-
src/Avalonia.Controls/ComboBox.cs
-
src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs
-
src/Avalonia.Controls/Primitives/OverlayPopupHost.cs
-
src/Avalonia.Controls/Primitives/Popup.cs
-
src/Avalonia.Controls/TopLevel.cs
-
src/Avalonia.Native/AvaloniaNativeDragSource.cs
-
src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs
|
|
|
@ -396,8 +396,8 @@ CanPickFolder: {storageProvider.CanPickFolder}"; |
|
|
|
return item.TryGetUri(out var uri) ? uri.ToString() : item.Name; |
|
|
|
} |
|
|
|
|
|
|
|
Window GetWindow() => this.VisualRoot as Window ?? throw new NullReferenceException("Invalid Owner"); |
|
|
|
TopLevel GetTopLevel() => this.VisualRoot as TopLevel ?? throw new NullReferenceException("Invalid Owner"); |
|
|
|
Window GetWindow() => TopLevel.GetTopLevel(this) as Window ?? throw new NullReferenceException("Invalid Owner"); |
|
|
|
TopLevel GetTopLevel() => TopLevel.GetTopLevel(this) ?? throw new NullReferenceException("Invalid Owner"); |
|
|
|
|
|
|
|
private void InitializeComponent() |
|
|
|
{ |
|
|
|
|
|
|
|
@ -27,7 +27,7 @@ namespace ControlCatalog.Pages |
|
|
|
{ |
|
|
|
base.OnAttachedToVisualTree(e); |
|
|
|
|
|
|
|
_viewModel.NotificationManager = new Avalonia.Controls.Notifications.WindowNotificationManager(VisualRoot as TopLevel); |
|
|
|
_viewModel.NotificationManager = new Avalonia.Controls.Notifications.WindowNotificationManager(TopLevel.GetTopLevel(this)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -189,7 +189,14 @@ namespace Avalonia.Input.GestureRecognizers |
|
|
|
|
|
|
|
var speed = _inertia * Math.Pow(0.15, st.Elapsed.TotalSeconds); |
|
|
|
var distance = speed * elapsedSinceLastTick.TotalSeconds; |
|
|
|
_target!.RaiseEvent(new ScrollGestureEventArgs(_gestureId, distance)); |
|
|
|
var scrollGestureEventArgs = new ScrollGestureEventArgs(_gestureId, distance); |
|
|
|
_target!.RaiseEvent(scrollGestureEventArgs); |
|
|
|
|
|
|
|
if (!scrollGestureEventArgs.Handled || scrollGestureEventArgs.ShouldEndScrollGesture) |
|
|
|
{ |
|
|
|
EndGesture(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// EndGesture using InertialScrollSpeedEnd only in the direction of scrolling
|
|
|
|
if (CanVerticallyScroll && CanHorizontallyScroll && Math.Abs(speed.X) < InertialScrollSpeedEnd && Math.Abs(speed.Y) <= InertialScrollSpeedEnd) |
|
|
|
|
|
|
|
@ -6,6 +6,10 @@ namespace Avalonia.Input |
|
|
|
{ |
|
|
|
public int Id { get; } |
|
|
|
public Vector Delta { get; } |
|
|
|
/// <summary>
|
|
|
|
/// When set the ScrollGestureRecognizer should stop its current active scroll gesture.
|
|
|
|
/// </summary>
|
|
|
|
public bool ShouldEndScrollGesture { get; set; } |
|
|
|
private static int _nextId = 1; |
|
|
|
|
|
|
|
public static int GetNextFreeId() => _nextId++; |
|
|
|
|
|
|
|
@ -383,7 +383,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
_subscriptionsOnOpen.Clear(); |
|
|
|
|
|
|
|
var toplevel = this.GetVisualRoot() as TopLevel; |
|
|
|
var toplevel = TopLevel.GetTopLevel(this); |
|
|
|
if (toplevel != null) |
|
|
|
{ |
|
|
|
toplevel.AddDisposableHandler(PointerWheelChangedEvent, (s, ev) => |
|
|
|
|
|
|
|
@ -428,6 +428,8 @@ namespace Avalonia.Controls.Presenters |
|
|
|
Offset = newOffset; |
|
|
|
|
|
|
|
e.Handled = !IsScrollChainingEnabled || offsetChanged; |
|
|
|
|
|
|
|
e.ShouldEndScrollGesture = !IsScrollChainingEnabled && !offsetChanged; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -123,7 +123,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
public static IPopupHost CreatePopupHost(Visual target, IAvaloniaDependencyResolver? dependencyResolver) |
|
|
|
{ |
|
|
|
var platform = (target.GetVisualRoot() as TopLevel)?.PlatformImpl?.CreatePopup(); |
|
|
|
var platform = TopLevel.GetTopLevel(target)?.PlatformImpl?.CreatePopup(); |
|
|
|
if (platform != null) |
|
|
|
return new PopupRoot((TopLevel)target.GetVisualRoot()!, platform, dependencyResolver); |
|
|
|
|
|
|
|
|
|
|
|
@ -358,7 +358,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var topLevel = placementTarget.VisualRoot as TopLevel; |
|
|
|
var topLevel = TopLevel.GetTopLevel(placementTarget); |
|
|
|
|
|
|
|
if (topLevel == null) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -341,6 +341,16 @@ namespace Avalonia.Controls |
|
|
|
{ |
|
|
|
return PlatformImpl?.PointToScreen(p) ?? default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the <see cref="TopLevel" /> for which the given <see cref="Visual"/> is hosted in.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="visual">The visual to query its TopLevel</param>
|
|
|
|
/// <returns>The TopLevel</returns>
|
|
|
|
public static TopLevel? GetTopLevel(Visual? visual) |
|
|
|
{ |
|
|
|
return visual == null ? null : visual.VisualRoot as TopLevel; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates the layout manager for this <see cref="TopLevel" />.
|
|
|
|
|
|
|
|
@ -6,7 +6,6 @@ using Avalonia.Input; |
|
|
|
using Avalonia.Input.Platform; |
|
|
|
using Avalonia.Interactivity; |
|
|
|
using Avalonia.Native.Interop; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
|
|
|
|
namespace Avalonia.Native |
|
|
|
{ |
|
|
|
@ -26,7 +25,7 @@ namespace Avalonia.Native |
|
|
|
if (element == null) |
|
|
|
return null; |
|
|
|
var visual = (Visual)element; |
|
|
|
return visual.GetVisualRoot() as TopLevel; |
|
|
|
return TopLevel.GetTopLevel(visual); |
|
|
|
} |
|
|
|
|
|
|
|
class DndCallback : NativeCallbackBase, IAvnDndResultCallback |
|
|
|
|
|
|
|
@ -1,7 +1,6 @@ |
|
|
|
using System; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Input; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
using Avalonia.Win32.Interop; |
|
|
|
|
|
|
|
namespace Avalonia.Win32.Input |
|
|
|
@ -34,7 +33,7 @@ namespace Avalonia.Win32.Input |
|
|
|
|
|
|
|
protected override void PlatformCapture(IInputElement element) |
|
|
|
{ |
|
|
|
var hwnd = (((element as Visual)?.GetVisualRoot() as TopLevel)?.PlatformImpl as WindowImpl) |
|
|
|
var hwnd = (TopLevel.GetTopLevel(element as Visual)?.PlatformImpl as WindowImpl) |
|
|
|
?.Handle.Handle; |
|
|
|
|
|
|
|
if (hwnd.HasValue && hwnd != IntPtr.Zero) |
|
|
|
|