Browse Source

Merge branch 'master' into fixes/scrollcontent-presenter-order-of-operations

pull/6093/head
Jumar Macato 5 years ago
committed by GitHub
parent
commit
728d8050c8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/Avalonia.Animation/AnimationInstance`1.cs
  2. 32
      src/Avalonia.Controls/Flyouts/FlyoutBase.cs
  3. 22
      src/Avalonia.Controls/Primitives/AdornerLayer.cs

8
src/Avalonia.Animation/AnimationInstance`1.cs

@ -37,6 +37,7 @@ namespace Avalonia.Animation
private IDisposable _timerSub; private IDisposable _timerSub;
private readonly IClock _baseClock; private readonly IClock _baseClock;
private IClock _clock; private IClock _clock;
private EventHandler<AvaloniaPropertyChangedEventArgs> _propertyChangedDelegate;
public AnimationInstance(Animation animation, Animatable control, Animator<T> animator, IClock baseClock, Action OnComplete, Func<double, T, T> Interpolator) public AnimationInstance(Animation animation, Animatable control, Animator<T> animator, IClock baseClock, Action OnComplete, Func<double, T, T> Interpolator)
{ {
@ -46,9 +47,6 @@ namespace Avalonia.Animation
_onCompleteAction = OnComplete; _onCompleteAction = OnComplete;
_interpolator = Interpolator; _interpolator = Interpolator;
_baseClock = baseClock; _baseClock = baseClock;
control.PropertyChanged += ControlPropertyChanged;
UpdateNeutralValue();
FetchProperties(); FetchProperties();
} }
@ -82,6 +80,7 @@ namespace Avalonia.Animation
// Animation may have been stopped before it has finished. // Animation may have been stopped before it has finished.
ApplyFinalFill(); ApplyFinalFill();
_targetControl.PropertyChanged -= _propertyChangedDelegate;
_timerSub?.Dispose(); _timerSub?.Dispose();
_clock.PlayState = PlayState.Stop; _clock.PlayState = PlayState.Stop;
} }
@ -90,6 +89,9 @@ namespace Avalonia.Animation
{ {
_clock = new Clock(_baseClock); _clock = new Clock(_baseClock);
_timerSub = _clock.Subscribe(Step); _timerSub = _clock.Subscribe(Step);
_propertyChangedDelegate ??= ControlPropertyChanged;
_targetControl.PropertyChanged += _propertyChangedDelegate;
UpdateNeutralValue();
} }
public void Step(TimeSpan frameTick) public void Step(TimeSpan frameTick)

32
src/Avalonia.Controls/Flyouts/FlyoutBase.cs

