Browse Source

Use inner methods for invalidation.

pull/1869/head
Steven Kirk 8 years ago
parent
commit
f39e38545d
  1. 36
      src/Avalonia.Layout/Layoutable.cs
  2. 17
      src/Avalonia.Visuals/Visual.cs

36
src/Avalonia.Layout/Layoutable.cs

@ -445,9 +445,14 @@ namespace Avalonia.Layout
protected static void AffectsMeasure<T>(params AvaloniaProperty[] properties)
where T : class, ILayoutable
{
void Invalidate(AvaloniaPropertyChangedEventArgs e)
{
(e.Sender as T)?.InvalidateMeasure();
}
foreach (var property in properties)
{
property.Changed.Subscribe(AffectsMeasureInvalidate<T>);
property.Changed.Subscribe(Invalidate);
}
}
@ -477,9 +482,14 @@ namespace Avalonia.Layout
protected static void AffectsArrange<T>(params AvaloniaProperty[] properties)
where T : class, ILayoutable
{
void Invalidate(AvaloniaPropertyChangedEventArgs e)
{
(e.Sender as T)?.InvalidateArrange();
}
foreach (var property in properties)
{
property.Changed.Subscribe(AffectsArrangeInvalidate<T>);
property.Changed.Subscribe(Invalidate);
}
}
@ -664,28 +674,6 @@ namespace Avalonia.Layout
base.OnVisualParentChanged(oldParent, newParent);
}
/// <summary>
/// Calls <see cref="InvalidateMeasure"/> on the control on which a property changed.
/// </summary>
/// <param name="e">The event args.</param>
private static void AffectsMeasureInvalidate<T>(AvaloniaPropertyChangedEventArgs e)
where T : class, ILayoutable
{
var control = e.Sender as T;
control?.InvalidateMeasure();
}
/// <summary>
/// Calls <see cref="InvalidateArrange"/> on the control on which a property changed.
/// </summary>
/// <param name="e">The event args.</param>
private static void AffectsArrangeInvalidate<T>(AvaloniaPropertyChangedEventArgs e)
where T : class, ILayoutable
{
var control = e.Sender as T;
control?.InvalidateArrange();
}
/// <summary>
/// Tests whether any of a <see cref="Rect"/>'s properties include negative values,
/// a NaN or Infinity.

17
src/Avalonia.Visuals/Visual.cs

@ -340,9 +340,14 @@ namespace Avalonia
protected static void AffectsRender<T>(params AvaloniaProperty[] properties)
where T : class, IVisual
{
void Invalidate(AvaloniaPropertyChangedEventArgs e)
{
(e.Sender as T)?.InvalidateVisual();
}
foreach (var property in properties)
{
property.Changed.Subscribe(AffectsRenderInvalidate<T>);
property.Changed.Subscribe(Invalidate);
}
}
@ -430,16 +435,6 @@ namespace Avalonia
RaisePropertyChanged(VisualParentProperty, oldParent, newParent, BindingPriority.LocalValue);
}
/// <summary>
/// Called when a property changes that should invalidate the visual.
/// </summary>
/// <param name="e">The event args.</param>
private static void AffectsRenderInvalidate<T>(AvaloniaPropertyChangedEventArgs e)
where T : class, IVisual
{
(e.Sender as T)?.InvalidateVisual();
}
/// <summary>
/// Gets the visual offset from the specified ancestor.
/// </summary>

Loading…
Cancel
Save