Browse Source

Make Rect.Deflate consistent with Rect.Inflate.

`Rect.Deflate` was halving the thickness passed into it whereas `Rect.Inflate` wasn't. Make both methods consistent and _not_ halve the thickness.
pull/2537/head
Steven Kirk 7 years ago
parent
commit
7cdaeac441
  1. 2
      src/Avalonia.Controls/Shapes/Ellipse.cs
  2. 2
      src/Avalonia.Controls/Shapes/Rectangle.cs
  3. 12
      src/Avalonia.Visuals/Rect.cs
  4. 6
      tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs

2
src/Avalonia.Controls/Shapes/Ellipse.cs

@ -14,7 +14,7 @@ namespace Avalonia.Controls.Shapes
protected override Geometry CreateDefiningGeometry()
{
var rect = new Rect(Bounds.Size).Deflate(StrokeThickness);
var rect = new Rect(Bounds.Size).Deflate(StrokeThickness / 2);
return new EllipseGeometry(rect);
}

2
src/Avalonia.Controls/Shapes/Rectangle.cs

@ -14,7 +14,7 @@ namespace Avalonia.Controls.Shapes
protected override Geometry CreateDefiningGeometry()
{
var rect = new Rect(Bounds.Size).Deflate(StrokeThickness);
var rect = new Rect(Bounds.Size).Deflate(StrokeThickness / 2);
return new RectangleGeometry(rect);
}

12
src/Avalonia.Visuals/Rect.cs

@ -256,7 +256,7 @@ namespace Avalonia
/// <summary>
/// Inflates the rectangle.
/// </summary>
/// <param name="thickness">The thickness.</param>
/// <param name="thickness">The thickness to be subtracted for each side of the rectangle.</param>
/// <returns>The inflated rectangle.</returns>
public Rect Inflate(double thickness)
{
@ -266,7 +266,7 @@ namespace Avalonia
/// <summary>
/// Inflates the rectangle.
/// </summary>
/// <param name="thickness">The thickness.</param>
/// <param name="thickness">The thickness to be subtracted for each side of the rectangle.</param>
/// <returns>The inflated rectangle.</returns>
public Rect Inflate(Thickness thickness)
{
@ -278,20 +278,18 @@ namespace Avalonia
/// <summary>
/// Deflates the rectangle.
/// </summary>
/// <param name="thickness">The thickness.</param>
/// <param name="thickness">The thickness to be subtracted for each side of the rectangle.</param>
/// <returns>The deflated rectangle.</returns>
/// <remarks>The deflated rectangle size cannot be less than 0.</remarks>
public Rect Deflate(double thickness)
{
return Deflate(new Thickness(thickness / 2));
return Deflate(new Thickness(thickness));
}
/// <summary>
/// Deflates the rectangle by a <see cref="Thickness"/>.
/// </summary>
/// <param name="thickness">The thickness.</param>
/// <param name="thickness">The thickness to be subtracted for each side of the rectangle.</param>
/// <returns>The deflated rectangle.</returns>
/// <remarks>The deflated rectangle size cannot be less than 0.</remarks>
public Rect Deflate(Thickness thickness)
{
return new Rect(

6
tests/Avalonia.RenderTests/Controls/CustomRenderTests.cs

@ -36,7 +36,7 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
new Rect(control.Bounds.Size),
4);
using (context.PushClip(new Rect(control.Bounds.Size).Deflate(20)))
using (context.PushClip(new Rect(control.Bounds.Size).Deflate(10)))
{
context.FillRectangle(
Brushes.Blue,
@ -100,7 +100,7 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
{
context.FillRectangle(
Brushes.Blue,
new Rect(control.Bounds.Size).Deflate(20),
new Rect(control.Bounds.Size).Deflate(10),
4);
}
}),
@ -140,7 +140,7 @@ namespace Avalonia.Direct2D1.RenderTests.Controls
{
context.FillRectangle(
Brushes.Blue,
new Rect(control.Bounds.Size).Deflate(20),
new Rect(control.Bounds.Size).Deflate(10),
4);
}
}),

Loading…
Cancel
Save