Browse Source

Merge branch 'fixes/osx-shadow' of github.com:AvaloniaUI/Avalonia into fixes/osx-shadow

pull/5963/head
Dan Walmsley 5 years ago
parent
commit
a5af6c9470
  1. 39
      src/Avalonia.Base/AvaloniaObject.cs
  2. 4
      src/Avalonia.Base/Diagnostics/IAvaloniaObjectDebug.cs
  3. 9
      src/Avalonia.Base/IAvaloniaObject.cs
  4. 2
      src/Avalonia.Controls/Control.cs
  5. 4
      src/Avalonia.Controls/IControl.cs
  6. 2
      src/Avalonia.Input/IInputElement.cs
  7. 2
      src/Avalonia.Input/InputElement.cs
  8. 4
      src/Avalonia.Input/KeyboardDevice.cs
  9. 8
      src/Avalonia.Input/MouseDevice.cs
  10. 2
      src/Avalonia.Interactivity/IInteractive.cs
  11. 2
      src/Avalonia.Interactivity/Interactive.cs
  12. 2
      src/Avalonia.Layout/Layoutable.cs
  13. 6
      src/Avalonia.Styling/Controls/ISetInheritanceParent.cs
  14. 6
      src/Avalonia.Styling/Controls/ISetLogicalParent.cs
  15. 6
      src/Avalonia.Styling/IDataContextProvider.cs
  16. 6
      src/Avalonia.Styling/IStyledElement.cs
  17. 4
      src/Avalonia.Styling/StyledElement.cs
  18. 4
      src/Avalonia.Styling/Styling/ISetterValue.cs
  19. 4
      src/Avalonia.Styling/Styling/PropertySetterInstance.cs
  20. 4
      src/Avalonia.Styling/Styling/PropertySetterLazyInstance.cs
  21. 50
      src/Avalonia.Visuals/Visual.cs
  22. 16
      src/Avalonia.Visuals/VisualTree/IVisual.cs

39
src/Avalonia.Base/AvaloniaObject.cs

