Mask only labels in sequence diagram groups
This commit is contained in:
parent
73f08a24a0
commit
358a53d815
5 changed files with 9 additions and 1 deletions
|
|
@ -127,6 +127,9 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape {
|
||||||
if obj.LabelPosition != nil {
|
if obj.LabelPosition != nil {
|
||||||
shape.LabelPosition = *obj.LabelPosition
|
shape.LabelPosition = *obj.LabelPosition
|
||||||
}
|
}
|
||||||
|
if obj.MaskLabel != nil {
|
||||||
|
shape.MaskLabel = *obj.MaskLabel
|
||||||
|
}
|
||||||
|
|
||||||
shape.Tooltip = obj.Attributes.Tooltip
|
shape.Tooltip = obj.Attributes.Tooltip
|
||||||
shape.Link = obj.Attributes.Link
|
shape.Link = obj.Attributes.Link
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ type Object struct {
|
||||||
References []Reference `json:"references,omitempty"`
|
References []Reference `json:"references,omitempty"`
|
||||||
|
|
||||||
*geo.Box `json:"box,omitempty"`
|
*geo.Box `json:"box,omitempty"`
|
||||||
|
MaskLabel *bool `json:"maskLabel,omitempty"`
|
||||||
LabelPosition *string `json:"labelPosition,omitempty"`
|
LabelPosition *string `json:"labelPosition,omitempty"`
|
||||||
LabelWidth *int `json:"labelWidth,omitempty"`
|
LabelWidth *int `json:"labelWidth,omitempty"`
|
||||||
LabelHeight *int `json:"labelHeight,omitempty"`
|
LabelHeight *int `json:"labelHeight,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,7 @@ func (sd *sequenceDiagram) placeGroups() {
|
||||||
})
|
})
|
||||||
for _, group := range sd.groups {
|
for _, group := range sd.groups {
|
||||||
group.ZIndex = GROUP_Z_INDEX
|
group.ZIndex = GROUP_Z_INDEX
|
||||||
|
group.MaskLabel = go2.Pointer(true)
|
||||||
sd.placeGroup(group)
|
sd.placeGroup(group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -782,9 +782,11 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string,
|
||||||
textStyle,
|
textStyle,
|
||||||
renderText(targetShape.Label, x, float64(targetShape.LabelHeight)),
|
renderText(targetShape.Label, x, float64(targetShape.LabelHeight)),
|
||||||
)
|
)
|
||||||
|
if targetShape.MaskLabel {
|
||||||
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING)
|
labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fmt.Fprintf(writer, `</g>`)
|
fmt.Fprintf(writer, `</g>`)
|
||||||
return labelMask, nil
|
return labelMask, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ type Shape struct {
|
||||||
Text
|
Text
|
||||||
|
|
||||||
LabelPosition string `json:"labelPosition,omitempty"`
|
LabelPosition string `json:"labelPosition,omitempty"`
|
||||||
|
MaskLabel bool `json:"maskLabel"`
|
||||||
|
|
||||||
ZIndex int `json:"zIndex"`
|
ZIndex int `json:"zIndex"`
|
||||||
Level int `json:"level"`
|
Level int `json:"level"`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue