Extract enforceConstraints from assignRows
This commit is contained in:
@@ -225,34 +225,35 @@ func (tl *Timeline) buildConstraints() {
|
||||
|
||||
func (tl *Timeline) assignRows() {
|
||||
for {
|
||||
found := false
|
||||
if tl.enforceConstraints() {
|
||||
continue
|
||||
}
|
||||
if tl.enforceExclusives() {
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func (tl *Timeline) enforceConstraints() bool {
|
||||
for _, c := range tl.constraints {
|
||||
switch c.kind {
|
||||
case "same_row":
|
||||
if c.a.row < c.b.row {
|
||||
tl.insertGap(c.a.track, c.a.row)
|
||||
found = true
|
||||
return true
|
||||
} else if c.b.row < c.a.row {
|
||||
tl.insertGap(c.b.track, c.b.row)
|
||||
found = true
|
||||
return true
|
||||
}
|
||||
case "next_row":
|
||||
if c.b.row <= c.a.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 {
|
||||
|
||||
Reference in New Issue
Block a user