@ -7,6 +7,8 @@ using Avalonia.Logging;
using Avalonia.PropertyStore; using Avalonia.PropertyStore;
using Avalonia.Threading; using Avalonia.Threading;
#nullable enable
namespace Avalonia namespace Avalonia
{ {
/// <summary> /// <summary>
@ -17,12 +19,12 @@ namespace Avalonia
/// </remarks> /// </remarks>
public class AvaloniaObject : IAvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged, IValueSink public class AvaloniaObject : IAvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged, IValueSink
{ {
private IAvaloniaObject _inheritanceParent; private IAvaloniaObject? _inheritanceParent;
private List<IDisposable> _directBindings; private List<IDisposable>? _directBindings;
private PropertyChangedEventHandler _inpcChanged; private PropertyChangedEventHandler? _inpcChanged;
private EventHandler<AvaloniaPropertyChangedEventArgs> _propertyChanged; private EventHandler<AvaloniaPropertyChangedEventArgs>? _propertyChanged;
private List<IAvaloniaObject> _inheritanceChildren; private List<IAvaloniaObject>? _inheritanceChildren;
private ValueStore _values; private ValueStore? _values;
private bool _batchUpdate; private bool _batchUpdate;
/// <summary> /// <summary>
@ -36,7 +38,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Raised when a <see cref="AvaloniaProperty"/> value changes on this object. /// Raised when a <see cref="AvaloniaProperty"/> value changes on this object.
/// </summary> /// </summary>
public event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged public event EventHandler<AvaloniaPropertyChangedEventArgs>? PropertyChanged
{ {
add { _propertyChanged += value; } add { _propertyChanged += value; }
remove { _propertyChanged -= value; } remove { _propertyChanged -= value; }
@ -58,7 +60,7 @@ namespace Avalonia
/// <value> /// <value>
/// The inheritance parent. /// The inheritance parent.
/// </value> /// </value>
protected IAvaloniaObject InheritanceParent protected IAvaloniaObject? InheritanceParent
{ {
get get
{ {
@ -289,7 +291,8 @@ namespace Avalonia
/// <returns>True if the property is animating, otherwise false.</returns> /// <returns>True if the property is animating, otherwise false.</returns>
public bool IsAnimating(AvaloniaProperty property) public bool IsAnimating(AvaloniaProperty property)
{ {
Contract.Requires<ArgumentNullException>(property != null); property = property ?? throw new ArgumentNullException(nameof(property));
VerifyAccess(); VerifyAccess();
return _values?.IsAnimating(property) ?? false; return _values?.IsAnimating(property) ?? false;
@ -306,7 +309,8 @@ namespace Avalonia
/// </remarks> /// </remarks>
public bool IsSet(AvaloniaProperty property) public bool IsSet(AvaloniaProperty property)
{ {
Contract.Requires<ArgumentNullException>(property != null); property = property ?? throw new ArgumentNullException(nameof(property));
VerifyAccess(); VerifyAccess();
return _values?.IsSet(property) ?? false; return _values?.IsSet(property) ?? false;
@ -320,7 +324,7 @@ namespace Avalonia
/// <param name="priority">The priority of the value.</param> /// <param name="priority">The priority of the value.</param>
public void SetValue( public void SetValue(
AvaloniaProperty property, AvaloniaProperty property,
object value, object? value,
BindingPriority priority = BindingPriority.LocalValue) BindingPriority priority = BindingPriority.LocalValue)
{ {
property = property ?? throw new ArgumentNullException(nameof(property)); property = property ?? throw new ArgumentNullException(nameof(property));
@ -338,7 +342,7 @@ namespace Avalonia
/// <returns> /// <returns>
/// An <see cref="IDisposable"/> if setting the property can be undone, otherwise null. /// An <see cref="IDisposable"/> if setting the property can be undone, otherwise null.
/// </returns> /// </returns>
public IDisposable SetValue<T>( public IDisposable? SetValue<T>(
StyledPropertyBase<T> property, StyledPropertyBase<T> property,
T value, T value,
BindingPriority priority = BindingPriority.LocalValue) BindingPriority priority = BindingPriority.LocalValue)
@ -497,7 +501,7 @@ namespace Avalonia
} }
/// <inheritdoc/> /// <inheritdoc/>
Delegate[] IAvaloniaObjectDebug.GetPropertyChangedSubscribers() Delegate[]? IAvaloniaObjectDebug.GetPropertyChangedSubscribers()
{ {
return _propertyChanged?.GetInvocationList(); return _propertyChanged?.GetInvocationList();
} }
@ -723,7 +727,8 @@ namespace Avalonia
{ {
var values = o._values; var values = o._values;
if (values?.TryGetValue(property, maxPriority, out value) == true) if (values != null
&& values.TryGetValue(property, maxPriority, out value) == true)
{ {
return value; return value;
} }
@ -873,7 +878,7 @@ namespace Avalonia
} }
else else
{ {
LogBindingError(property, value.Error); LogBindingError(property, value.Error!);
} }
} }
} }
@ -907,14 +912,14 @@ namespace Avalonia
{ {
_owner = owner; _owner = owner;
_property = property; _property = property;
_owner._directBindings.Add(this); _owner._directBindings!.Add(this);
_subscription = source.Subscribe(this); _subscription = source.Subscribe(this);
} }
public void Dispose() public void Dispose()
{ {
_subscription.Dispose(); _subscription.Dispose();
_owner._directBindings.Remove(this); _owner._directBindings!.Remove(this);
} }
public void OnCompleted() => Dispose(); public void OnCompleted() => Dispose();

4
src/Avalonia.Base/Diagnostics/IAvaloniaObjectDebug.cs

@ -1,5 +1,7 @@
using System; using System;
#nullable enable
namespace Avalonia.Diagnostics namespace Avalonia.Diagnostics
{ {
/// <summary> /// <summary>
@ -14,6 +16,6 @@ namespace Avalonia.Diagnostics
/// <returns> /// <returns>
/// The subscribers or null if no subscribers. /// The subscribers or null if no subscribers.
/// </returns> /// </returns>
Delegate[] GetPropertyChangedSubscribers(); Delegate[]? GetPropertyChangedSubscribers();
} }
} }

9
src/Avalonia.Base/IAvaloniaObject.cs

@ -1,6 +1,8 @@
using System; using System;
using Avalonia.Data; using Avalonia.Data;
#nullable enable
namespace Avalonia namespace Avalonia
{ {
/// <summary> /// <summary>
@ -11,7 +13,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Raised when a <see cref="AvaloniaProperty"/> value changes on this object. /// Raised when a <see cref="AvaloniaProperty"/> value changes on this object.
/// </summary> /// </summary>
event EventHandler<AvaloniaPropertyChangedEventArgs> PropertyChanged; event EventHandler<AvaloniaPropertyChangedEventArgs>? PropertyChanged;
/// <summary> /// <summary>
/// Clears an <see cref="AvaloniaProperty"/>'s local value. /// Clears an <see cref="AvaloniaProperty"/>'s local value.
@ -75,7 +77,10 @@ namespace Avalonia
/// <param name="property">The property.</param> /// <param name="property">The property.</param>
/// <param name="value">The value.</param> /// <param name="value">The value.</param>
/// <param name="priority">The priority of the value.</param> /// <param name="priority">The priority of the value.</param>
IDisposable SetValue<T>( /// <returns>
/// An <see cref="IDisposable"/> if setting the property can be undone, otherwise null.
/// </returns>
IDisposable? SetValue<T>(
StyledPropertyBase<T> property, StyledPropertyBase<T> property,
T value, T value,
BindingPriority priority = BindingPriority.LocalValue); BindingPriority priority = BindingPriority.LocalValue);

2
src/Avalonia.Controls/Control.cs

@ -201,7 +201,7 @@ namespace Avalonia.Controls
{ {
base.OnLostFocus(e); base.OnLostFocus(e);
if (_focusAdorner != null) if (_focusAdorner?.Parent != null)
{ {
var adornerLayer = (IPanel)_focusAdorner.Parent; var adornerLayer = (IPanel)_focusAdorner.Parent;
adornerLayer.Children.Remove(_focusAdorner); adornerLayer.Children.Remove(_focusAdorner);

4
src/Avalonia.Controls/IControl.cs

@ -3,6 +3,8 @@ using Avalonia.Input;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.VisualTree; using Avalonia.VisualTree;
#nullable enable
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
@ -15,6 +17,6 @@ namespace Avalonia.Controls
INamed, INamed,
IStyledElement IStyledElement
{ {
new IControl Parent { get; } new IControl? Parent { get; }
} }
} }

2
src/Avalonia.Input/IInputElement.cs

@ -3,6 +3,8 @@ using System.Collections.Generic;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.VisualTree; using Avalonia.VisualTree;
#nullable enable
namespace Avalonia.Input namespace Avalonia.Input
{ {
/// <summary> /// <summary>

2
src/Avalonia.Input/InputElement.cs

@ -9,6 +9,8 @@ using Avalonia.Input.TextInput;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.VisualTree; using Avalonia.VisualTree;
#nullable enable
namespace Avalonia.Input namespace Avalonia.Input
{ {
/// <summary> /// <summary>

4
src/Avalonia.Input/KeyboardDevice.cs

@ -60,7 +60,7 @@ namespace Avalonia.Input
ie.IsKeyboardFocusWithin = false; ie.IsKeyboardFocusWithin = false;
} }
el = (IInputElement)el.VisualParent; el = (IInputElement?)el.VisualParent;
} }
} }
@ -212,7 +212,7 @@ namespace Avalonia.Input
Source = element, Source = element,
}; };
IVisual currentHandler = element; IVisual? currentHandler = element;
while (currentHandler != null && !ev.Handled && keyInput.Type == RawKeyEventType.KeyDown) while (currentHandler != null && !ev.Handled && keyInput.Type == RawKeyEventType.KeyDown)
{ {
var bindings = (currentHandler as IInputElement)?.KeyBindings; var bindings = (currentHandler as IInputElement)?.KeyBindings;

8
src/Avalonia.Input/MouseDevice.cs

@ -377,7 +377,7 @@ namespace Avalonia.Input
e.Source = element; e.Source = element;
e.Handled = false; e.Handled = false;
element.RaiseEvent(e); element.RaiseEvent(e);
element = (IInputElement)element.VisualParent; element = (IInputElement?)element.VisualParent;
} }
root.PointerOverElement = null; root.PointerOverElement = null;
@ -444,7 +444,7 @@ namespace Avalonia.Input
branch = el; branch = el;
break; break;
} }
el = (IInputElement)el.VisualParent; el = (IInputElement?)el.VisualParent;
} }
el = root.PointerOverElement; el = root.PointerOverElement;
@ -460,7 +460,7 @@ namespace Avalonia.Input
e.Source = el; e.Source = el;
e.Handled = false; e.Handled = false;
el.RaiseEvent(e); el.RaiseEvent(e);
el = (IInputElement)el.VisualParent; el = (IInputElement?)el.VisualParent;
} }
el = root.PointerOverElement = element; el = root.PointerOverElement = element;
@ -471,7 +471,7 @@ namespace Avalonia.Input
e.Source = el; e.Source = el;
e.Handled = false; e.Handled = false;
el.RaiseEvent(e); el.RaiseEvent(e);
el = (IInputElement)el.VisualParent; el = (IInputElement?)el.VisualParent;
} }
} }

