|
|
@ -4,14 +4,14 @@ |
|
|
namespace Perspex |
|
|
namespace Perspex |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Defines a rectangle that may be defined relative to another rectangle.
|
|
|
/// Defines a rectangle that may be defined relative to a containing element.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public struct RelativeRect |
|
|
public struct RelativeRect |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// A rectangle that represents 100% of an area.
|
|
|
/// A rectangle that represents 100% of an area.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static readonly RelativeRect Fill = new RelativeRect(0, 0, 1, 1, OriginUnit.Percent); |
|
|
public static readonly RelativeRect Fill = new RelativeRect(0, 0, 1, 1, RelativeUnit.Percent); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="RelativeRect"/> structure.
|
|
|
/// Initializes a new instance of the <see cref="RelativeRect"/> structure.
|
|
|
@ -21,7 +21,7 @@ namespace Perspex |
|
|
/// <param name="width">The width.</param>
|
|
|
/// <param name="width">The width.</param>
|
|
|
/// <param name="height">The height.</param>
|
|
|
/// <param name="height">The height.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
public RelativeRect(double x, double y, double width, double height, OriginUnit unit) |
|
|
public RelativeRect(double x, double y, double width, double height, RelativeUnit unit) |
|
|
{ |
|
|
{ |
|
|
Rect = new Rect(x, y, width, height); |
|
|
Rect = new Rect(x, y, width, height); |
|
|
Unit = unit; |
|
|
Unit = unit; |
|
|
@ -32,7 +32,7 @@ namespace Perspex |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="rect">The rectangle.</param>
|
|
|
/// <param name="rect">The rectangle.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
public RelativeRect(Rect rect, OriginUnit unit) |
|
|
public RelativeRect(Rect rect, RelativeUnit unit) |
|
|
{ |
|
|
{ |
|
|
Rect = rect; |
|
|
Rect = rect; |
|
|
Unit = unit; |
|
|
Unit = unit; |
|
|
@ -43,7 +43,7 @@ namespace Perspex |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="size">The size of the rectangle.</param>
|
|
|
/// <param name="size">The size of the rectangle.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
public RelativeRect(Size size, OriginUnit unit) |
|
|
public RelativeRect(Size size, RelativeUnit unit) |
|
|
{ |
|
|
{ |
|
|
Rect = new Rect(size); |
|
|
Rect = new Rect(size); |
|
|
Unit = unit; |
|
|
Unit = unit; |
|
|
@ -55,7 +55,7 @@ namespace Perspex |
|
|
/// <param name="position">The position of the rectangle.</param>
|
|
|
/// <param name="position">The position of the rectangle.</param>
|
|
|
/// <param name="size">The size of the rectangle.</param>
|
|
|
/// <param name="size">The size of the rectangle.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
public RelativeRect(Point position, Size size, OriginUnit unit) |
|
|
public RelativeRect(Point position, Size size, RelativeUnit unit) |
|
|
{ |
|
|
{ |
|
|
Rect = new Rect(position, size); |
|
|
Rect = new Rect(position, size); |
|
|
Unit = unit; |
|
|
Unit = unit; |
|
|
@ -67,7 +67,7 @@ namespace Perspex |
|
|
/// <param name="topLeft">The top left position of the rectangle.</param>
|
|
|
/// <param name="topLeft">The top left position of the rectangle.</param>
|
|
|
/// <param name="bottomRight">The bottom right position of the rectangle.</param>
|
|
|
/// <param name="bottomRight">The bottom right position of the rectangle.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
/// <param name="unit">The unit of the rect.</param>
|
|
|
public RelativeRect(Point topLeft, Point bottomRight, OriginUnit unit) |
|
|
public RelativeRect(Point topLeft, Point bottomRight, RelativeUnit unit) |
|
|
{ |
|
|
{ |
|
|
Rect = new Rect(topLeft, bottomRight); |
|
|
Rect = new Rect(topLeft, bottomRight); |
|
|
Unit = unit; |
|
|
Unit = unit; |
|
|
@ -76,7 +76,7 @@ namespace Perspex |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the unit of the rectangle.
|
|
|
/// Gets the unit of the rectangle.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public OriginUnit Unit { get; } |
|
|
public RelativeUnit Unit { get; } |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets the rectangle.
|
|
|
/// Gets the rectangle.
|
|
|
@ -90,7 +90,7 @@ namespace Perspex |
|
|
/// <returns>The origin point in pixels.</returns>
|
|
|
/// <returns>The origin point in pixels.</returns>
|
|
|
public Rect ToPixels(Size size) |
|
|
public Rect ToPixels(Size size) |
|
|
{ |
|
|
{ |
|
|
return Unit == OriginUnit.Pixels ? |
|
|
return Unit == RelativeUnit.Pixels ? |
|
|
Rect : |
|
|
Rect : |
|
|
new Rect( |
|
|
new Rect( |
|
|
Rect.X * size.Width, |
|
|
Rect.X * size.Width, |
|
|
|