Browse Source

Make all mutable brushes implement IMutableBrush.

pull/942/head
Steven Kirk 10 years ago
parent
commit
5be8f17eb1
  1. 12
      src/Avalonia.Visuals/Media/ImageBrush.cs
  2. 8
      src/Avalonia.Visuals/Media/LinearGradientBrush.cs
  3. 8
      src/Avalonia.Visuals/Media/RadialGradientBrush.cs
  4. 8
      src/Avalonia.Visuals/Media/VisualBrush.cs

12
src/Avalonia.Visuals/Media/ImageBrush.cs

@ -8,7 +8,7 @@ namespace Avalonia.Media
/// <summary> /// <summary>
/// Paints an area with an <see cref="IBitmap"/>. /// Paints an area with an <see cref="IBitmap"/>.
/// </summary> /// </summary>
public class ImageBrush : TileBrush, IImageBrush public class ImageBrush : TileBrush, IImageBrush, IMutableBrush
{ {
/// <summary> /// <summary>
/// Defines the <see cref="Visual"/> property. /// Defines the <see cref="Visual"/> property.
@ -17,14 +17,14 @@ namespace Avalonia.Media
AvaloniaProperty.Register<ImageBrush, IBitmap>("Source"); AvaloniaProperty.Register<ImageBrush, IBitmap>("Source");
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VisualBrush"/> class. /// Initializes a new instance of the <see cref="ImageBrush"/> class.
/// </summary> /// </summary>
public ImageBrush() public ImageBrush()
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VisualBrush"/> class. /// Initializes a new instance of the <see cref="ImageBrush"/> class.
/// </summary> /// </summary>
/// <param name="source">The image to draw.</param> /// <param name="source">The image to draw.</param>
public ImageBrush(IBitmap source) public ImageBrush(IBitmap source)
@ -40,5 +40,11 @@ namespace Avalonia.Media
get { return GetValue(SourceProperty); } get { return GetValue(SourceProperty); }
set { SetValue(SourceProperty, value); } set { SetValue(SourceProperty, value); }
} }
/// <inheritdoc/>
IBrush IMutableBrush.ToImmutable()
{
return new Immutable.ImmutableImageBrush(this);
}
} }
} }

8
src/Avalonia.Visuals/Media/LinearGradientBrush.cs

@ -6,7 +6,7 @@ namespace Avalonia.Media
/// <summary> /// <summary>
/// A brush that draws with a linear gradient. /// A brush that draws with a linear gradient.
/// </summary> /// </summary>
public sealed class LinearGradientBrush : GradientBrush, ILinearGradientBrush public sealed class LinearGradientBrush : GradientBrush, ILinearGradientBrush, IMutableBrush
{ {
/// <summary> /// <summary>
/// Defines the <see cref="StartPoint"/> property. /// Defines the <see cref="StartPoint"/> property.
@ -41,5 +41,11 @@ namespace Avalonia.Media
get { return GetValue(EndPointProperty); } get { return GetValue(EndPointProperty); }
set { SetValue(EndPointProperty, value); } set { SetValue(EndPointProperty, value); }
} }
/// <inheritdoc/>
IBrush IMutableBrush.ToImmutable()
{
return new Immutable.ImmutableLinearGradientBrush(this);
}
} }
} }

8
src/Avalonia.Visuals/Media/RadialGradientBrush.cs

@ -7,7 +7,7 @@ namespace Avalonia.Media
/// Paints an area with a radial gradient. A focal point defines the beginning of the gradient, /// Paints an area with a radial gradient. A focal point defines the beginning of the gradient,
/// and a circle defines the end point of the gradient. /// and a circle defines the end point of the gradient.
/// </summary> /// </summary>
public sealed class RadialGradientBrush : GradientBrush, IRadialGradientBrush public sealed class RadialGradientBrush : GradientBrush, IRadialGradientBrush, IMutableBrush
{ {
/// <summary> /// <summary>
/// Defines the <see cref="Center"/> property. /// Defines the <see cref="Center"/> property.
@ -61,5 +61,11 @@ namespace Avalonia.Media
get { return GetValue(RadiusProperty); } get { return GetValue(RadiusProperty); }
set { SetValue(RadiusProperty, value); } set { SetValue(RadiusProperty, value); }
} }
/// <inheritdoc/>
IBrush IMutableBrush.ToImmutable()
{
return new Immutable.ImmutableRadialGradientBrush(this);
}
} }
} }

8
src/Avalonia.Visuals/Media/VisualBrush.cs

@ -8,7 +8,7 @@ namespace Avalonia.Media
/// <summary> /// <summary>
/// Paints an area with an <see cref="IVisual"/>. /// Paints an area with an <see cref="IVisual"/>.
/// </summary> /// </summary>
public class VisualBrush : TileBrush, IVisualBrush public class VisualBrush : TileBrush, IVisualBrush, IMutableBrush
{ {
/// <summary> /// <summary>
/// Defines the <see cref="Visual"/> property. /// Defines the <see cref="Visual"/> property.
@ -40,5 +40,11 @@ namespace Avalonia.Media
get { return GetValue(VisualProperty); } get { return GetValue(VisualProperty); }
set { SetValue(VisualProperty, value); } set { SetValue(VisualProperty, value); }
} }
/// <inheritdoc/>
IBrush IMutableBrush.ToImmutable()
{
return new Immutable.ImmutableVisualBrush(this);
}
} }
} }

Loading…
Cancel
Save