2
src/Avalonia.Interactivity/IInteractive.cs

@ -1,5 +1,7 @@
using System; using System;
#nullable enable
namespace Avalonia.Interactivity namespace Avalonia.Interactivity
{ {
/// <summary> /// <summary>

2
src/Avalonia.Interactivity/Interactive.cs

@ -3,6 +3,8 @@ using System.Collections.Generic;
using Avalonia.Layout; using Avalonia.Layout;
using Avalonia.VisualTree; using Avalonia.VisualTree;
#nullable enable
namespace Avalonia.Interactivity namespace Avalonia.Interactivity
{ {
/// <summary> /// <summary>

2
src/Avalonia.Layout/Layoutable.cs

@ -782,7 +782,7 @@ namespace Avalonia.Layout
} }
/// <inheritdoc/> /// <inheritdoc/>
protected sealed override void OnVisualParentChanged(IVisual oldParent, IVisual newParent) protected sealed override void OnVisualParentChanged(IVisual? oldParent, IVisual? newParent)
{ {
LayoutHelper.InvalidateSelfAndChildrenMeasure(this); LayoutHelper.InvalidateSelfAndChildrenMeasure(this);

6
src/Avalonia.Styling/Controls/ISetInheritanceParent.cs

@ -1,3 +1,5 @@
#nullable enable
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
@ -14,6 +16,6 @@ namespace Avalonia.Controls
/// Sets the control's inheritance parent. /// Sets the control's inheritance parent.
/// </summary> /// </summary>
/// <param name="parent">The parent.</param> /// <param name="parent">The parent.</param>
void SetParent(IAvaloniaObject parent); void SetParent(IAvaloniaObject? parent);
} }
} }

