Fixed many compiler errors.
This commit is contained in:
parent
de4156122f
commit
06f32ca759
|
@ -24,7 +24,7 @@ class tBox : tControl {
|
|||
|
||||
// TODO rename to padded
|
||||
init(vertical: Bool, spaced: Bool) {
|
||||
self.v = tBoxContainer(NSZeroRect)
|
||||
self.v = tBoxContainer(frame: NSZeroRect)
|
||||
self.v.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.children = []
|
||||
self.vertical = vertical
|
||||
|
@ -36,12 +36,11 @@ class tBox : tControl {
|
|||
c.tSetParent(self, addToView: self.v)
|
||||
self.children.append(tBoxChild(
|
||||
c: c,
|
||||
stretchy: stretchy,
|
||||
))
|
||||
stretchy: stretchy))
|
||||
self.tRelayout()
|
||||
}
|
||||
|
||||
func tSetParent(p: tControl, v addToView: NSView) {
|
||||
func tSetParent(p: tControl, addToView v: NSView) {
|
||||
self.parent = p
|
||||
v.addSubview(self.v)
|
||||
}
|
||||
|
@ -59,9 +58,9 @@ class tBox : tControl {
|
|||
|
||||
self.v.removeConstraints(self.v.constraints)
|
||||
|
||||
orientation = NSLayoutConstraintOrientationHorizontal
|
||||
orientation = NSLayoutConstraintOrientation.Horizontal
|
||||
if self.vertical {
|
||||
orientation = NSLayoutConstraintOrientationVertical
|
||||
orientation = NSLayoutConstraintOrientation.Vertical
|
||||
}
|
||||
|
||||
var views = [String: NSView]()
|
||||
|
@ -70,8 +69,8 @@ class tBox : tControl {
|
|||
for child in self.children {
|
||||
var priority: NSLayoutPriority
|
||||
|
||||
pp.nonStretchyWidthPredicate = @""
|
||||
pp.nonStretchyHeightPredicate = @""
|
||||
pp.nonStretchyWidthPredicate = ""
|
||||
pp.nonStretchyHeightPredicate = ""
|
||||
// this also resets the hugging priority
|
||||
// TODO do this when adding and removing controls instead
|
||||
child.c.tFillAutoLayout(pp)
|
||||
|
@ -84,7 +83,7 @@ class tBox : tControl {
|
|||
} else {
|
||||
predicates.append(pp.nonStretchyWidthPredicate)
|
||||
}
|
||||
pp.view.setContentHuggingPriority(priority, orientation:orientation)
|
||||
pp.view.setContentHuggingPriority(priority, forOrientation:orientation)
|
||||
views[tAutoLayoutKey(n)] = pp.view
|
||||
n++
|
||||
}
|
||||
|
@ -94,7 +93,7 @@ class tBox : tControl {
|
|||
if self.vertical {
|
||||
constraint = "V:"
|
||||
}
|
||||
var firstStretchy: true
|
||||
var firstStretchy = true
|
||||
for i = 0; i < n; i++ {
|
||||
if self.spaced && i != 0 {
|
||||
constraint += "-"
|
||||
|
@ -113,7 +112,7 @@ class tBox : tControl {
|
|||
constraint += "]"
|
||||
}
|
||||
constraint += "|"
|
||||
self.v.addConstraints(NSLayoutConstraint(
|
||||
self.v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat: constraint,
|
||||
options: 0,
|
||||
metrics: nil,
|
||||
|
@ -124,11 +123,11 @@ class tBox : tControl {
|
|||
// TODO make all of these the same width/height
|
||||
for i = 0; i < n; i++ {
|
||||
constraint = "V:|["
|
||||
if self->vertical {
|
||||
if self.vertical {
|
||||
constraint = "H:|["
|
||||
}
|
||||
constraint += tAutoLayoutKey(i) + "]|"
|
||||
self.v.addConstraints(NSLayoutConstraint(
|
||||
self.v.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat: constraint,
|
||||
options: 0,
|
||||
metrics: nil,
|
||||
|
@ -153,7 +152,7 @@ class tBox : tControl {
|
|||
}
|
||||
|
||||
func tRelayout() {
|
||||
if self->parent != nil {
|
||||
if self.parent != nil {
|
||||
self.parent.tRelayout()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,29 +7,29 @@ class tButton : tControl {
|
|||
private var horzpri, vertpri: NSLayoutPriority
|
||||
|
||||
init(text: String) {
|
||||
self.b = NSButton(NSZeroRect)
|
||||
self.b = NSButton(frame: NSZeroRect)
|
||||
self.b.title = text
|
||||
self.b.buttonType = NSMomentaryPushInButton
|
||||
self.b bordered = true
|
||||
self.b.bordered = true
|
||||
self.b.bezelStyle = NSRoundedBezelStyle
|
||||
self.b.font = NSFont.systemFontOfSize(NSFont.systemFontSizeForControlSize(NSRegularControlSize))
|
||||
self.b.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
self.parent = nil
|
||||
|
||||
self.horzpri = self.b.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationHorizontal)
|
||||
self.vertpri = self.b.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationVertical)
|
||||
self.horzpri = self.b.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Horizontal)
|
||||
self.vertpri = self.b.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Vertical)
|
||||
}
|
||||
|
||||
func tSetParent(p: tControl, v addToView: NSView) {
|
||||
func tSetParent(p: tControl, addToView v: NSView) {
|
||||
self.parent = p
|
||||
v.addSubview(self.b)
|
||||
}
|
||||
|
||||
func tFillAutoLayout:(p: tAutoLayoutParams) {
|
||||
func tFillAutoLayout(p: tAutoLayoutParams) {
|
||||
// reset the hugging priority
|
||||
self.b.setContentHuggingPriority(self.horzpri, orientation:NSLayoutConstraintOrientationHorizontal)
|
||||
self.b.setContentHuggingPriority(self.vertpri, orientation:NSLayoutConstraintOrientationVertical)
|
||||
self.b.setContentHuggingPriority(self.horzpri, forOrientation:NSLayoutConstraintOrientation.Horizontal)
|
||||
self.b.setContentHuggingPriority(self.vertpri, forOrientation:NSLayoutConstraintOrientation.Vertical)
|
||||
|
||||
p.view = self.b
|
||||
p.attachLeft = true
|
||||
|
@ -39,7 +39,7 @@ class tButton : tControl {
|
|||
}
|
||||
|
||||
func tRelayout() {
|
||||
if self->parent != nil {
|
||||
if self.parent != nil {
|
||||
self.parent.tRelayout()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class tEntry : tControl {
|
|||
private var horzpri, vertpri: NSLayoutPriority
|
||||
|
||||
init() {
|
||||
self.t = NSTextField(NSZeroRect)
|
||||
self.t = NSTextField(frame: NSZeroRect)
|
||||
self.t.selectable = true
|
||||
self.t.font = NSFont.systemFontOfSize(NSFont.systemFontSizeForControlSize(NSRegularControlSize))
|
||||
self.t.bordered = false
|
||||
|
@ -19,19 +19,19 @@ class tEntry : tControl {
|
|||
|
||||
self.parent = nil
|
||||
|
||||
self.horzpri = self.t.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationHorizontal)
|
||||
self.vertpri = self.t contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationVertical)
|
||||
self.horzpri = self.t.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Horizontal)
|
||||
self.vertpri = self.t.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Vertical)
|
||||
}
|
||||
|
||||
func tSetParent(p: tControl, v addToView: NSView) {
|
||||
func tSetParent(p: tControl, addToView v: NSView) {
|
||||
self.parent = p
|
||||
v.addSubview(self.t)
|
||||
}
|
||||
|
||||
func tFillAutoLayout:(p: tAutoLayoutParams) {
|
||||
func tFillAutoLayout(p: tAutoLayoutParams) {
|
||||
// reset the hugging priority
|
||||
self.t.setContentHuggingPriority(self.horzpri, orientation:NSLayoutConstraintOrientationHorizontal)
|
||||
self.t.setContentHuggingPriority(self.vertpri, orientation:NSLayoutConstraintOrientationVertical)
|
||||
self.t.setContentHuggingPriority(self.horzpri, forOrientation:NSLayoutConstraintOrientation.Horizontal)
|
||||
self.t.setContentHuggingPriority(self.vertpri, forOrientation:NSLayoutConstraintOrientation.Vertical)
|
||||
|
||||
p.view = self.t
|
||||
p.attachLeft = true
|
||||
|
@ -42,7 +42,7 @@ class tEntry : tControl {
|
|||
}
|
||||
|
||||
func tRelayout() {
|
||||
if self->parent != nil {
|
||||
if self.parent != nil {
|
||||
self.parent.tRelayout()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class tEntry : tControl {
|
|||
private var horzpri, vertpri: NSLayoutPriority
|
||||
|
||||
init() {
|
||||
self.t = NSTextField(NSZeroRect)
|
||||
self.t = NSTextField(frame: NSZeroRect)
|
||||
self.t.stringValue = "Label"
|
||||
self.t.setEditable = false
|
||||
self.t.selectable = false
|
||||
|
@ -22,19 +22,19 @@ class tEntry : tControl {
|
|||
|
||||
self.parent = nil
|
||||
|
||||
self.horzpri = self.t.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationHorizontal)
|
||||
self.vertpri = self.t contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationVertical)
|
||||
self.horzpri = self.t.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Horizontal)
|
||||
self.vertpri = self.t.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Vertical)
|
||||
}
|
||||
|
||||
func tSetParent(p: tControl, v addToView: NSView) {
|
||||
func tSetParent(p: tControl, addToView v: NSView) {
|
||||
self.parent = p
|
||||
v.addSubview(self.t)
|
||||
}
|
||||
|
||||
func tFillAutoLayout:(p: tAutoLayoutParams) {
|
||||
func tFillAutoLayout(p: tAutoLayoutParams) {
|
||||
// reset the hugging priority
|
||||
self.t.setContentHuggingPriority(self.horzpri, orientation:NSLayoutConstraintOrientationHorizontal)
|
||||
self.t.setContentHuggingPriority(self.vertpri, orientation:NSLayoutConstraintOrientationVertical)
|
||||
self.t.setContentHuggingPriority(self.horzpri, forOrientation:NSLayoutConstraintOrientation.Horizontal)
|
||||
self.t.setContentHuggingPriority(self.vertpri, forOrientation:NSLayoutConstraintOrientation.Vertical)
|
||||
|
||||
p.view = self.t
|
||||
p.attachLeft = true
|
||||
|
@ -44,7 +44,7 @@ class tEntry : tControl {
|
|||
}
|
||||
|
||||
func tRelayout() {
|
||||
if self->parent != nil {
|
||||
if self.parent != nil {
|
||||
self.parent.tRelayout()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ class tSpinbox : tControl {
|
|||
private var horzpri, vertpri: NSLayoutPriority
|
||||
|
||||
init() {
|
||||
self.c = tSpinboxContainer(NSZeroRect)
|
||||
self.c = tSpinboxContainer(frame: NSZeroRect)
|
||||
self.c.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
self.t = NSTextField(NSZeroRect)
|
||||
self.t = NSTextField(frame: NSZeroRect)
|
||||
self.t.stringValue = "\(nspinbox)"
|
||||
nspinbox++
|
||||
self.t.selectable = true
|
||||
|
@ -36,8 +36,8 @@ nspinbox++
|
|||
|
||||
self.s = NSStepper(NSZeroFrame)
|
||||
self.s.increment = 1
|
||||
self.s valueWraps = false
|
||||
self.s autorepeat = true
|
||||
self.s.valueWraps = false
|
||||
self.s.autorepeat = true
|
||||
self.s.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.c.addSubview(self.s)
|
||||
|
||||
|
@ -45,19 +45,19 @@ nspinbox++
|
|||
"t": self.t,
|
||||
"s": self.s,
|
||||
]
|
||||
var constraints = NSLayoutConstraint(
|
||||
var constraints = NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat: "H:|[t]-[s]|",
|
||||
options: 0,
|
||||
metrics: nil,
|
||||
views: views)
|
||||
self.c.addConstraints(constraints)
|
||||
constraints = NSLayoutConstraint(
|
||||
constraints = NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat: "V:|[t]|",
|
||||
options: 0,
|
||||
metrics: nil,
|
||||
views: views)
|
||||
self.c.addConstraints(constraints)
|
||||
constraints = NSLayoutConstraint(
|
||||
constraints = NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat: "V:|[s]|",
|
||||
options: 0,
|
||||
metrics: nil,
|
||||
|
@ -66,19 +66,19 @@ nspinbox++
|
|||
|
||||
self.parent = nil
|
||||
|
||||
self.horzpri = self.c.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationHorizontal)
|
||||
self.vertpri = self.c contentHuggingPriorityForOrientation(NSLayoutConstraintOrientationVertical)
|
||||
self.horzpri = self.c.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Horizontal)
|
||||
self.vertpri = self.c.contentHuggingPriorityForOrientation(NSLayoutConstraintOrientation.Vertical)
|
||||
}
|
||||
|
||||
func tSetParent(p: tControl, v addToView: NSView) {
|
||||
func tSetParent(p: tControl, addToView v: NSView) {
|
||||
self.parent = p
|
||||
v.addSubview(self.c)
|
||||
}
|
||||
|
||||
func tFillAutoLayout:(p: tAutoLayoutParams) {
|
||||
func tFillAutoLayout(p: tAutoLayoutParams) {
|
||||
// reset the hugging priority
|
||||
self.c.setContentHuggingPriority(self.horzpri, orientation:NSLayoutConstraintOrientationHorizontal)
|
||||
self.c.setContentHuggingPriority(self.vertpri, orientation:NSLayoutConstraintOrientationVertical)
|
||||
self.c.setContentHuggingPriority(self.horzpri, forOrientation:NSLayoutConstraintOrientation.Horizontal)
|
||||
self.c.setContentHuggingPriority(self.vertpri, forOrientation:NSLayoutConstraintOrientation.Vertical)
|
||||
|
||||
p.view = self.c
|
||||
p.attachLeft = true
|
||||
|
@ -89,7 +89,7 @@ nspinbox++
|
|||
}
|
||||
|
||||
func tRelayout() {
|
||||
if self->parent != nil {
|
||||
if self.parent != nil {
|
||||
self.parent.tRelayout()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class tWindow : tControl {
|
|||
if p.attachRight {
|
||||
constraint += margin + "|"
|
||||
}
|
||||
var constraints = NSLayoutConstraint(
|
||||
var constraints = NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat:constraint,
|
||||
options:0,
|
||||
metrics:nil,
|
||||
|
@ -98,7 +98,7 @@ class tWindow : tControl {
|
|||
if p.attachBottom {
|
||||
constraint += margin + "|"
|
||||
}
|
||||
constraints = NSLayoutConstraint(
|
||||
constraints = NSLayoutConstraint.constraintsWithVisualFormat(
|
||||
visualFormat:constraint,
|
||||
options:0,
|
||||
metrics:nil,
|
||||
|
|
Loading…
Reference in New Issue