Mask only labels in sequence diagram groups

This commit is contained in:
Júlio César Batista 2022-12-05 13:32:33 -08:00
parent 73f08a24a0
commit 358a53d815
No known key found for this signature in database
GPG key ID: 10C4B861BF314878
5 changed files with 9 additions and 1 deletions

View file

@ -127,6 +127,9 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape {
if obj.LabelPosition != nil {
shape.LabelPosition = *obj.LabelPosition
}
if obj.MaskLabel != nil {
shape.MaskLabel = *obj.MaskLabel
}
shape.Tooltip = obj.Attributes.Tooltip
shape.Link = obj.Attributes.Link

View file

@ -69,6 +69,7 @@ type Object struct {
References []Reference `json:"references,omitempty"`
*geo.Box `json:"box,omitempty"`
MaskLabel *bool `json:"maskLabel,omitempty"`
LabelPosition *string `json:"labelPosition,omitempty"`
LabelWidth *int `json:"labelWidth,omitempty"`
LabelHeight *int `json:"labelHeight,omitempty"`

View file

@ -198,6 +198,7 @@ func (sd *sequenceDiagram) placeGroups() {
})
for _, group := range sd.groups {
group.ZIndex = GROUP_Z_INDEX
group.MaskLabel = go2.Pointer(true)
sd.placeGroup(group)
}
}

View file

@ -782,7 +782,9 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string,
textStyle,
renderText(targetShape.Label, x, float64(targetShape.LabelHeight)),
)
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING)
if targetShape.MaskLabel {
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING)
}
}
}
fmt.Fprintf(writer, `</g>`)

View file

@ -121,6 +121,7 @@ type Shape struct {
Text
LabelPosition string `json:"labelPosition,omitempty"`
MaskLabel bool `json:"maskLabel"`
ZIndex int `json:"zIndex"`
Level int `json:"level"`