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