SPB Git

Repository Public MIT

GlassControlMetrics.swift 3.2 KB 93 lines swift

1// =============================================================================2//                  SP BOUCHER | SOFTWARE & RESEARCH3//             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project          : SP GlassKit7// File             : Sources/SPGlassTokens/GlassControlMetrics.swift8// Module           : SPGlassTokens9// Repository       : https://git.spboucher.ai/sp-glasskit10// Project Website  : https://glass.spboucher.ai11// Created          : 2026-12-0212// Last Modified    : 2026-12-0213//14// Author           : Simon-Pierre Boucher15// Position         : Professor of Finance16// Institution      : Université du Québec en Outaouais (UQO)17// Organization     : SP Boucher18// Website          : https://spboucher.ai19// Git              : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development      : dev@spboucher.ai23// Support          : support@spboucher.ai24// Security/Admin   : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License          : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import Foundation42import SPGlassCore4344/// Sizes of the controls GlassKit draws itself, per platform. System controls are never resized by these values.45public struct GlassControlMetrics: Hashable, Sendable {46    public let platform: GlassPlatform4748    public init(platform: GlassPlatform = .current) {49        self.platform = platform50    }5152    /// Smallest pointer or touch target: 44 points on iOS and iPadOS, 24 on macOS.53    public var minimumHitTarget: Double {54        platform == .macOS ? 24 : 4455    }5657    /// Height of a custom control surface.58    public func height(_ size: GlassControlSize) -> Double {59        switch (platform, size) {60        case (.macOS, .small): 2461        case (.macOS, .regular): 3062        case (.macOS, .large): 3863        case (_, .small): 3464        case (_, .regular): 4465        case (_, .large): 5466        }67    }6869    /// Horizontal padding of a custom control surface.70    public func horizontalPadding(_ size: GlassControlSize) -> Double {71        switch (platform, size) {72        case (.macOS, .small): 873        case (.macOS, .regular): 1274        case (.macOS, .large): 1675        case (_, .small): 1276        case (_, .regular): 1677        case (_, .large): 2278        }79    }8081    /// Point size of an SF Symbol inside a custom icon control.82    public func iconSize(_ size: GlassControlSize) -> Double {83        switch (platform, size) {84        case (.macOS, .small): 1285        case (.macOS, .regular): 1486        case (.macOS, .large): 1787        case (_, .small): 1588        case (_, .regular): 1889        case (_, .large): 2290        }91    }92}93
Files main
Menu

Theme