From 4c5a78ef52ea637c22b1f738aeeb186f9101e100 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 1 Oct 2020 14:36:45 -0400 Subject: [PATCH] feat(dragdrop): Fix WASM compilation issues --- src/Uno.UI/UI/Xaml/DragRoot.cs | 42 +------------------ src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs | 2 +- src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs | 24 +++++------ 3 files changed, 14 insertions(+), 54 deletions(-) diff --git a/src/Uno.UI/UI/Xaml/DragRoot.cs b/src/Uno.UI/UI/Xaml/DragRoot.cs index 0319b96ab2c9..a98ef12cf8a3 100644 --- a/src/Uno.UI/UI/Xaml/DragRoot.cs +++ b/src/Uno.UI/UI/Xaml/DragRoot.cs @@ -10,21 +10,11 @@ namespace Windows.UI.Xaml { internal partial class DragRoot : Canvas { - private readonly DragDropManager _manager; - - public DragRoot(DragDropManager manager) + public DragRoot() { - _manager = manager; - VerticalAlignment = VerticalAlignment.Stretch; HorizontalAlignment = HorizontalAlignment.Stretch; Background = new SolidColorBrush(Colors.Transparent); - - //PointerEntered += OnPointerEntered; - //PointerExited += OnPointerExited; - //PointerMoved += OnPointerMoved; - //PointerReleased += OnPointerReleased; - //PointerCanceled += OnPointerCanceled; } public int PendingDragCount => Children.Count; @@ -39,35 +29,5 @@ public void Hide(DragView view) { Children.Remove(view); } - - private static void OnPointerEntered(object snd, PointerRoutedEventArgs e) - { - ((DragRoot)snd)._manager.ProcessPointerEnteredWindow(e); - e.Handled = true; - } - - private static void OnPointerExited(object snd, PointerRoutedEventArgs e) - { - ((DragRoot)snd)._manager.ProcessPointerExitedWindow(e); - e.Handled = true; - } - - private static void OnPointerMoved(object snd, PointerRoutedEventArgs e) - { - ((DragRoot)snd)._manager.ProcessPointerMovedOverWindow(e); - e.Handled = true; - } - - private static void OnPointerReleased(object snd, PointerRoutedEventArgs e) - { - ((DragRoot)snd)._manager.ProcessPointerReleased(e); - e.Handled = true; - } - - private static void OnPointerCanceled(object snd, PointerRoutedEventArgs e) - { - ((DragRoot)snd)._manager.ProcessPointerCanceled(e); - e.Handled = true; - } } } diff --git a/src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs b/src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs index b8627fe48d1a..d3c2a1ef7673 100644 --- a/src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs +++ b/src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs @@ -56,7 +56,7 @@ protected virtual void OnChildrenChanged() { } - private protected override void OnHitTestVisibilityChanged(HitTestVisibility oldValue, HitTestVisibility newValue) + private protected override void OnHitTestVisibilityChanged(HitTestability oldValue, HitTestability newValue) { // We don't invoke the base, so we stay at the default "pointer-events: none" defined in Uno.UI.css in class svg.uno-uielement. // This is required to avoid this SVG element (which is actually only a collection) to stoll pointer events. diff --git a/src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs b/src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs index b9c1b5138454..0034b196b009 100644 --- a/src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs +++ b/src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs @@ -272,10 +272,10 @@ internal void UpdateHitTest() private static DependencyProperty HitTestVisibilityProperty { get ; } = DependencyProperty.Register( "HitTestVisibility", - typeof(HitTestVisibility), + typeof(HitTestability), typeof(UIElement), new FrameworkPropertyMetadata( - HitTestVisibility.Visible, + HitTestability.Visible, FrameworkPropertyMetadataOptions.Inherits, coerceValueCallback: (s, e) => CoerceHitTestVisibility(s, e), propertyChangedCallback: (s, e) => OnHitTestVisibilityChanged(s, e) @@ -291,43 +291,43 @@ private static object CoerceHitTestVisibility(DependencyObject dependencyObject, var element = (UIElement)dependencyObject; // The HitTestVisibilityProperty is never set directly. This means that baseValue is always the result of the parent's CoerceHitTestVisibility. - var baseHitTestVisibility = (HitTestVisibility)baseValue; + var baseHitTestVisibility = (HitTestability)baseValue; // If the parent is collapsed, we should be collapsed as well. This takes priority over everything else, even if we would be visible otherwise. - if (baseHitTestVisibility == HitTestVisibility.Collapsed) + if (baseHitTestVisibility == HitTestability.Collapsed) { - return HitTestVisibility.Collapsed; + return HitTestability.Collapsed; } // If we're not locally hit-test visible, visible, or enabled, we should be collapsed. Our children will be collapsed as well. if (!element.IsLoaded || !element.IsHitTestVisible || element.Visibility != Visibility.Visible || !element.IsEnabledOverride()) { - return HitTestVisibility.Collapsed; + return HitTestability.Collapsed; } // If we're not hit (usually means we don't have a Background/Fill), we're invisible. Our children will be visible or not, depending on their state. if (!element.IsViewHit()) { - return HitTestVisibility.Invisible; + return HitTestability.Invisible; } // If we're not collapsed or invisible, we can be targeted by hit-testing. This means that we can be the source of pointer events. - return HitTestVisibility.Visible; + return HitTestability.Visible; } private static void OnHitTestVisibilityChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) { if (dependencyObject is UIElement element - && args.OldValue is HitTestVisibility oldValue - && args.NewValue is HitTestVisibility newValue) + && args.OldValue is HitTestability oldValue + && args.NewValue is HitTestability newValue) { element.OnHitTestVisibilityChanged(oldValue, newValue); } } - private protected virtual void OnHitTestVisibilityChanged(HitTestVisibility oldValue, HitTestVisibility newValue) + private protected virtual void OnHitTestVisibilityChanged(HitTestability oldValue, HitTestability newValue) { - if (newValue == HitTestVisibility.Visible) + if (newValue == HitTestability.Visible) { // By default, elements have 'pointer-event' set to 'auto' (see Uno.UI.css .uno-uielement class). // This means that they can be the target of hit-testing and will raise pointer events when interacted with.