Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import AppKitimport QuartzCore
@MainActorfinal class DragLayoutTargetLayer { let outline = OverlayLayerAllocation.makeShape() let selection = OverlayLayerAllocation.makeShape() let badge: DragLayoutBadge
init(parent: CALayer) { parent.addSublayer(outline) outline.addSublayer(selection) badge = DragLayoutBadge(parent: outline) }
func update( frame: CGRect, label: String?, selected: Bool, scale: CGFloat, palette: OverlayPalette, accessibility: OverlayAccessibility ) { outline.frame = frame let width: CGFloat = accessibility.increaseContrast ? 3 : 2 let inset = width / 2 + 1 / scale let bounds = outline.bounds.insetBy(dx: inset, dy: inset) outline.path = CGPath(roundedRect: bounds, cornerWidth: 10, cornerHeight: 10, transform: nil) outline.strokeColor = label == nil ? palette.activeBorder : palette.chipText outline.fillColor = nil outline.lineWidth = label == nil ? 1 : width outline.lineCap = .round outline.lineDashPattern = label == nil ? nil : [0, 6] outline.contentsScale = scale selection.frame = outline.bounds selection.path = CGPath( roundedRect: bounds.insetBy(dx: 5, dy: 5), cornerWidth: 6, cornerHeight: 6, transform: nil) selection.fillColor = nil selection.strokeColor = palette.chipText selection.lineWidth = width selection.contentsScale = scale selection.isHidden = !selected badge.background.isHidden = label == nil if let label { badge.update( label: label, center: CGPoint(x: outline.bounds.midX, y: outline.bounds.midY), available: frame.size, scale: scale, selected: selected, palette: palette) } }}