Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.General
Imports Nexamas.UI.Rendering
Imports Nexamas.UI.Theming
Imports Nexamas.UI.Values
Imports Nexamas.UI.Architecture
Imports Nexamas.UI.Layout
Imports Nexamas.UI.Composition
Imports SkiaSharp

Namespace Nexamas.UI.Controls


    Partial Public NotInheritable Class MASGroupBox
        Private _titleNotchEnabled As Boolean = True
        Private _titlePlateStrength As MASGroupBoxTitlePlateStrength = MASGroupBoxTitlePlateStrength.Premium
        Private _titleLift As Single = GroupBoxTokens.FloatingTitleDefaultLift


        Public Property TitleNotchEnabled As Boolean
            Get
                Return _titleNotchEnabled
            End Get
            Set(value As Boolean)
                If _titleNotchEnabled = value Then Return
                _titleNotchEnabled = value
                InvalidateVisual()
            End Set
        End Property

        Public Property TitlePlateStrength As MASGroupBoxTitlePlateStrength
            Get
                Return _titlePlateStrength
            End Get
            Set(value As MASGroupBoxTitlePlateStrength)
                If _titlePlateStrength = value Then Return
                _titlePlateStrength = value
                InvalidateVisual()
            End Set
        End Property

        Public Property TitleLift As Single
            Get
                Return _titleLift
            End Get
            Set(value As Single)
                Dim v As Single = MASGroupBoxSurfacePolicy.NormalizeTitleLift(value)

                If Math.Abs(_titleLift - v) < 0.001F Then Return
                _titleLift = v
                InvalidateVisual()
            End Set
        End Property

        Private Shared Function ToRendererTitlePlateStrength(value As MASGroupBoxTitlePlateStrength) As MASGroupBoxRenderer.GroupBoxRenderTitlePlateStrength
            Select Case value
                Case MASGroupBoxTitlePlateStrength.Soft
                    Return MASGroupBoxRenderer.GroupBoxRenderTitlePlateStrength.Soft
                Case MASGroupBoxTitlePlateStrength.Strong
                    Return MASGroupBoxRenderer.GroupBoxRenderTitlePlateStrength.Strong
                Case Else
                    Return MASGroupBoxRenderer.GroupBoxRenderTitlePlateStrength.Premium
            End Select
        End Function





#Region "Fluent API - Title Plate"

        Public Function WithTitleNotch(value As Boolean) As MASGroupBox
            Me.TitleNotchEnabled = value
            Return Me
        End Function

        Public Function WithTitlePlateStrength(value As MASGroupBoxTitlePlateStrength) As MASGroupBox
            Me.TitlePlateStrength = value
            Return Me
        End Function

        <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
        Friend Function WithTitleLift(value As Single) As MASGroupBox
            Me.TitleLift = value
            Return Me
        End Function

#End Region

    End Class

End Namespace
