feat(menubar): 支持固定居中面板与独立刷新频率及图表浮层
This commit is contained in:
@@ -3,12 +3,19 @@ import CoreGraphics
|
||||
|
||||
nonisolated enum PanelLayout {
|
||||
static func resourceRowHeight(size: CGSize) -> CGFloat { min(230, max(220, size.height - 590)) }
|
||||
static func firstRowWideCardWidth(size: CGSize) -> CGFloat { (size.width - 36 - resourceRowHeight(size: size)) / 2 }
|
||||
static func batteryWidth(size: CGSize) -> CGFloat { resourceRowHeight(size: size) * 4 / 3 }
|
||||
static func firstRowWideCardWidth(size: CGSize) -> CGFloat { (size.width - 36 - batteryWidth(size: size)) / 2 }
|
||||
|
||||
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 centeredFrame(_ frame: CGRect, visible: CGRect) -> CGRect {
|
||||
var result = constrainedFrame(frame, visible: visible)
|
||||
result.origin.x = visible.midX - result.width / 2
|
||||
return result
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user