6
src/Avalonia.Styling/Controls/ISetLogicalParent.cs

@ -1,5 +1,7 @@
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
#nullable enable
namespace Avalonia.Controls namespace Avalonia.Controls
{ {
/// <summary> /// <summary>
@ -14,6 +16,6 @@ namespace Avalonia.Controls
/// Sets the control's parent. /// Sets the control's parent.
/// </summary> /// </summary>
/// <param name="parent">The parent.</param> /// <param name="parent">The parent.</param>
void SetParent(ILogical parent); void SetParent(ILogical? parent);
} }
} }

6
src/Avalonia.Styling/IDataContextProvider.cs

@ -1,4 +1,6 @@
namespace Avalonia #nullable enable
namespace Avalonia
{ {
/// <summary> /// <summary>
/// Defines an element with a data context that can be used for binding. /// Defines an element with a data context that can be used for binding.
@ -8,6 +10,6 @@
/// <summary> /// <summary>
/// Gets or sets the element's data context. /// Gets or sets the element's data context.
/// </summary> /// </summary>
object DataContext { get; set; } object? DataContext { get; set; }
} }
} }

6
src/Avalonia.Styling/IStyledElement.cs

@ -4,6 +4,8 @@ using Avalonia.Controls;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
using Avalonia.Styling; using Avalonia.Styling;
#nullable enable
namespace Avalonia namespace Avalonia
{ {
public interface IStyledElement : public interface IStyledElement :
@ -17,7 +19,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Occurs when the control has finished initialization. /// Occurs when the control has finished initialization.
/// </summary> /// </summary>
event EventHandler Initialized; event EventHandler? Initialized;
/// <summary> /// <summary>
/// Gets a value that indicates whether the element has finished initialization. /// Gets a value that indicates whether the element has finished initialization.
@ -32,6 +34,6 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets the control's logical parent. /// Gets the control's logical parent.
/// </summary> /// </summary>
IStyledElement Parent { get; } IStyledElement? Parent { get; }
} }
} }

