forked from HEL/chronos
		
	added synched sequences
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							| @@ -49,3 +49,38 @@ | |||||||
|   _seq("Alice", "?", comment: [->?\ *short* from actor1]) |   _seq("Alice", "?", comment: [->?\ *short* from actor1]) | ||||||
|   _seq("Alice", "Bob", comment: [->\ from actor1 to actor2]) |   _seq("Alice", "Bob", comment: [->\ from actor1 to actor2]) | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | #chronos.diagram({ | ||||||
|  |   import chronos: * | ||||||
|  |   _par("alice", display-name: "Alice") | ||||||
|  |   _par("bob", display-name: "Bob") | ||||||
|  |   _par("craig", display-name: "Craig") | ||||||
|  |  | ||||||
|  |   _seq("bob", "alice") | ||||||
|  |   _seq("bob", "craig") | ||||||
|  |   _gap() | ||||||
|  |    | ||||||
|  |   _sync({ | ||||||
|  |     _seq("bob", "alice") | ||||||
|  |     _seq("bob", "craig") | ||||||
|  |   }) | ||||||
|  |   _gap() | ||||||
|  |    | ||||||
|  |   _seq("alice", "bob") | ||||||
|  |   _seq("craig", "bob") | ||||||
|  |   _gap() | ||||||
|  |    | ||||||
|  |   _sync({ | ||||||
|  |     _seq("alice", "bob") | ||||||
|  |     _seq("craig", "bob") | ||||||
|  |   }) | ||||||
|  |   _gap() | ||||||
|  |    | ||||||
|  |   _sync({ | ||||||
|  |     _seq("alice", "bob", enable-dst: true) | ||||||
|  |     _seq("craig", "bob") | ||||||
|  |   }) | ||||||
|  |   _gap() | ||||||
|  |  | ||||||
|  |   _evt("bob", "disable") | ||||||
|  | }) | ||||||
| @@ -5,3 +5,4 @@ | |||||||
| #import "participant.typ": _par | #import "participant.typ": _par | ||||||
| #import "separator.typ": _sep | #import "separator.typ": _sep | ||||||
| #import "note.typ": _note | #import "note.typ": _note | ||||||
|  | #import "sync.typ": _sync | ||||||
| @@ -5,6 +5,7 @@ | |||||||
| #import participant: PAR-SPECIALS | #import participant: PAR-SPECIALS | ||||||
| #import "sequence.typ" | #import "sequence.typ" | ||||||
| #import "separator.typ" | #import "separator.typ" | ||||||
|  | #import "sync.typ" | ||||||
| #import "consts.typ": * | #import "consts.typ": * | ||||||
| #import "note.typ" as note: get-note-box | #import "note.typ" as note: get-note-box | ||||||
|  |  | ||||||
| @@ -203,6 +204,7 @@ | |||||||
|   let draw-sep = separator.render.with(x-pos) |   let draw-sep = separator.render.with(x-pos) | ||||||
|   let draw-par = participant.render.with(x-pos) |   let draw-par = participant.render.with(x-pos) | ||||||
|   let draw-note = note.render.with(pars-i, x-pos) |   let draw-note = note.render.with(pars-i, x-pos) | ||||||
|  |   let draw-sync = sync.render.with(pars-i, x-pos, participants) | ||||||
|    |    | ||||||
|   // Draw participants (start) |   // Draw participants (start) | ||||||
|   for p in participants { |   for p in participants { | ||||||
| @@ -295,6 +297,12 @@ | |||||||
|         (y, shps) = draw-note(elmt, y, lifelines) |         (y, shps) = draw-note(elmt, y, lifelines) | ||||||
|         shapes += shps |         shapes += shps | ||||||
|       } |       } | ||||||
|  |  | ||||||
|  |     // Synched sequences | ||||||
|  |     } else if elmt.type == "sync" { | ||||||
|  |       let shps | ||||||
|  |       (y, lifelines, shps) = draw-sync(elmt, y, lifelines) | ||||||
|  |       shapes += shps | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								src/sync.typ
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/sync.typ
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | #import "sequence.typ" | ||||||
|  |  | ||||||
|  | #let _sync(elmts) = { | ||||||
|  |   return (( | ||||||
|  |     type: "sync", | ||||||
|  |     elmts: elmts | ||||||
|  |   ),) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #let render(pars-i, x-pos, participants, elmt, y, lifelines) = { | ||||||
|  |   let draw-seq = sequence.render.with(pars-i, x-pos, participants) | ||||||
|  |  | ||||||
|  |   let shapes = () | ||||||
|  |  | ||||||
|  |   let end-y = y | ||||||
|  |  | ||||||
|  |   for e in elmt.elmts { | ||||||
|  |     let yi | ||||||
|  |     let shps | ||||||
|  |     (yi, lifelines, shps) = draw-seq(e, y, lifelines) | ||||||
|  |     shapes += shps | ||||||
|  |     end-y = calc.min(end-y, yi) | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   let r = (end-y, lifelines, shapes) | ||||||
|  |   return r | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user