SPB Git

Repository Public MIT

GlassControlMetrics.swift 3.1 KB 92 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 Foundation4243/// Sizes of the controls GlassKit draws itself, per platform. System controls are never resized by these values.44public struct GlassControlMetrics: Hashable, Sendable {45    public let platform: GlassPlatform4647    public init(platform: GlassPlatform = .current) {48        self.platform = platform49    }5051    /// Smallest pointer or touch target: 44 points on iOS and iPadOS, 24 on macOS.52    public var minimumHitTarget: Double {53        platform == .macOS ? 24 : 4454    }5556    /// Height of a custom control surface.57    public func height(_ size: GlassControlSize) -> Double {58        switch (platform, size) {59        case (.macOS, .small): 2460        case (.macOS, .regular): 3061        case (.macOS, .large): 3862        case (_, .small): 3463        case (_, .regular): 4464        case (_, .large): 5465        }66    }6768    /// Horizontal padding of a custom control surface.69    public func horizontalPadding(_ size: GlassControlSize) -> Double {70        switch (platform, size) {71        case (.macOS, .small): 872        case (.macOS, .regular): 1273        case (.macOS, .large): 1674        case (_, .small): 1275        case (_, .regular): 1676        case (_, .large): 2277        }78    }7980    /// Point size of an SF Symbol inside a custom icon control.81    public func iconSize(_ size: GlassControlSize) -> Double {82        switch (platform, size) {83        case (.macOS, .small): 1284        case (.macOS, .regular): 1485        case (.macOS, .large): 1786        case (_, .small): 1587        case (_, .regular): 1888        case (_, .large): 2289        }90    }91}92
Files main
Menu

Theme