Skip to content
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

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

alixander
Copy link
Collaborator

@alixander alixander commented Dec 12, 2023

Before

Screen Shot 2023-12-10 at 10 05 07 AM

After

Screen Shot 2023-12-11 at 3 45 18 PM Screen Shot 2023-12-11 at 4 12 14 PM

closes #1558

@@ -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
Copy link
Collaborator Author

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

Copy link
Contributor

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

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

// special handling to start/end connections below label
if obj.HasOutsideBottomLabel() {
obj.Height -= float64(obj.LabelDimensions.Height) + label.PADDING
}

// special handling
if obj.HasOutsideBottomLabel() || obj.Icon != nil {
height += float64(obj.LabelDimensions.Height) + label.PADDING
}

d2/d2graph/layout.go

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the elk icon_positions test it appears this is unaccounted for prior to your PR, it also may not be accounted for in dagre if the label were inside

Screenshot 2023-12-11 at 5 38 05 PM

Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavin-ts
are you sure about the "these are no longer needed"? Many tests change when I remove those:

8ce19c5

Copy link
Collaborator Author

@alixander alixander Dec 12, 2023

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8ce19c5#r134821504

looks like we do want the || icon part for this
Screenshot 2023-12-12 at 10 46 19 AM

Copy link
Contributor

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

to avoid this
Screenshot 2023-12-12 at 10 49 31 AM

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

@alixander alixander requested a review from gavin-ts December 12, 2023 00:17
@alixander alixander marked this pull request as ready for review December 12, 2023 17:28
@alixander alixander merged commit da3fa94 into terrastruct:master Dec 12, 2023
3 checks passed
@alixander alixander deleted the sql_table_icon branch December 12, 2023 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

applying icon to sql_table makes it render differently
2 participants