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
|
||||
var views = [String: NSView]()
|
||||
var n = 0
|
||||
var firstStretchy = -1
|
||||
for c in self.controls {
|
||||
views["view\(n)"] = c.c.View()
|
||||
if firstStretchy == -1 && c.stretchy {
|
||||
firstStretchy = n
|
||||
}
|
||||
n++
|
||||
}
|
||||
|
||||
|
@ -104,7 +108,12 @@ class Box : NSView, Control {
|
|||
if self.padded && i != 0 {
|
||||
constraint += "-"
|
||||
}
|
||||
constraint += "[view\(i)]"
|
||||
constraint += "[view\(i)"
|
||||
// implement multiple stretchiness properly
|
||||
if self.controls[i].stretchy && i != firstStretchy {
|
||||
constraint += "(==view\(firstStretchy))"
|
||||
}
|
||||
constraint += "]"
|
||||
}
|
||||
constraint += "|"
|
||||
var constraints = mkconstraints(constraint, views)
|
||||
|
|
|
@ -16,7 +16,7 @@ func appLaunched() {
|
|||
var box = Box(vertical: firstvert, padded: spaced)
|
||||
mainwin.SetControl(box)
|
||||
|
||||
box.Add(Entry(), false)
|
||||
box.Add(Entry(), true)
|
||||
box.Add(Button("Button"), true)
|
||||
|
||||
mainwin.Show()
|
||||
|
|
Loading…
Reference in New Issue