4
src/Avalonia.Styling/StyledElement.cs

@ -300,7 +300,7 @@ namespace Avalonia
bool IStyleHost.IsStylesInitialized => _styles != null; bool IStyleHost.IsStylesInitialized => _styles != null;
/// <inheritdoc/> /// <inheritdoc/>
IStyleHost? IStyleHost.StylingParent => (IStyleHost)InheritanceParent; IStyleHost? IStyleHost.StylingParent => (IStyleHost?)InheritanceParent;
/// <inheritdoc/> /// <inheritdoc/>
public virtual void BeginInit() public virtual void BeginInit()
@ -465,7 +465,7 @@ namespace Avalonia
/// Sets the styled element's inheritance parent. /// Sets the styled element's inheritance parent.
/// </summary> /// </summary>
/// <param name="parent">The parent.</param> /// <param name="parent">The parent.</param>
void ISetInheritanceParent.SetParent(IAvaloniaObject parent) void ISetInheritanceParent.SetParent(IAvaloniaObject? parent)
{ {
InheritanceParent = parent; InheritanceParent = parent;
} }

4
src/Avalonia.Styling/Styling/ISetterValue.cs

@ -1,4 +1,6 @@
namespace Avalonia.Styling #nullable enable
namespace Avalonia.Styling
{ {
/// <summary> /// <summary>
/// Customizes the behavior of a class when added as a value to an <see cref="ISetter"/>. /// Customizes the behavior of a class when added as a value to an <see cref="ISetter"/>.

4
src/Avalonia.Styling/Styling/PropertySetterInstance.cs

@ -50,7 +50,7 @@ namespace Avalonia.Styling
} }
else else
{ {
_subscription = _target.Bind(_directProperty, this); _subscription = _target.Bind(_directProperty!, this);
} }
} }
else else
@ -100,7 +100,7 @@ namespace Avalonia.Styling
} }
else else
{ {
_target.ClearValue(_directProperty); _target.ClearValue(_directProperty!);
} }
} }

4
src/Avalonia.Styling/Styling/PropertySetterLazyInstance.cs

