Extract enforceConstraints from assignRows

This commit is contained in:
Ian Gulliver
2026-02-20 17:10:02 -07:00
parent 69402ea2e4
commit bd3dd1a43d

View File

@@ -225,34 +225,35 @@ func (tl *Timeline) buildConstraints() {
func (tl *Timeline) assignRows() { func (tl *Timeline) assignRows() {
for { for {
found := false if tl.enforceConstraints() {
continue
}
if tl.enforceExclusives() {
continue
}
break
}
}
func (tl *Timeline) enforceConstraints() bool {
for _, c := range tl.constraints { for _, c := range tl.constraints {
switch c.kind { switch c.kind {
case "same_row": case "same_row":
if c.a.row < c.b.row { if c.a.row < c.b.row {
tl.insertGap(c.a.track, c.a.row) tl.insertGap(c.a.track, c.a.row)
found = true return true
} else if c.b.row < c.a.row { } else if c.b.row < c.a.row {
tl.insertGap(c.b.track, c.b.row) tl.insertGap(c.b.track, c.b.row)
found = true return true
} }
case "next_row": case "next_row":
if c.b.row <= c.a.row { if c.b.row <= c.a.row {
tl.insertGap(c.b.track, c.b.row) tl.insertGap(c.b.track, c.b.row)
found = true return true
} }
} }
if found {
break
}
}
if !found {
found = tl.enforceExclusives()
}
if !found {
break
}
} }
return false
} }
func (tl *Timeline) enforceExclusives() bool { func (tl *Timeline) enforceExclusives() bool {