forked from HEL/chronos
		
	implemented aligned notes
This commit is contained in:
		| @@ -65,23 +65,36 @@ | ||||
|      | ||||
|     } else if elmt.type == "note" { | ||||
|       let (p1, p2) = (none, none) | ||||
|       let cell = none | ||||
|       if elmt.side == "left" { | ||||
|         p1 = "[" | ||||
|         p2 = elmt.pos | ||||
|         cell = get-note-box(elmt) | ||||
|       } else if elmt.side == "right" { | ||||
|         p1 = elmt.pos | ||||
|         p2 = "]" | ||||
|         cell = get-note-box(elmt) | ||||
|       } else if elmt.side == "over" { | ||||
|         if elmt.aligned-with != none { | ||||
|           let box1 = get-note-box(elmt) | ||||
|           let box2 = get-note-box(elmt.aligned-with) | ||||
|           let m1 = measure(box1) | ||||
|           let m2 = measure(box2) | ||||
|           cell = box(width: (m1.width + m2.width) / 2, height: calc.max(m1.height, m2.height)) | ||||
|           p1 = elmt.pos | ||||
|           p2 = elmt.aligned-with.pos | ||||
|         } | ||||
|       } | ||||
|  | ||||
|       if p1 != none and p2 != none { | ||||
|       if p1 != none and p2 != none and cell != none { | ||||
|         let i1 = pars-i.at(p1) | ||||
|         let i2 = pars-i.at(p2) | ||||
|         cells.push( | ||||
|           ( | ||||
|             elmt: elmt, | ||||
|             i1: i1, | ||||
|             i2: i2, | ||||
|             cell: get-note-box(elmt) | ||||
|             i1: calc.min(i1, i2), | ||||
|             i2: calc.max(i1, i2), | ||||
|             cell: cell | ||||
|           ) | ||||
|         ) | ||||
|       } | ||||
| @@ -101,6 +114,28 @@ | ||||
|     widths.push(w1 / 2pt + w2 / 2pt + PAR-SPACE) | ||||
|   } | ||||
|  | ||||
|   // Compute minimum width for over notes | ||||
|   for n in elements.filter(e => (e.type == "note" and | ||||
|                                  e.side == "over" and  | ||||
|                                  type(e.pos) == str)) { | ||||
|      | ||||
|     let m = note.get-size(n) | ||||
|     let i = pars-i.at(n.pos) | ||||
|  | ||||
|     if i < widths.len() { | ||||
|       widths.at(i) = calc.max( | ||||
|         widths.at(i), | ||||
|         m.width / 2 + NOTE-GAP | ||||
|       ) | ||||
|     } | ||||
|     if i > 0 { | ||||
|       widths.at(i - 1) = calc.max( | ||||
|         widths.at(i - 1), | ||||
|         m.width / 2 + NOTE-GAP | ||||
|       ) | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Compute minimum width for simple sequences (spanning 1 column) | ||||
|   for cell in cells.filter(c => c.i2 - c.i1 == 1) { | ||||
|     let m = measure(cell.cell) | ||||
| @@ -111,7 +146,7 @@ | ||||
|   } | ||||
|  | ||||
|   // Compute minimum width for self sequences | ||||
|   for cell in cells.filter(c => c.i1 == c.i2) { | ||||
|   for cell in cells.filter(c => c.elmt.type == "seq" and c.i1 == c.i2) { | ||||
|     let m = measure(cell.cell) | ||||
|     let i = cell.i1 | ||||
|     if cell.elmt.flip { | ||||
| @@ -252,7 +287,9 @@ | ||||
|     // Note | ||||
|     } else if elmt.type == "note" { | ||||
|       if not elmt.linked { | ||||
|         y -= Y-SPACE | ||||
|         if not elmt.aligned { | ||||
|           y -= Y-SPACE | ||||
|         } | ||||
|         let shps | ||||
|         (y, shps) = draw-note(elmt, y, lifelines) | ||||
|         shapes += shps | ||||
|   | ||||
		Reference in New Issue
	
	Block a user