@ -4,6 +4,7 @@ using Avalonia.Input;
using Avalonia.Input.Raw; using Avalonia.Input.Raw;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.Logging; using Avalonia.Logging;
using Avalonia.Rendering;
#nullable enable #nullable enable
@ -51,8 +52,9 @@ namespace Avalonia.Controls.Primitives
private bool _isOpen; private bool _isOpen;
private Control? _target; private Control? _target;
private FlyoutShowMode _showMode = FlyoutShowMode.Standard; private FlyoutShowMode _showMode = FlyoutShowMode.Standard;
private Rect? enlargedPopupRect; private Rect? _enlargedPopupRect;
private IDisposable? transientDisposable; private PixelRect? _enlargePopupRectScreenPixelRect;
private IDisposable? _transientDisposable;
protected Popup? Popup { get; private set; } protected Popup? Popup { get; private set; }
@ -163,8 +165,10 @@ namespace Avalonia.Controls.Primitives
Popup.IsOpen = false; Popup.IsOpen = false;
// Ensure this isn't active // Ensure this isn't active
transientDisposable?.Dispose(); _transientDisposable?.Dispose();
transientDisposable = null; _transientDisposable = null;
_enlargedPopupRect = null;
_enlargePopupRectScreenPixelRect = null;
OnClosed(); OnClosed();
} }
@ -230,7 +234,7 @@ namespace Avalonia.Controls.Primitives
} }
else if (ShowMode == FlyoutShowMode.TransientWithDismissOnPointerMoveAway) else if (ShowMode == FlyoutShowMode.TransientWithDismissOnPointerMoveAway)
{ {
transientDisposable = InputManager.Instance?.Process.Subscribe(HandleTransientDismiss); _transientDisposable = InputManager.Instance?.Process.Subscribe(HandleTransientDismiss);
} }
} }
@ -246,20 +250,20 @@ namespace Avalonia.Controls.Primitives
// For windowed popups, enlargedPopupRect is in screen coordinates, // For windowed popups, enlargedPopupRect is in screen coordinates,
// for overlay popups, its in OverlayLayer coordinates // for overlay popups, its in OverlayLayer coordinates
if (enlargedPopupRect == null) if (_enlargedPopupRect == null && _enlargePopupRectScreenPixelRect == null)
{ {
// Only do this once when the Flyout opens & cache the result // Only do this once when the Flyout opens & cache the result
if (Popup?.Host is PopupRoot root) if (Popup?.Host is PopupRoot root)
{ {
// Get the popup root bounds and convert to screen coordinates // Get the popup root bounds and convert to screen coordinates
var tmp = root.Bounds.Inflate(100); var tmp = root.Bounds.Inflate(100);
var scPt = root.PointToScreen(tmp.TopLeft); _enlargePopupRectScreenPixelRect = new PixelRect(root.PointToScreen(tmp.TopLeft), root.PointToScreen(tmp.BottomRight));
enlargedPopupRect = new Rect(scPt.X, scPt.Y, tmp.Width, tmp.Height);
} }
else if (Popup?.Host is OverlayPopupHost host) else if (Popup?.Host is OverlayPopupHost host)
{ {
// Overlay popups are in OverlayLayer coordinates, just use that // Overlay popups are in OverlayLayer coordinates, just use that
enlargedPopupRect = host.Bounds.Inflate(100); _enlargedPopupRect = host.Bounds.Inflate(100);
} }
return; return;
@ -273,24 +277,18 @@ namespace Avalonia.Controls.Primitives
// window will not close this (as pointer events stop), which // window will not close this (as pointer events stop), which
// does match UWP // does match UWP
var pt = pArgs.Root.PointToScreen(pArgs.Position); var pt = pArgs.Root.PointToScreen(pArgs.Position);
if (!enlargedPopupRect?.Contains(new Point(pt.X, pt.Y)) ?? false) if (!_enlargePopupRectScreenPixelRect?.Contains(pt) ?? false)
{ {
HideCore(false); HideCore(false);
enlargedPopupRect = null;
transientDisposable?.Dispose();
transientDisposable = null;
} }
} }
else if (Popup?.Host is OverlayPopupHost) else if (Popup?.Host is OverlayPopupHost)
{ {
// Same as above here, but just different coordinate space // Same as above here, but just different coordinate space
// so we don't need to translate // so we don't need to translate
if (!enlargedPopupRect?.Contains(pArgs.Position) ?? false) if (!_enlargedPopupRect?.Contains(pArgs.Position) ?? false)
{ {
HideCore(false); HideCore(false);
enlargedPopupRect = null;
transientDisposable?.Dispose();
transientDisposable = null;
} }
} }
} }

22
src/Avalonia.Controls/Primitives/AdornerLayer.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using System.Resources;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Rendering; using Avalonia.Rendering;
using Avalonia.Utilities; using Avalonia.Utilities;
@ -45,10 +46,27 @@ namespace Avalonia.Controls.Primitives
?.AdornerLayer; ?.AdornerLayer;
} }
protected override Size ArrangeOverride(Size finalSize) protected override Size MeasureOverride(Size availableSize)
{ {
var parent = Parent; foreach (var child in Children)
{
var info = child.GetValue(s_adornedElementInfoProperty);
if (info != null && info.Bounds.HasValue)
{
child.Measure(info.Bounds.Value.Bounds.Size);
}
else
{
child.Measure(availableSize);
}
}
return default;
}
protected override Size ArrangeOverride(Size finalSize)
{
foreach (var child in Children) foreach (var child in Children)
{ {
var info = child.GetValue(s_adornedElementInfoProperty); var info = child.GetValue(s_adornedElementInfoProperty);

Loading…
Cancel
Save