Implemented multiple stretchy controls.
This commit is contained in:
parent
48e1ccdb10
commit
64dedfe540
|
@ -92,8 +92,12 @@ class Box : NSView, Control {
|
||||||
// first collect the views
|
// first collect the views
|
||||||
var views = [String: NSView]()
|
var views = [String: NSView]()
|
||||||
var n = 0
|
var n = 0
|
||||||
|
var firstStretchy = -1
|
||||||
for c in self.controls {
|
for c in self.controls {
|
||||||
views["view\(n)"] = c.c.View()
|
views["view\(n)"] = c.c.View()
|
||||||
|
if firstStretchy == -1 && c.stretchy {
|
||||||
|
firstStretchy = n
|
||||||
|
}
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +108,12 @@ class Box : NSView, Control {
|
||||||
if self.padded && i != 0 {
|
if self.padded && i != 0 {
|
||||||
constraint += "-"
|
constraint += "-"
|
||||||
}
|
}
|
||||||
constraint += "[view\(i)]"
|
constraint += "[view\(i)"
|
||||||
|
// implement multiple stretchiness properly
|
||||||
|
if self.controls[i].stretchy && i != firstStretchy {
|
||||||
|
constraint += "(==view\(firstStretchy))"
|
||||||
|
}
|
||||||
|
constraint += "]"
|
||||||
}
|
}
|
||||||
constraint += "|"
|
constraint += "|"
|
||||||
var constraints = mkconstraints(constraint, views)
|
var constraints = mkconstraints(constraint, views)
|
||||||
|
|
|
@ -16,7 +16,7 @@ func appLaunched() {
|
||||||
var box = Box(vertical: firstvert, padded: spaced)
|
var box = Box(vertical: firstvert, padded: spaced)
|
||||||
mainwin.SetControl(box)
|
mainwin.SetControl(box)
|
||||||
|
|
||||||
box.Add(Entry(), false)
|
box.Add(Entry(), true)
|
||||||
box.Add(Button("Button"), true)
|
box.Add(Button("Button"), true)
|
||||||
|
|
||||||
mainwin.Show()
|
mainwin.Show()
|
||||||
|
|
Loading…
Reference in New Issue