Skip to content

EllipseGeometry Clone Fix #11773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Avalonia.Base/AvaloniaObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public static IDisposable AddClassHandler<TTarget>(
/// <typeparamref name="TTarget"/>.
/// </summary>
/// <typeparam name="TTarget">The type of the property change sender.</typeparam>
/// /// <typeparam name="TValue">The type of the property..</typeparam>
/// <typeparam name="TValue">The type of the property.</typeparam>
/// <param name="observable">The property changed observable.</param>
/// <param name="action">
/// The method to call. The parameters are the sender and the event args.
Expand Down
41 changes: 40 additions & 1 deletion src/Avalonia.Base/Media/EllipseGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public EllipseGeometry(Rect rect) : this()
/// <summary>
/// Gets or sets a rect that defines the bounds of the ellipse.
/// </summary>
/// <remarks>
/// When set, this takes priority over the other properties that define an
/// ellipse using a center point and X/Y-axis radii.
/// </remarks>
public Rect Rect
{
get => GetValue(RectProperty);
Expand All @@ -65,6 +69,10 @@ public Rect Rect
/// <summary>
/// Gets or sets a double that defines the radius in the X-axis of the ellipse.
/// </summary>
/// <remarks>
/// In order for this property to be used, <see cref="Rect"/> must not be set
/// (equal to the default <see cref="Avalonia.Rect"/> value).
/// </remarks>
public double RadiusX
{
get => GetValue(RadiusXProperty);
Expand All @@ -74,6 +82,10 @@ public double RadiusX
/// <summary>
/// Gets or sets a double that defines the radius in the Y-axis of the ellipse.
/// </summary>
/// <remarks>
/// In order for this property to be used, <see cref="Rect"/> must not be set
/// (equal to the default <see cref="Avalonia.Rect"/> value).
/// </remarks>
public double RadiusY
{
get => GetValue(RadiusYProperty);
Expand All @@ -83,6 +95,10 @@ public double RadiusY
/// <summary>
/// Gets or sets a point that defines the center of the ellipse.
/// </summary>
/// <remarks>
/// In order for this property to be used, <see cref="Rect"/> must not be set
/// (equal to the default <see cref="Avalonia.Rect"/> value).
/// </remarks>
public Point Center
{
get => GetValue(CenterProperty);
Expand All @@ -92,7 +108,30 @@ public Point Center
/// <inheritdoc/>
public override Geometry Clone()
{
return new EllipseGeometry(Rect);
// Note that the ellipse properties are used in two modes:
//
// 1. Rect-only Mode:
// Directly set the rectangle bounds the ellipse will fill
//
// 2. Center + Radii Mode:
// Set a center-point and then X/Y-axis radii that are used to
// calculate the rectangle bounds the ellipse will fill.
// This is the only mode supported by WPF.
//
// Rendering the ellipse will only ever use one of these two modes
// based on if the Rect property is set (not equal to default).
//
// This means it would normally be fine to copy ONLY the Rect property
// when it is set. However, while it would render the same, it isn't
// a true clone. We want to include all the properties here regardless
// of the rendering mode that will eventually be used.
return new EllipseGeometry()
{
Rect = Rect,
RadiusX = RadiusX,
RadiusY = RadiusY,
Center = Center,
};
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ private void BuildX9RemovalMap()
/// <remarks>
/// This method resolves the sos and eos values for the run
/// and adds the run to the list
/// /// </remarks>
/// </remarks>
/// <param name="start">The index of the start of the run (in x9 removed units)</param>
/// <param name="length">The length of the run (in x9 removed units)</param>
/// <param name="level">The level of the run</param>
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Platform/IPlatformRenderInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface IPlatformRenderInterface
/// Creates an ellipse geometry implementation.
/// </summary>
/// <param name="rect">The bounds of the ellipse.</param>
/// <returns>An ellipse geometry..</returns>
/// <returns>An ellipse geometry.</returns>
IGeometryImpl CreateEllipseGeometry(Rect rect);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Base/Utilities/TypeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public static bool TryConvertImplicit(Type to, object? value, out object? result
/// if the value could not be converted.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <param name="type">The type to convert to..</param>
/// <param name="type">The type to convert to.</param>
/// <param name="culture">The culture to use.</param>
/// <returns>A value of <paramref name="type"/>.</returns>
[RequiresUnreferencedCode(TrimmingMessages.TypeConversionRequiresUnreferencedCodeMessage)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public enum PopupPositionerConstraintAdjustment
///
/// If the adjusted position also ends up being constrained, the resulting position of the
/// FlipX adjustment will be the one before the adjustment.
/// /// </remarks>
/// </remarks>
FlipX = 4,

/// <summary>
Expand Down