@ -53,7 +53,7 @@ namespace Avalonia.Styling
} }
else else
{ {
_subscription = _target.Bind(_directProperty, this); _subscription = _target.Bind(_directProperty!, this);
} }
} }
@ -91,7 +91,7 @@ namespace Avalonia.Styling
} }
else else
{ {
_target.ClearValue(_directProperty); _target.ClearValue(_directProperty!);
} }
} }

50
src/Avalonia.Visuals/Visual.cs

@ -11,6 +11,8 @@ using Avalonia.Rendering;
using Avalonia.Utilities; using Avalonia.Utilities;
using Avalonia.VisualTree; using Avalonia.VisualTree;
#nullable enable
namespace Avalonia namespace Avalonia
{ {
/// <summary> /// <summary>
@ -45,8 +47,8 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines the <see cref="Clip"/> property. /// Defines the <see cref="Clip"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<Geometry> ClipProperty = public static readonly StyledProperty<Geometry?> ClipProperty =
AvaloniaProperty.Register<Visual, Geometry>(nameof(Clip)); AvaloniaProperty.Register<Visual, Geometry?>(nameof(Clip));
/// <summary> /// <summary>
/// Defines the <see cref="IsVisibleProperty"/> property. /// Defines the <see cref="IsVisibleProperty"/> property.
@ -63,14 +65,14 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines the <see cref="OpacityMask"/> property. /// Defines the <see cref="OpacityMask"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<IBrush> OpacityMaskProperty = public static readonly StyledProperty<IBrush?> OpacityMaskProperty =
AvaloniaProperty.Register<Visual, IBrush>(nameof(OpacityMask)); AvaloniaProperty.Register<Visual, IBrush?>(nameof(OpacityMask));
/// <summary> /// <summary>
/// Defines the <see cref="RenderTransform"/> property. /// Defines the <see cref="RenderTransform"/> property.
/// </summary> /// </summary>
public static readonly StyledProperty<ITransform> RenderTransformProperty = public static readonly StyledProperty<ITransform?> RenderTransformProperty =
AvaloniaProperty.Register<Visual, ITransform>(nameof(RenderTransform)); AvaloniaProperty.Register<Visual, ITransform?>(nameof(RenderTransform));
/// <summary> /// <summary>
/// Defines the <see cref="RenderTransformOrigin"/> property. /// Defines the <see cref="RenderTransformOrigin"/> property.
@ -81,8 +83,8 @@ namespace Avalonia
/// <summary> /// <summary>
/// Defines the <see cref="IVisual.VisualParent"/> property. /// Defines the <see cref="IVisual.VisualParent"/> property.
/// </summary> /// </summary>
public static readonly DirectProperty<Visual, IVisual> VisualParentProperty = public static readonly DirectProperty<Visual, IVisual?> VisualParentProperty =
AvaloniaProperty.RegisterDirect<Visual, IVisual>("VisualParent", o => o._visualParent); AvaloniaProperty.RegisterDirect<Visual, IVisual?>(nameof(IVisual.VisualParent), o => o._visualParent);
/// <summary> /// <summary>
/// Defines the <see cref="ZIndex"/> property. /// Defines the <see cref="ZIndex"/> property.
@ -92,8 +94,8 @@ namespace Avalonia
private Rect _bounds; private Rect _bounds;
private TransformedBounds? _transformedBounds; private TransformedBounds? _transformedBounds;
private IRenderRoot _visualRoot; private IRenderRoot? _visualRoot;
private IVisual _visualParent; private IVisual? _visualParent;
/// <summary> /// <summary>
/// Initializes static members of the <see cref="Visual"/> class. /// Initializes static members of the <see cref="Visual"/> class.
@ -128,12 +130,12 @@ namespace Avalonia
/// <summary> /// <summary>
/// Raised when the control is attached to a rooted visual tree. /// Raised when the control is attached to a rooted visual tree.
/// </summary> /// </summary>
public event EventHandler<VisualTreeAttachmentEventArgs> AttachedToVisualTree; public event EventHandler<VisualTreeAttachmentEventArgs>? AttachedToVisualTree;
/// <summary> /// <summary>
/// Raised when the control is detached from a rooted visual tree. /// Raised when the control is detached from a rooted visual tree.
/// </summary> /// </summary>
public event EventHandler<VisualTreeAttachmentEventArgs> DetachedFromVisualTree; public event EventHandler<VisualTreeAttachmentEventArgs>? DetachedFromVisualTree;
/// <summary> /// <summary>
/// Gets the bounds of the control relative to its parent. /// Gets the bounds of the control relative to its parent.
@ -161,7 +163,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets or sets the geometry clip for this visual. /// Gets or sets the geometry clip for this visual.
/// </summary> /// </summary>
public Geometry Clip public Geometry? Clip
{ {
get { return GetValue(ClipProperty); } get { return GetValue(ClipProperty); }
set { SetValue(ClipProperty, value); } set { SetValue(ClipProperty, value); }
@ -174,7 +176,7 @@ namespace Avalonia
{ {
get get
{ {
IVisual node = this; IVisual? node = this;
while (node != null) while (node != null)
{ {
@ -211,7 +213,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets or sets the opacity mask of the control. /// Gets or sets the opacity mask of the control.
/// </summary> /// </summary>
public IBrush OpacityMask public IBrush? OpacityMask
{ {
get { return GetValue(OpacityMaskProperty); } get { return GetValue(OpacityMaskProperty); }
set { SetValue(OpacityMaskProperty, value); } set { SetValue(OpacityMaskProperty, value); }
@ -220,7 +222,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets or sets the render transform of the control. /// Gets or sets the render transform of the control.
/// </summary> /// </summary>
public ITransform RenderTransform public ITransform? RenderTransform
{ {
get { return GetValue(RenderTransformProperty); } get { return GetValue(RenderTransformProperty); }
set { SetValue(RenderTransformProperty, value); } set { SetValue(RenderTransformProperty, value); }
@ -261,7 +263,7 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets the root of the visual tree, if the control is attached to a visual tree. /// Gets the root of the visual tree, if the control is attached to a visual tree.
/// </summary> /// </summary>
protected IRenderRoot VisualRoot => _visualRoot ?? (this as IRenderRoot); protected IRenderRoot? VisualRoot => _visualRoot ?? (this as IRenderRoot);
/// <summary> /// <summary>
/// Gets a value indicating whether this control is attached to a visual root. /// Gets a value indicating whether this control is attached to a visual root.
@ -276,12 +278,12 @@ namespace Avalonia
/// <summary> /// <summary>
/// Gets the control's parent visual. /// Gets the control's parent visual.
/// </summary> /// </summary>
IVisual IVisual.VisualParent => _visualParent; IVisual? IVisual.VisualParent => _visualParent;
/// <summary> /// <summary>
/// Gets the root of the visual tree, if the control is attached to a visual tree. /// Gets the root of the visual tree, if the control is attached to a visual tree.
/// </summary> /// </summary>
IRenderRoot IVisual.VisualRoot => VisualRoot; IRenderRoot? IVisual.VisualRoot => VisualRoot;
TransformedBounds? IVisual.TransformedBounds TransformedBounds? IVisual.TransformedBounds
{ {
@ -476,12 +478,12 @@ namespace Avalonia
/// </summary> /// </summary>
/// <param name="oldParent">The old visual parent.</param> /// <param name="oldParent">The old visual parent.</param>
/// <param name="newParent">The new visual parent.</param> /// <param name="newParent">The new visual parent.</param>
protected virtual void OnVisualParentChanged(IVisual oldParent, IVisual newParent) protected virtual void OnVisualParentChanged(IVisual? oldParent, IVisual? newParent)
{ {
RaisePropertyChanged( RaisePropertyChanged(
VisualParentProperty, VisualParentProperty,
new Optional<IVisual>(oldParent), new Optional<IVisual?>(oldParent),
new BindingValue<IVisual>(newParent), new BindingValue<IVisual?>(newParent),
BindingPriority.LocalValue); BindingPriority.LocalValue);
} }
@ -582,7 +584,7 @@ namespace Avalonia
/// Sets the visual parent of the Visual. /// Sets the visual parent of the Visual.
/// </summary> /// </summary>
/// <param name="value">The visual parent.</param> /// <param name="value">The visual parent.</param>
private void SetVisualParent(Visual value) private void SetVisualParent(Visual? value)
{ {
if (_visualParent == value) if (_visualParent == value)
{ {
@ -634,7 +636,7 @@ namespace Avalonia
} }
} }
private static void SetVisualParent(IList children, Visual parent) private static void SetVisualParent(IList children, Visual? parent)
{ {
var count = children.Count; var count = children.Count;

16
src/Avalonia.Visuals/VisualTree/IVisual.cs

@ -3,6 +3,8 @@ using Avalonia.Collections;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Rendering; using Avalonia.Rendering;
#nullable enable
namespace Avalonia.VisualTree namespace Avalonia.VisualTree
{ {
/// <summary> /// <summary>
@ -21,12 +23,12 @@ namespace Avalonia.VisualTree
/// <summary> /// <summary>
/// Raised when the control is attached to a rooted visual tree. /// Raised when the control is attached to a rooted visual tree.
/// </summary> /// </summary>
event EventHandler<VisualTreeAttachmentEventArgs> AttachedToVisualTree; event EventHandler<VisualTreeAttachmentEventArgs>? AttachedToVisualTree;
/// <summary> /// <summary>
/// Raised when the control is detached from a rooted visual tree. /// Raised when the control is detached from a rooted visual tree.
/// </summary> /// </summary>
event EventHandler<VisualTreeAttachmentEventArgs> DetachedFromVisualTree; event EventHandler<VisualTreeAttachmentEventArgs>? DetachedFromVisualTree;
/// <summary> /// <summary>
/// Gets the bounds of the control relative to its parent. /// Gets the bounds of the control relative to its parent.
@ -46,7 +48,7 @@ namespace Avalonia.VisualTree
/// <summary> /// <summary>
/// Gets or sets the geometry clip for this visual. /// Gets or sets the geometry clip for this visual.
/// </summary> /// </summary>
Geometry Clip { get; set; } Geometry? Clip { get; set; }
/// <summary> /// <summary>
/// Gets a value indicating whether this control is attached to a visual root. /// Gets a value indicating whether this control is attached to a visual root.
@ -71,12 +73,12 @@ namespace Avalonia.VisualTree
/// <summary> /// <summary>
/// Gets or sets the opacity mask for the control. /// Gets or sets the opacity mask for the control.
/// </summary> /// </summary>
IBrush OpacityMask { get; set; } IBrush? OpacityMask { get; set; }
/// <summary> /// <summary>
/// Gets or sets the render transform of the control. /// Gets or sets the render transform of the control.
/// </summary> /// </summary>
ITransform RenderTransform { get; set; } ITransform? RenderTransform { get; set; }
/// <summary> /// <summary>
/// Gets or sets the render transform origin of the control. /// Gets or sets the render transform origin of the control.
@ -91,12 +93,12 @@ namespace Avalonia.VisualTree
/// <summary> /// <summary>
/// Gets the control's parent visual. /// Gets the control's parent visual.
/// </summary> /// </summary>
IVisual VisualParent { get; } IVisual? VisualParent { get; }
/// <summary> /// <summary>
/// Gets the root of the visual tree, if the control is attached to a visual tree. /// Gets the root of the visual tree, if the control is attached to a visual tree.
/// </summary> /// </summary>
IRenderRoot VisualRoot { get; } IRenderRoot? VisualRoot { get; }
/// <summary> /// <summary>
/// Gets or sets the Z index of the node. /// Gets or sets the Z index of the node.

Loading…
Cancel
Save