Files
Kymo/kymo/UI/Components/DetailPlacement.swift
T
wangairnan 0c846a2127 feat(menubar): 实现趋势面板外侧详情与三语外观设置
接入有界趋势、平滑滚动、菜单式外侧详情、底部操作与三语文案,装配独立外观设置和 Dock 生命周期。
合并跟随系统外观刷新、自选颜色入口与色块绘制修复,保留用户确认的配色联动、重启保存及滚动验收。
多场景视觉与长期资源验证边界仍记录于 docs。
2026-10-30 00:45:34 +08:00

19 lines
775 B
Swift

import Foundation
import CoreGraphics
/// Screen coordinates: prefer the parent's right side, otherwise use its left.
nonisolated enum DetailPlacement {
static func frame(anchor: CGRect, parent: CGRect, content: CGSize, visible: CGRect) -> CGRect {
let gap: CGFloat = 4
let width = min(content.width, visible.width)
let height = min(content.height, visible.height)
let right = parent.maxX + gap
let left = parent.minX - gap - width
let candidate = right + width <= visible.maxX ? right : left
let x = max(visible.minX, min(candidate, visible.maxX - width))
let y = max(visible.minY, min(anchor.maxY - height, visible.maxY - height))
return CGRect(x: x, y: y, width: width, height: height)
}
}