elk label height

This commit is contained in:
Alexander Wang 2023-12-12 09:43:12 -08:00 committed by Gavin Nishizawa
parent 4bc18d7152
commit 018b0d4fa0
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
3 changed files with 304 additions and 297 deletions

View file

@ -374,11 +374,18 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err
if hasTop || hasBottom { if hasTop || hasBottom {
padding := parsePadding(elkNodes[obj].LayoutOptions.Padding) padding := parsePadding(elkNodes[obj].LayoutOptions.Padding)
if hasTop { if hasTop {
// TODO I think this fails to account for a potential inner label of container ownLabelHeight := 0
padding.top = go2.Max(padding.top, d2target.MAX_ICON_SIZE+2*label.PADDING) if obj.LabelPosition != nil && strings.HasPrefix(*obj.LabelPosition, "INSIDE_TOP") {
ownLabelHeight = obj.LabelDimensions.Height + label.PADDING
}
padding.top = go2.Max(padding.top, d2target.MAX_ICON_SIZE+2*label.PADDING+ownLabelHeight)
} }
if hasBottom { if hasBottom {
padding.bottom = go2.Max(padding.bottom, d2target.MAX_ICON_SIZE+2*label.PADDING) ownLabelHeight := 0
if obj.LabelPosition != nil && strings.HasPrefix(*obj.LabelPosition, "INSIDE_BOTTOM") {
ownLabelHeight = obj.LabelDimensions.Height + label.PADDING
}
padding.bottom = go2.Max(padding.bottom, d2target.MAX_ICON_SIZE+2*label.PADDING+ownLabelHeight)
} }
elkNodes[obj].LayoutOptions.Padding = padding.String() elkNodes[obj].LayoutOptions.Padding = padding.String()
} }

View file

@ -253,7 +253,7 @@
"y": 330 "y": 330
}, },
"width": 972, "width": 972,
"height": 262, "height": 303,
"opacity": 1, "opacity": 1,
"strokeDash": 0, "strokeDash": 0,
"strokeWidth": 2, "strokeWidth": 2,
@ -291,7 +291,7 @@
"type": "sql_table", "type": "sql_table",
"pos": { "pos": {
"x": 62, "x": 62,
"y": 404 "y": 445
}, },
"width": 106, "width": 106,
"height": 72, "height": 72,
@ -375,7 +375,7 @@
"type": "class", "type": "class",
"pos": { "pos": {
"x": 188, "x": 188,
"y": 404 "y": 445
}, },
"width": 204, "width": 204,
"height": 138, "height": 138,
@ -436,7 +436,7 @@
"type": "code", "type": "code",
"pos": { "pos": {
"x": 412, "x": 412,
"y": 404 "y": 445
}, },
"width": 74, "width": 74,
"height": 37, "height": 37,
@ -488,7 +488,7 @@
"type": "text", "type": "text",
"pos": { "pos": {
"x": 506, "x": 506,
"y": 404 "y": 445
}, },
"width": 428, "width": 428,
"height": 91, "height": 91,
@ -567,7 +567,7 @@
}, },
{ {
"x": 115, "x": 115,
"y": 404 "y": 445
} }
], ],
"animated": false, "animated": false,
@ -605,7 +605,7 @@
}, },
{ {
"x": 290, "x": 290,
"y": 404 "y": 445
} }
], ],
"animated": false, "animated": false,
@ -643,7 +643,7 @@
}, },
{ {
"x": 449, "x": 449,
"y": 404 "y": 445
} }
], ],
"animated": false, "animated": false,
@ -681,7 +681,7 @@
}, },
{ {
"x": 720, "x": 720,
"y": 404 "y": 445
} }
], ],
"animated": false, "animated": false,

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB