Option Strict On
Option Explicit On

Imports SkiaSharp

Namespace Nexamas.UI.Rendering

    ''' <summary>
    ''' Internal layout result produced by MASPanelShellRenderer.
    ''' External projects receive only stable Application-layer geometry results; this raw result stays internal.
    ''' </summary>
    Friend NotInheritable Class MASPanelShellResult

        Friend Shared ReadOnly Empty As MASPanelShellResult =
            New MASPanelShellResult(SKRect.Empty, 0.0F, SKRect.Empty, SKRect.Empty,
                                    SKRect.Empty, SKRect.Empty, SKRect.Empty, SKRect.Empty, False)

        Friend ReadOnly Property BaseRectPx As SKRect
        Friend ReadOnly Property RadiusPx As Single
        Friend ReadOnly Property HeaderRectPx As SKRect
        Friend ReadOnly Property ContentRectPx As SKRect
        Friend ReadOnly Property HeaderIconRectPx As SKRect
        Friend ReadOnly Property HeaderTitleRectPx As SKRect
        Friend ReadOnly Property HeaderSubtitleRectPx As SKRect
        Friend ReadOnly Property HeaderCloseRectPx As SKRect
        Friend ReadOnly Property HasHeader As Boolean

        Friend Sub New(baseRectPx As SKRect,
                       radiusPx As Single,
                       headerRectPx As SKRect,
                       contentRectPx As SKRect,
                       headerIconRectPx As SKRect,
                       headerTitleRectPx As SKRect,
                       headerSubtitleRectPx As SKRect,
                       headerCloseRectPx As SKRect,
                       hasHeader As Boolean)

            Me.BaseRectPx = baseRectPx
            Me.RadiusPx = radiusPx
            Me.HeaderRectPx = headerRectPx
            Me.ContentRectPx = contentRectPx
            Me.HeaderIconRectPx = headerIconRectPx
            Me.HeaderTitleRectPx = headerTitleRectPx
            Me.HeaderSubtitleRectPx = headerSubtitleRectPx
            Me.HeaderCloseRectPx = headerCloseRectPx
            Me.HasHeader = hasHeader
        End Sub

        Friend Function HitTest(pointPx As SKPoint) As MASPanelShellHitTarget
            If Not HeaderCloseRectPx.IsEmpty AndAlso HeaderCloseRectPx.Contains(pointPx.X, pointPx.Y) Then
                Return MASPanelShellHitTarget.CloseButton
            End If

            If Not HeaderRectPx.IsEmpty AndAlso HeaderRectPx.Contains(pointPx.X, pointPx.Y) Then
                Return MASPanelShellHitTarget.Header
            End If

            If Not ContentRectPx.IsEmpty AndAlso ContentRectPx.Contains(pointPx.X, pointPx.Y) Then
                Return MASPanelShellHitTarget.Content
            End If

            Return MASPanelShellHitTarget.None
        End Function

    End Class

End Namespace
