|
|
@ -129,70 +129,58 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
|
if (_root != null) |
|
|
if (_root != null) |
|
|
{ |
|
|
{ |
|
|
_content = Content as Control; |
|
|
OnOrientationChanged(); |
|
|
|
|
|
|
|
|
if (_content == null) |
|
|
if (_root != null && _content != null) |
|
|
{ |
|
|
{ |
|
|
_content = new PathIcon() |
|
|
_root.Children.Insert(0, _content); |
|
|
{ |
|
|
_content.VerticalAlignment = Layout.VerticalAlignment.Center; |
|
|
Height = DefaultIndicatorSize, |
|
|
_content.HorizontalAlignment = Layout.HorizontalAlignment.Center; |
|
|
Width = DefaultIndicatorSize, |
|
|
|
|
|
Name = "PART_Icon" |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
_content.Loaded += (s, e) => |
|
|
UpdateContent(); |
|
|
{ |
|
|
} |
|
|
var composition = ElementComposition.GetElementVisual(_content); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(composition == null) |
|
|
private void OnContentLoaded(object? s, RoutedEventArgs e) |
|
|
return; |
|
|
{ |
|
|
|
|
|
if (_content == null) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var composition = ElementComposition.GetElementVisual(_content); |
|
|
|
|
|
|
|
|
var compositor = composition.Compositor; |
|
|
if (composition == null) return; |
|
|
composition.Opacity = 0; |
|
|
|
|
|
|
|
|
|
|
|
var smoothRotationAnimation |
|
|
var compositor = composition.Compositor; |
|
|
= compositor.CreateScalarKeyFrameAnimation(); |
|
|
composition.Opacity = 0; |
|
|
smoothRotationAnimation.Target = "RotationAngle"; |
|
|
|
|
|
smoothRotationAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
|
|
|
smoothRotationAnimation.Duration = TimeSpan.FromMilliseconds(100); |
|
|
|
|
|
|
|
|
|
|
|
var opacityAnimation |
|
|
var smoothRotationAnimation = compositor.CreateScalarKeyFrameAnimation(); |
|
|
= compositor.CreateScalarKeyFrameAnimation(); |
|
|
smoothRotationAnimation.Target = "RotationAngle"; |
|
|
opacityAnimation.Target = "Opacity"; |
|
|
smoothRotationAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
opacityAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
smoothRotationAnimation.Duration = TimeSpan.FromMilliseconds(100); |
|
|
opacityAnimation.Duration = TimeSpan.FromMilliseconds(100); |
|
|
|
|
|
|
|
|
|
|
|
var offsetAnimation = compositor.CreateVector3KeyFrameAnimation(); |
|
|
var opacityAnimation = compositor.CreateScalarKeyFrameAnimation(); |
|
|
offsetAnimation.Target = "Offset"; |
|
|
opacityAnimation.Target = "Opacity"; |
|
|
offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
opacityAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
offsetAnimation.Duration = TimeSpan.FromMilliseconds(150); |
|
|
opacityAnimation.Duration = TimeSpan.FromMilliseconds(100); |
|
|
|
|
|
|
|
|
var scaleAnimation |
|
|
var offsetAnimation = compositor.CreateVector3KeyFrameAnimation(); |
|
|
= compositor.CreateVector3KeyFrameAnimation(); |
|
|
offsetAnimation.Target = "Offset"; |
|
|
scaleAnimation.Target = "Scale"; |
|
|
offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
scaleAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
offsetAnimation.Duration = TimeSpan.FromMilliseconds(150); |
|
|
scaleAnimation.Duration = TimeSpan.FromMilliseconds(100); |
|
|
|
|
|
|
|
|
|
|
|
var animation = compositor.CreateImplicitAnimationCollection(); |
|
|
var scaleAnimation = compositor.CreateVector3KeyFrameAnimation(); |
|
|
animation["RotationAngle"] = smoothRotationAnimation; |
|
|
scaleAnimation.Target = "Scale"; |
|
|
animation["Offset"] = offsetAnimation; |
|
|
scaleAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", new LinearEasing()); |
|
|
animation["Scale"] = scaleAnimation; |
|
|
scaleAnimation.Duration = TimeSpan.FromMilliseconds(100); |
|
|
animation["Opacity"] = opacityAnimation; |
|
|
|
|
|
|
|
|
|
|
|
composition.ImplicitAnimations = animation; |
|
|
var animation = compositor.CreateImplicitAnimationCollection(); |
|
|
|
|
|
animation["RotationAngle"] = smoothRotationAnimation; |
|
|
|
|
|
animation["Offset"] = offsetAnimation; |
|
|
|
|
|
animation["Scale"] = scaleAnimation; |
|
|
|
|
|
animation["Opacity"] = opacityAnimation; |
|
|
|
|
|
|
|
|
UpdateContent(); |
|
|
composition.ImplicitAnimations = animation; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
SetCurrentValue(ContentProperty, _content); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
RaisePropertyChanged(ContentProperty, null, Content, Data.BindingPriority.Style, false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OnOrientationChanged(); |
|
|
|
|
|
|
|
|
|
|
|
UpdateContent(); |
|
|
UpdateContent(); |
|
|
} |
|
|
} |
|
|
@ -229,6 +217,7 @@ namespace Avalonia.Controls |
|
|
visualizerVisual.Offset = IsPullDirectionVertical ? |
|
|
visualizerVisual.Offset = IsPullDirectionVertical ? |
|
|
new Vector3D(visualizerVisual.Offset.X, 0, 0) : |
|
|
new Vector3D(visualizerVisual.Offset.X, 0, 0) : |
|
|
new Vector3D(0, visualizerVisual.Offset.Y, 0); |
|
|
new Vector3D(0, visualizerVisual.Offset.Y, 0); |
|
|
|
|
|
visual.Offset = visualizerVisual.Offset; |
|
|
_content.InvalidateMeasure(); |
|
|
_content.InvalidateMeasure(); |
|
|
break; |
|
|
break; |
|
|
case RefreshVisualizerState.Interacting: |
|
|
case RefreshVisualizerState.Interacting: |
|
|
@ -353,14 +342,27 @@ namespace Avalonia.Controls |
|
|
} |
|
|
} |
|
|
else if (change.Property == ContentProperty) |
|
|
else if (change.Property == ContentProperty) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (change.OldValue is Control c) |
|
|
|
|
|
{ |
|
|
|
|
|
c.Loaded -= OnContentLoaded; |
|
|
|
|
|
_root?.Children.Remove(c); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_content = change.NewValue as Control; |
|
|
|
|
|
|
|
|
|
|
|
if (_content != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_content.Loaded += OnContentLoaded; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (_root != null && _content != null) |
|
|
if (_root != null && _content != null) |
|
|
{ |
|
|
{ |
|
|
_root.Children.Insert(0, _content); |
|
|
_root.Children.Insert(0, _content); |
|
|
_content.VerticalAlignment = Layout.VerticalAlignment.Center; |
|
|
_content.VerticalAlignment = Layout.VerticalAlignment.Center; |
|
|
_content.HorizontalAlignment = Layout.HorizontalAlignment.Center; |
|
|
_content.HorizontalAlignment = Layout.HorizontalAlignment.Center; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UpdateContent(); |
|
|
UpdateContent(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else if (change.Property == OrientationProperty) |
|
|
else if (change.Property == OrientationProperty) |
|
|
{ |
|
|
{ |
|
|
|