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

Near keys for container #1071

Merged
merged 45 commits into from
Apr 7, 2023

Conversation

ShupingHe
Copy link
Contributor

@ShupingHe ShupingHe commented Mar 21, 2023

#848

now descendants are allowed for contianer with near attribute

the screenshot can be generated by run script:

./ci/e2ereport.sh -test-case=near_keys_for_container

image

@ShupingHe
Copy link
Contributor Author

// These shapes skipped core layout, which means they also skipped label placements
for _, obj := range constantNears {
if obj.HasOutsideBottomLabel() {
obj.LabelPosition = go2.Pointer(string(label.OutsideBottomCenter))
} else if obj.Attributes.Icon != nil {
obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter))
} else {
obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter))
}
}

@alixander these codes that set labelPosition of near shape should be removed once we allow descendant, but if outside label is allowed, does that mean these containers should also be included during the core layout? we shouldn't let label position affect the main layout

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

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

👏 amazing

d2compiler/compile_test.go Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2lib/d2.go Outdated Show resolved Hide resolved
e2etests/stable_test.go Show resolved Hide resolved
@alixander
Copy link
Collaborator

these codes that set labelPosition of near shape should be removed once we allow descendant, but if outside label is allowed, does that mean these containers should also be included during the core layout? we shouldn't let label position affect the main layout

why should it be removed? we need to place the labels somewhere. maybe we could place it depending on direction, so that it'll never collide with core layout. e.g. the top-x near objects get labels placed on outside_top, the bottom-x objects get labels to outside_bottom, etc

@ShupingHe ShupingHe force-pushed the near-keys-for-container branch 2 times, most recently from fdc91e7 to f69ec48 Compare March 23, 2023 04:40
@alixander
Copy link
Collaborator

@donglixiaoche

well, i may misunderstood a little bit, but after run core layout for every near container, the label placement of near container will still be skipped? what i thought is now descendant is allowed, so the label may be placed outside, so i need to consider the dimension of label as well when put these near container inside main layout

actually... i think you're right. if you run core layout on the near object, the label placement should happen too.

ohh and so what you're calculating now is this new x, y right? the position considering the label, otherwise, the label might collide with the main diagram?

Screen Shot 2023-03-22 at 10 15 52 PM

@ShupingHe
Copy link
Contributor Author

ShupingHe commented Mar 23, 2023

@donglixiaoche

well, i may misunderstood a little bit, but after run core layout for every near container, the label placement of near container will still be skipped? what i thought is now descendant is allowed, so the label may be placed outside, so i need to consider the dimension of label as well when put these near container inside main layout

actually... i think you're right. if you run core layout on the near object, the label placement should happen too.

ohh and so what you're calculating now is this new x, y right? the position considering the label, otherwise, the label might collide with the main diagram?

Screen Shot 2023-03-22 at 10 15 52 PM

yep, that's what i tried to do, but i found there are still some little bugs to fix, working on it, sorry for deleted comments 🤣

@ShupingHe
Copy link
Contributor Author

@alixander one thing to confirm, for this line

tl, br := boundingBox(obj.Graph)

tl will always be (0, 0) right? any exceptions?

@alixander
Copy link
Collaborator

@donglixiaoche no. i can't remember what the exceptions were, but it can't be assumed to always be 0, 0

@ShupingHe
Copy link
Contributor Author

@alixander you can now continue the code review process

e2etests/stable_test.go Outdated Show resolved Hide resolved
d2lib/d2.go Outdated Show resolved Hide resolved
d2graph/d2graph.go Outdated Show resolved Hide resolved
@ShupingHe ShupingHe force-pushed the near-keys-for-container branch from 5cb285a to 849b117 Compare March 24, 2023 18:29
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

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

can you add this test? label still off. (got it from an issue with the motivating use case for this feature: #1001 )

direction: right

x -> y: {
  style.stroke: green
}

y -> z: {
  style.stroke: red
}

legend: {
  near: bottom-center
  color1: foo {
    shape: text
    style.font-color: green
  }

  color2: bar {
    shape: text
    style.font-color: red
  }
}

Screen Shot 2023-03-26 at 8 45 28 PM

d2compiler/compile.go Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
@ShupingHe
Copy link
Contributor Author

@alixander seems like there are some conflicts, what is the correct way to resolve them? how about i just use these files from master branh, and then rerun TA=1 ./ci/test.sh?

yeah exactly, what i do is just accept all conflicts without modifying, and then regenerate after

confilcts resolved by run git merge -x theirs master and then run TA=1 ./ci/test.sh

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

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

apologies for how long my reviews have taken @donglixiaoche . this is really good and i'm excited about this. tested locally across all the layout engine and works beautifully

d2compiler/compile.go Show resolved Hide resolved
d2graph/d2graph.go Outdated Show resolved Hide resolved
d2graph/d2graph.go Outdated Show resolved Hide resolved
d2lib/d2.go Outdated Show resolved Hide resolved
d2lib/d2.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Show resolved Hide resolved
d2layouts/d2near/layout.go Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
@ShupingHe
Copy link
Contributor Author

@alixander no worries, actually i'm on vacation right now. and i know i could do better about the details. and i'd love to pick another hard one, do you got one for me?

@alixander
Copy link
Collaborator

alixander commented Apr 3, 2023

@donglixiaoche nice! where are you vacationing?

Does this sound interesting? #1107

  • One of the biggest improvements in D2 0.3 was that font sizes got "subset", meaning reduced to only include the characters needed for them. but we don't split by styles. so the letter "b" may be used for italic, but we'll include it for regular and bold fonts as well. theoretically this should be another significant decrease in file size if we can further optimize by style.

Or if you want to stick to rendering stuff, this one could result in some big layout improvements: #1031

Feel free to say "pass" and I'm more than happy to find more!

@ShupingHe
Copy link
Contributor Author

@alixander haha, i'm now in Tibet watching those big views.

and #1107 sounds interesting, want to do some optimizations about font size 🙋🏻‍♂️

@alixander
Copy link
Collaborator

Nice! Definitely hope to go someday.

Could you please leave a comment in that issue? Just a "." or anything will do, GitHub won't let me assign otherwise

ci/release/changelogs/next.md Outdated Show resolved Hide resolved
d2compiler/compile.go Outdated Show resolved Hide resolved
d2graph/d2graph.go Outdated Show resolved Hide resolved
d2lib/d2.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
d2layouts/d2near/layout.go Show resolved Hide resolved
d2layouts/d2near/layout.go Show resolved Hide resolved
d2layouts/d2near/layout.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

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

beautiful! 💯

is this good to go for merging?

@ShupingHe
Copy link
Contributor Author

beautiful! 💯

is this good to go for merging?

ready to merge if you don't have any other considerations

@alixander
Copy link
Collaborator

nope, that's what the approval means =). i just started taking a habit of confirming with the author after ran into an instance where i merged too early (#1091 (comment)). Thanks @donglixiaoche

@alixander alixander merged commit 2d7cdc5 into terrastruct:master Apr 7, 2023
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.

3 participants