Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.Components
Imports Nexamas.UI.Controls
Imports Nexamas.UI.General
Imports Nexamas.UI.Icons
Imports Nexamas.UI.Theming
Imports Nexamas.UI.TextRendering
Imports Nexamas.UI.Values
Imports Nexamas.UI.Architecture
Imports SkiaSharp

Namespace Nexamas.UI.Rendering

    Partial Friend NotInheritable Class MASToastRenderer
        Private Shared Function ResolveCompactGlyphButtonSizePx(dpi As Single) As Single
            Dim safeDpi As Single = PixelSnap.SafeDpi(dpi)
            Dim sizePx As Single = ToastTokens.CloseButtonSize * safeDpi

            Return PixelSnap.SnapHalf(Math.Max(1.0F, sizePx))
        End Function

        ''' <summary>Resolves the visual gap between adjacent compact glyph buttons.</summary>
        Private Shared Function ResolveCompactGlyphButtonGapPx(dpi As Single) As Single
            Return PixelSnap.SnapHalf(Math.Max(0.0F, ToastTokens.ToastGlyphButtonGap * PixelSnap.SafeDpi(dpi)))
        End Function

        ''' <summary>Resolves the protected text-to-command gap before the compact glyph group.</summary>
        Private Shared Function ResolveCompactGlyphContentGapPx(dpi As Single) As Single
            Return PixelSnap.SnapHalf(Math.Max(0.0F, ToastTokens.CloseGap * PixelSnap.SafeDpi(dpi)))
        End Function

        ''' <summary>Reserves the exact right-side width occupied by the compact glyph-button group.</summary>
        Private Shared Function ResolveCompactGlyphGroupReservePx(dpi As Single, buttonCount As Integer) As Single
            Dim count As Integer = Math.Max(0, buttonCount)
            If count = 0 Then Return 0.0F

            Dim buttonsWidth As Single = ResolveCompactGlyphButtonSizePx(dpi) * CSng(count)
            Dim internalGaps As Single = ResolveCompactGlyphButtonGapPx(dpi) * CSng(Math.Max(0, count - 1))

            Return PixelSnap.SnapHalf(buttonsWidth + internalGaps + ResolveCompactGlyphContentGapPx(dpi))
        End Function
    End Class

End Namespace
