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

Way to get absolute position in nested layout? #787

Closed
Robert-M-Muench opened this issue Jun 25, 2018 · 3 comments
Closed

Way to get absolute position in nested layout? #787

Robert-M-Muench opened this issue Jun 25, 2018 · 3 comments

Comments

@Robert-M-Muench
Copy link

YGNodeLayoutGetLeft() and YGNodeLayoutGetTop() return values relative to the parent.

Is there a way to get the absolute values in a nested layout that adds up all the parent positions?

@KitsuneAlex
Copy link

I know this is a bit late but did you get this sorted out? The C++ documentation is kinda sparse and i've been struggeling with the exact same problem for a while now. Thanks in advance :)

@Robert-M-Muench
Copy link
Author

There is no function you can use.

I solve this by tracking the absolute positions ax and ay manually and updated them while traversing the layout tree on any layout changes. Works and doesn't add too much run-time overhead.

@KitsuneAlex
Copy link

Yeah i figured a way out myself, i just retrieve the X and Y position of my component in question, then check if it has a parent and if so, add it's X and Y to the component's X and Y, then return the result. Works pretty nicely :D

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

No branches or pull requests

3 participants