-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow icon for sql_table, class, code/md #1774
Conversation
@@ -374,6 +374,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err | |||
if hasTop || hasBottom { | |||
padding := parsePadding(elkNodes[obj].LayoutOptions.Padding) | |||
if hasTop { | |||
// TODO I think this fails to account for a potential inner label of container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gavin-ts there is currently a collision between the icon and label in ELK. I believe it's unrelated to my change and that this code has a bug as described. Can you confirm if so or if I'm just missing something.
![Screen Shot 2023-12-11 at 4 16 05 PM](https://private-user-images.githubusercontent.com/3120367/289706082-b9032857-c15b-41dd-b8e3-92d2fbbc6a10.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NDkxMTksIm5iZiI6MTczOTU0ODgxOSwicGF0aCI6Ii8zMTIwMzY3LzI4OTcwNjA4Mi1iOTAzMjg1Ny1jMTViLTQxZGQtYjhlMy05MmQyZmJiYzZhMTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMTYwMDE5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzA5Y2UxYTk5NGU0ODA3NTRiOTIzZmM2NmM3NDEyNTk4YTQxNmQzM2Y5ZDg4MmRiYzQ5OWJmMjQxMjBlMmU1OSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.-EsnyXKjZVlnIhpqmRbj9j3MkYL0P_21YCcAfAnPbiE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it looks like elk hasn't been updated for this. previously all icon positions would be placed in an inside position by default so this would only be possible with custom set positions.
not sure why but elk only seems to be adjusting horizontally for icons but not vertically
d2/d2layouts/d2elklayout/layout.go
Lines 1125 to 1131 in 56a549d
switch position { | |
case label.OutsideLeftTop, label.OutsideLeftMiddle, label.OutsideLeftBottom, | |
label.OutsideRightTop, label.OutsideRightMiddle, label.OutsideRightBottom: | |
width += d2target.MAX_ICON_SIZE + label.PADDING | |
default: | |
width = go2.Max(width, d2target.MAX_ICON_SIZE+2*label.PADDING) | |
} |
also noticed elk layout is still doing some old height manipulations but we already look for intersections with outside labels so these are no longer needed
d2/d2layouts/d2elklayout/layout.go
Lines 1184 to 1187 in 56a549d
// special handling to start/end connections below label | |
if obj.HasOutsideBottomLabel() { | |
obj.Height -= float64(obj.LabelDimensions.Height) + label.PADDING | |
} |
d2/d2layouts/d2elklayout/layout.go
Lines 1112 to 1115 in 56a549d
// special handling | |
if obj.HasOutsideBottomLabel() || obj.Icon != nil { | |
height += float64(obj.LabelDimensions.Height) + label.PADDING | |
} |
Lines 439 to 445 in 56a549d
if intersections := labelBox.Intersections(startingSegment); len(intersections) > 0 { | |
overlapsOutsideLabel = true | |
p := intersections[0] | |
if len(intersections) > 1 { | |
p = findOuterIntersection(labelPosition, intersections) | |
} | |
// move starting segment to label intersection point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, i'll get in followup then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i reverted that file, there's still changes: 705225e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may actually want this adjustment for all outside labels/icons unless we adjust the spacing in another way
8ce19c5#r134822027
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this captured in #1776 or can you make another issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this is captured in #1776, all margins are now included in the width/height passed to elk, so elk ends up routing the edge distance to shape + margin, instead of routing to shape then cutting at margin.
6b1b985
to
5cdeca3
Compare
Before
After
closes #1558