2015-08-06 21:38:39 -05:00
|
|
|
// 31 july 2015
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
// TODO stretchy across both dimensions
|
|
|
|
// for a vertical box, the horizontal width should be variable
|
2015-08-07 13:45:01 -05:00
|
|
|
struct tAutoLayoutParams {
|
|
|
|
var view: NSView? = nil
|
|
|
|
var attachLeft: Bool = false
|
|
|
|
var attachTop: Bool = false
|
|
|
|
var attachRight: Bool = false
|
|
|
|
var attachBottom: Bool = false
|
|
|
|
var nonStretchyWidthPredicate: String = ""
|
|
|
|
var nonStretchyHeightPredicate: String = ""
|
2015-08-06 21:38:39 -05:00
|
|
|
}
|
|
|
|
|
2015-08-07 13:45:01 -05:00
|
|
|
protocol tControl : class {
|
|
|
|
func tSetParent(p: tControl, addToView: NSView)
|
|
|
|
func tFillAutoLayout(inout p: tAutoLayoutParams)
|
|
|
|
func tRelayout()
|
2015-08-06 21:38:39 -05:00
|
|
|
}
|
|
|
|
|
2015-08-07 00:11:55 -05:00
|
|
|
func tAutoLayoutKey(n: UIntMax) -> String {
|
2015-08-07 13:45:01 -05:00
|
|
|
return NSString(format: "view%d", n) as String
|
2015-08-06 21:38:39 -05:00
|
|
|
}
|
2015-08-07 15:24:15 -05:00
|
|
|
|
|
|
|
func mkconstraints(constraint: String, views: [String: NSView]) -> [AnyObject] {
|
|
|
|
println("making constraint \(constraint)")
|
|
|
|
return NSLayoutConstraint.constraintsWithVisualFormat(
|
|
|
|
constraint,
|
|
|
|
options: NSLayoutFormatOptions(0),
|
|
|
|
metrics: nil,
|
|
|
|
views: views)
|
|
|
|
}
|