Browse Source

Requested Changes

pull/6564/head
Sergey Mikolaytis 5 years ago
parent
commit
90c846007a
  1. 12
      src/Avalonia.Input/Gestures.cs
  2. 48
      src/Avalonia.Input/InputElement.cs
  3. 18
      src/Avalonia.Input/MouseDevice.cs
  4. 19
      src/Avalonia.Input/PointerDeltaEventArgs.cs
  5. 19
      src/Avalonia.Input/PointerTouchPadGestureMagnifyEventArgs.cs
  6. 19
      src/Avalonia.Input/PointerTouchPadGestureRotateEventArgs.cs
  7. 19
      src/Avalonia.Input/PointerTouchPadGestureSwipeEventArgs.cs

12
src/Avalonia.Input/Gestures.cs

@ -30,16 +30,16 @@ namespace Avalonia.Input
RoutedEvent.Register<ScrollGestureEventArgs>(
"ScrollGestureEnded", RoutingStrategies.Bubble, typeof(Gestures));
public static readonly RoutedEvent<PointerTouchPadGestureMagnifyEventArgs> PointerTouchPadGestureMagnifyEvent =
RoutedEvent.Register<PointerTouchPadGestureMagnifyEventArgs>(
public static readonly RoutedEvent<PointerDeltaEventArgs> PointerTouchPadGestureMagnifyEvent =
RoutedEvent.Register<PointerDeltaEventArgs>(
"PointerMagnifyGesture", RoutingStrategies.Bubble, typeof(Gestures));
public static readonly RoutedEvent<PointerTouchPadGestureRotateEventArgs> PointerTouchPadGestureRotateEvent =
RoutedEvent.Register<PointerTouchPadGestureRotateEventArgs>(
public static readonly RoutedEvent<PointerDeltaEventArgs> PointerTouchPadGestureRotateEvent =
RoutedEvent.Register<PointerDeltaEventArgs>(
"PointerRotateGesture", RoutingStrategies.Bubble, typeof(Gestures));
public static readonly RoutedEvent<PointerTouchPadGestureSwipeEventArgs> PointerTouchPadGestureSwipeEvent =
RoutedEvent.Register<PointerTouchPadGestureSwipeEventArgs>(
public static readonly RoutedEvent<PointerDeltaEventArgs> PointerTouchPadGestureSwipeEvent =
RoutedEvent.Register<PointerDeltaEventArgs>(
"PointerSwipeGesture", RoutingStrategies.Bubble, typeof(Gestures));
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.

48
src/Avalonia.Input/InputElement.cs

@ -197,24 +197,6 @@ namespace Avalonia.Input
/// </summary>
public static readonly RoutedEvent<TappedEventArgs> DoubleTappedEvent = Gestures.DoubleTappedEvent;
/// <summary>
/// Defines the <see cref="PointerTouchPadGestureMagnify"/> event.
/// </summary>
public static readonly RoutedEvent<PointerTouchPadGestureMagnifyEventArgs> PointerTouchPadGestureMagnifyEvent
= Gestures.PointerTouchPadGestureMagnifyEvent;
/// <summary>
/// Defines the <see cref="PointerTouchPadGestureRotate"/> event.
/// </summary>
public static readonly RoutedEvent<PointerTouchPadGestureRotateEventArgs> PointerTouchPadGestureRotateEvent
= Gestures.PointerTouchPadGestureRotateEvent;
/// <summary>
/// Defines the <see cref="PointerTouchPadGestureSwipe"/> event.
/// </summary>
public static readonly RoutedEvent<PointerTouchPadGestureSwipeEventArgs> PointerTouchPadGestureSwipeEvent
= Gestures.PointerTouchPadGestureSwipeEvent;
private bool _isEffectivelyEnabled = true;
private bool _isFocused;
private bool _isKeyboardFocusWithin;
@ -375,36 +357,6 @@ namespace Avalonia.Input
remove { RemoveHandler(PointerWheelChangedEvent, value); }
}
/// <summary>
/// Occurs when the user uses magnify (Pitch to Zoom) gesture on a trackpad and pointer is over the control.
/// Works only on macOS.
/// </summary>
public event EventHandler<PointerTouchPadGestureMagnifyEventArgs> PointerTouchPadGestureMagnify
{
add { AddHandler(PointerTouchPadGestureMagnifyEvent, value); }
remove { RemoveHandler(PointerTouchPadGestureMagnifyEvent, value); }
}
/// <summary>
/// Occurs when the user uses rotate gesture on a trackpad and pointer is over the control.
/// Works only on macOS.
/// </summary>
public event EventHandler<PointerTouchPadGestureRotateEventArgs> PointerTouchPadGestureRotate
{
add { AddHandler(PointerTouchPadGestureRotateEvent, value); }
remove { RemoveHandler(PointerTouchPadGestureRotateEvent, value); }
}
/// <summary>
/// Occurs when the user uses swipe gesture on a trackpad and pointer is over the control.
/// Works only on macOS.
/// </summary>
public event EventHandler<PointerTouchPadGestureSwipeEventArgs> PointerTouchPadGestureSwipe
{
add { AddHandler(PointerTouchPadGestureSwipeEvent, value); }
remove { RemoveHandler(PointerTouchPadGestureSwipeEvent, value); }
}
/// <summary>
/// Occurs when a tap gesture occurs on the control.
/// </summary>

18
src/Avalonia.Input/MouseDevice.cs

@ -345,8 +345,7 @@ namespace Avalonia.Input
}
private bool GestureMagnify(IMouseDevice device, ulong timestamp, IInputRoot root, Point p,
PointerPointProperties props,
Vector delta, KeyModifiers inputModifiers)
PointerPointProperties props, Vector delta, KeyModifiers inputModifiers)
{
device = device ?? throw new ArgumentNullException(nameof(device));
root = root ?? throw new ArgumentNullException(nameof(root));
@ -356,7 +355,8 @@ namespace Avalonia.Input
if (hit != null)
{
var source = GetSource(hit);
var e = new PointerTouchPadGestureMagnifyEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta.X);
var e = new PointerDeltaEventArgs(Gestures.PointerTouchPadGestureMagnifyEvent, source,
_pointer, root, p, timestamp, props, inputModifiers, delta);
source?.RaiseEvent(e);
return e.Handled;
@ -366,8 +366,7 @@ namespace Avalonia.Input
}
private bool GestureRotate(IMouseDevice device, ulong timestamp, IInputRoot root, Point p,
PointerPointProperties props,
Vector delta, KeyModifiers inputModifiers)
PointerPointProperties props, Vector delta, KeyModifiers inputModifiers)
{
device = device ?? throw new ArgumentNullException(nameof(device));
root = root ?? throw new ArgumentNullException(nameof(root));
@ -377,7 +376,8 @@ namespace Avalonia.Input
if (hit != null)
{
var source = GetSource(hit);
var e = new PointerTouchPadGestureRotateEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta.X);
var e = new PointerDeltaEventArgs(Gestures.PointerTouchPadGestureRotateEvent, source,
_pointer, root, p, timestamp, props, inputModifiers, delta);
source?.RaiseEvent(e);
return e.Handled;
@ -387,8 +387,7 @@ namespace Avalonia.Input
}
private bool GestureSwipe(IMouseDevice device, ulong timestamp, IInputRoot root, Point p,
PointerPointProperties props,
Vector delta, KeyModifiers inputModifiers)
PointerPointProperties props, Vector delta, KeyModifiers inputModifiers)
{
device = device ?? throw new ArgumentNullException(nameof(device));
root = root ?? throw new ArgumentNullException(nameof(root));
@ -398,7 +397,8 @@ namespace Avalonia.Input
if (hit != null)
{
var source = GetSource(hit);
var e = new PointerTouchPadGestureSwipeEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta);
var e = new PointerDeltaEventArgs(Gestures.PointerTouchPadGestureSwipeEvent, source,
_pointer, root, p, timestamp, props, inputModifiers, delta);
source?.RaiseEvent(e);
return e.Handled;

19
src/Avalonia.Input/PointerDeltaEventArgs.cs

@ -0,0 +1,19 @@
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace Avalonia.Input
{
public class PointerDeltaEventArgs : PointerEventArgs
{
public Vector Delta { get; set; }
public PointerDeltaEventArgs(RoutedEvent routedEvent, IInteractive? source,
IPointer pointer, IVisual rootVisual, Point rootVisualPosition, ulong timestamp,
PointerPointProperties properties, KeyModifiers modifiers, Vector delta)
: base(routedEvent, source, pointer, rootVisual, rootVisualPosition,
timestamp, properties, modifiers)
{
Delta = delta;
}
}
}

19
src/Avalonia.Input/PointerTouchPadGestureMagnifyEventArgs.cs

@ -1,19 +0,0 @@
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace Avalonia.Input
{
public class PointerTouchPadGestureMagnifyEventArgs : PointerEventArgs
{
public double Delta { get; set; }
public PointerTouchPadGestureMagnifyEventArgs(IInteractive source, IPointer pointer, IVisual rootVisual,
Point rootVisualPosition, ulong timestamp,
PointerPointProperties properties, KeyModifiers modifiers, double delta)
: base(InputElement.PointerTouchPadGestureMagnifyEvent, source, pointer, rootVisual, rootVisualPosition,
timestamp, properties, modifiers)
{
Delta = delta;
}
}
}

19
src/Avalonia.Input/PointerTouchPadGestureRotateEventArgs.cs

@ -1,19 +0,0 @@
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace Avalonia.Input
{
public class PointerTouchPadGestureRotateEventArgs : PointerEventArgs
{
public double Delta { get; set; }
public PointerTouchPadGestureRotateEventArgs(IInteractive source, IPointer pointer, IVisual rootVisual,
Point rootVisualPosition, ulong timestamp,
PointerPointProperties properties, KeyModifiers modifiers, double delta)
: base(InputElement.PointerTouchPadGestureRotateEvent, source, pointer, rootVisual, rootVisualPosition,
timestamp, properties, modifiers)
{
Delta = delta;
}
}
}

19
src/Avalonia.Input/PointerTouchPadGestureSwipeEventArgs.cs

@ -1,19 +0,0 @@
using Avalonia.Interactivity;
using Avalonia.VisualTree;
namespace Avalonia.Input
{
public class PointerTouchPadGestureSwipeEventArgs : PointerEventArgs
{
public Vector Delta { get; set; }
public PointerTouchPadGestureSwipeEventArgs(IInteractive source, IPointer pointer, IVisual rootVisual,
Point rootVisualPosition, ulong timestamp,
PointerPointProperties properties, KeyModifiers modifiers, Vector delta)
: base(InputElement.PointerTouchPadGestureSwipeEvent, source, pointer, rootVisual, rootVisualPosition,
timestamp, properties, modifiers)
{
Delta = delta;
}
}
}
Loading…
Cancel
Save