forked from HEL/chronos
		
	added lifeline-style
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| #import "@preview/cetz:0.2.2": canvas, draw | ||||
| #import "utils.typ": get-participants-i | ||||
| #import "utils.typ": get-participants-i, get-style | ||||
| #import "group.typ" | ||||
| #import "sequence.typ" | ||||
| #import "separator.typ" | ||||
| @@ -209,10 +209,12 @@ | ||||
|  | ||||
|       // Draw lifeline rectangles (reverse for bottom to top) | ||||
|       for rect in rects.rev() { | ||||
|         let (cx, y0, y1) = rect | ||||
|         let (cx, y0, y1, style) = rect | ||||
|         let style = get-style("lifeline", style) | ||||
|         draw.rect( | ||||
|           (cx - LIFELINE-W / 2, y0), | ||||
|           (cx + LIFELINE-W / 2, y1) | ||||
|           (cx + LIFELINE-W / 2, y1), | ||||
|           ..style | ||||
|         ) | ||||
|       } | ||||
|  | ||||
|   | ||||
| @@ -10,10 +10,12 @@ | ||||
|   color: black, | ||||
|   flip: false, | ||||
|   enable-dst: false, | ||||
|   create-dst: false, | ||||
|   disable-dst: false, | ||||
|   destroy-dst: false, | ||||
|   disable-src: false, | ||||
|   destroy-src: false, | ||||
|   lifeline-style: auto | ||||
| ) = { | ||||
|   return (( | ||||
|     type: "seq", | ||||
| @@ -25,10 +27,12 @@ | ||||
|     color: color, | ||||
|     flip: flip, | ||||
|     enable-dst: enable-dst, | ||||
|     create-dst: create-dst, | ||||
|     disable-dst: disable-dst, | ||||
|     destroy-dst: destroy-dst, | ||||
|     disable-src: disable-src, | ||||
|     destroy-src: destroy-src, | ||||
|     lifeline-style: lifeline-style, | ||||
|   ),) | ||||
| } | ||||
|  | ||||
| @@ -45,7 +49,7 @@ | ||||
|   if elmt.disable-src { | ||||
|     let src-line = lifelines.at(i1) | ||||
|     src-line.level -= 1 | ||||
|     src-line.lines.push(("disable", y, auto)) | ||||
|     src-line.lines.push(("disable", y)) | ||||
|     lifelines.at(i1) = src-line | ||||
|   } | ||||
|   if elmt.destroy-src { | ||||
| @@ -142,7 +146,12 @@ | ||||
|   } | ||||
|   if elmt.enable-dst { | ||||
|     let dst-line = lifelines.at(i2) | ||||
|     dst-line.lines.push(("enable", y, auto)) | ||||
|     dst-line.lines.push(("enable", y, elmt.lifeline-style)) | ||||
|     lifelines.at(i2) = dst-line | ||||
|   } | ||||
|   if elmt.create-dst { | ||||
|     let dst-line = lifelines.at(i2) | ||||
|     dst-line.lines.push(("create", y)) | ||||
|     lifelines.at(i2) = dst-line | ||||
|   } | ||||
|   y -= Y-SPACE | ||||
|   | ||||
| @@ -24,4 +24,20 @@ | ||||
|     } | ||||
|   } | ||||
|   return (min-i, max-i) | ||||
| } | ||||
|  | ||||
| #let get-style(base-name, mods) = { | ||||
|   let style = if base-name == "lifeline" {( | ||||
|     fill: white, | ||||
|     stroke: black + 1pt | ||||
|   )} | ||||
|  | ||||
|   if mods == auto { | ||||
|     return style | ||||
|   } | ||||
|   if type(mods) == dictionary { | ||||
|     return style + mods | ||||
|   } | ||||
|  | ||||
|   panic("Invalid type for parameter mods, expected auto or dictionary, got " + str(type(mods))) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user