Add ContainsPoint helper method to Widget.
This commit is contained in:
@@ -61,5 +61,18 @@ public abstract class Widget : IElement, IRenderableElement, IInputElement, IRes
|
||||
renderer.DrawRectangleOutline(new Vector2(Size.Width, Size.Height), Color.Red, 2.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if this <see cref="Widget"/> contains a point within its confines.
|
||||
/// </summary>
|
||||
/// <param name="pointPosition">A global position of the point.</param>
|
||||
/// <returns>True if the point is inside the widget; otherwise, false.</returns>
|
||||
public bool ContainsPoint(Vector2 pointPosition)
|
||||
{
|
||||
return pointPosition.X >= Position.X &&
|
||||
pointPosition.Y >= Position.Y &&
|
||||
pointPosition.X <= Position.X + Size.Width &&
|
||||
pointPosition.Y <= Position.Y + Size.Height;
|
||||
}
|
||||
|
||||
private bool _isDirty = true;
|
||||
}
|
||||
Reference in New Issue
Block a user