Skip to content

Commit

Permalink
feat(dragdrop): Fix WASM compilation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Oct 16, 2020
1 parent e853cf7 commit 4c5a78e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 54 deletions.
42 changes: 1 addition & 41 deletions src/Uno.UI/UI/Xaml/DragRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Shapes/Shape.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 12 additions & 12 deletions src/Uno.UI/UI/Xaml/UIElement.Pointers.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down

0 comments on commit 4c5a78e

Please sign in to comment.