Option Strict On
Option Explicit On

Imports System
Imports SkiaSharp

Namespace Nexamas.UI.Components

    ''' <summary>
    ''' Generic rectangular hit testing for media command buttons. Owners decide whether
    ''' the returned action id is currently enabled or executable.
    ''' </summary>
    Friend NotInheritable Class MASMediaButtonHitTester

        Private Sub New()
        End Sub

        Friend Shared Function TryHitTest(buttons As MASMediaButtonModel(),
                                          pointPx As SKPoint,
                                          ByRef actionId As Integer) As Boolean
            actionId = 0
            If buttons Is Nothing Then Return False

            For i As Integer = 0 To buttons.Length - 1
                Dim button As MASMediaButtonModel = buttons(i)
                If button.Rect.Contains(pointPx.X, pointPx.Y) Then
                    actionId = button.ActionId
                    Return True
                End If
            Next

            Return False
        End Function

    End Class

End Namespace
