import CoreGraphics // ConstraintMath holds the pure math for the window constraint (spec 7.10). // The functions have no AppKit dependency. The unit tests cover the functions. // // Coordinate convention: Cocoa. The origin is bottom-left. The Y axis points // up. The window bottom is rect.minY. The window top is rect.maxY. limitY is // the strip top edge in Cocoa Y. This convention matches Sources/Util/Geometry.swift. enum ConstraintMath { // newHeight returns the new window height so the window bottom sits at // limitY. The function keeps the window top fixed. The function returns nil // if the window bottom is at limitY or above limitY. static func newHeight(windowCocoa: CGRect, limitY: CGFloat) -> CGFloat? { guard windowCocoa.minY < limitY else { return nil } return windowCocoa.maxY - limitY } // isIntentionalMoveDown returns true if the window top is also below // (limitY - 100). In this case the user moved the window down on purpose. // The service does nothing (spec 7.10, step 3). static func isIntentionalMoveDown(windowTopCocoa: CGFloat, limitY: CGFloat) -> Bool { return windowTopCocoa < (limitY - 100) } }