feat(menubar): 实现统一资源面板与独立滚动进程表
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import Foundation
|
||||
import CoreGraphics
|
||||
|
||||
nonisolated enum PanelLayout {
|
||||
static func contentSize(visible: CGRect, chrome: CGSize = .zero) -> CGSize {
|
||||
CGSize(width: max(1, min(1240, visible.width - 32 - max(0, chrome.width))),
|
||||
height: max(1, min(820, visible.height - 32 - max(0, chrome.height))))
|
||||
}
|
||||
static func constrainedFrame(_ frame: CGRect, visible: CGRect) -> CGRect {
|
||||
let safe = visible.insetBy(dx: 16, dy: 16)
|
||||
let width = min(frame.width, safe.width), height = min(frame.height, safe.height)
|
||||
return CGRect(x: min(max(frame.minX, safe.minX), safe.maxX - width),
|
||||
y: min(max(frame.minY, safe.minY), safe.maxY - height), width: width, height: height)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user