From 84efb2a3d1124514cde9602cad626c5a2a81607c Mon Sep 17 00:00:00 2001 From: dnesov Date: Fri, 20 Jun 2025 20:21:45 +0200 Subject: [PATCH] Add ContainsPoint helper method to Widget. --- Voile/Source/UI/Widgets/Widget.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Voile/Source/UI/Widgets/Widget.cs b/Voile/Source/UI/Widgets/Widget.cs index 81bce9c..5ce7698 100644 --- a/Voile/Source/UI/Widgets/Widget.cs +++ b/Voile/Source/UI/Widgets/Widget.cs @@ -61,5 +61,18 @@ public abstract class Widget : IElement, IRenderableElement, IInputElement, IRes renderer.DrawRectangleOutline(new Vector2(Size.Width, Size.Height), Color.Red, 2.0f); } + /// + /// Determines if this contains a point within its confines. + /// + /// A global position of the point. + /// True if the point is inside the widget; otherwise, false. + 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; } \ No newline at end of file