Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading
Imports System.Threading.Tasks

Imports Nexamas.UI.Architecture
Imports Nexamas.UI.Composition
Imports Nexamas.UI.Controls
Imports Nexamas.UI.FileSystem
Imports Nexamas.UI.General
Imports Nexamas.UI.Icons
Imports Nexamas.UI.Layout
Imports Nexamas.UI.Platform
Imports Nexamas.UI.Theming
Imports Nexamas.UI.Values

Imports SkiaSharp

Namespace Nexamas.UI.Components


    Partial Friend NotInheritable Class MASFileBrowser
#Region "Rendering and host hooks"

        Protected Overrides Function WantsKeyboardFocus() As Boolean
            Return True
        End Function


        Protected Overrides Sub OnGotKeyboardFocus()
            MyBase.OnGotKeyboardFocus()

            If _list IsNot Nothing Then
                RequestFocus(_list)
            End If
        End Sub


        Protected Overrides Sub Render(canvas As SKCanvas, ctx As MASThemeContext, pixelBounds As SKRect)
            If canvas Is Nothing OrElse ctx Is Nothing Then Return
            If pixelBounds.Width <= 0.5F OrElse pixelBounds.Height <= 0.5F Then Return

            Dim safeDpi As Single = PixelSnap.SafeDpi(ctx.Dpi)
            Dim contentBoundsPx As SKRect = GetLayoutContentBoundsPxInternal(safeDpi)
            If contentBoundsPx.Width <= 0.5F OrElse contentBoundsPx.Height <= 0.5F Then
                contentBoundsPx = pixelBounds
            End If

            ApplyListLayout(contentBoundsPx, safeDpi)
        End Sub


        Protected Overrides Function HitTest(ctx As MASThemeContext, ptPx As SKPoint) As Boolean
            If ctx Is Nothing Then Return False
            Return GetPixelHitBounds(ctx).Contains(ptPx.X, ptPx.Y)
        End Function


        Protected Overrides Sub OnBoundsChanged()
            SafeInvalidate()
        End Sub



#End Region

    End Class

End Namespace
