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

Use logical coordinates for the UI layout #8426

Closed
wants to merge 2 commits into from

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Apr 17, 2023

Objective

It would be a lot more efficient and less complicated if the UI layout systems only used logical coordinates.

Solution

Just use logical coordinates everywhere except where we can't.
Change flex_node_system and FlexSurface to use logical coordinates.


Changelog

  • Modified flex_node_system and FlexSurface to use logical coordinates.
  • Changed the size paramter of update_window to a Vec2 and renamed it to logical_size.

Migration Guide

* Added a field `logical_size` to `LayoutContext` and changed its `min_size` and `max_size` fields to use logical sizes.
* Modified `flex_node_system` and `FlexSurface` to use logical coordinates.
* Changed the size paramter of `update_window` to a `Vec2` and renamed it to `logical_size`.
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change labels Apr 17, 2023
@ickshonpe ickshonpe changed the title use logical coordinates for the layout Use logical coordinates for the UI layout Apr 17, 2023
@alice-i-cecile alice-i-cecile added this to the 0.11 milestone Apr 17, 2023
@ickshonpe
Copy link
Contributor Author

ickshonpe commented Apr 17, 2023

cargo run --profile stress-test --features trace_tracy --example many_buttons -- no-text
logical_layout

Not as big an improvement as I hoped for, but I'll take it.

@alice-i-cecile
Copy link
Member

Yeah IMO the primary wins here are code quality. Can you fix up merge conflicts?

@ickshonpe
Copy link
Contributor Author

Yeah IMO the primary wins here are code quality. Can you fix up merge conflicts?

yes, will do.

@nicoburns
Copy link
Contributor

Hmm... we ideally want to use physical coordinates in Taffy for rounding purposes (although this may not be critical for game UIs). I've been considering added a scale_factor configuration field to Taffy such that it takes logical units in and outputs physical units. Would that work with this approach?

@ickshonpe
Copy link
Contributor Author

ickshonpe commented Apr 17, 2023

Hmm... we ideally want to use physical coordinates in Taffy for rounding purposes (although this may not be critical for game UIs). I've been considering added a scale_factor configuration field to Taffy such that it takes logical units in and outputs physical units. Would that work with this approach?

Yeah, I've been looking for rounding issues but I haven't seen anything so far. If Taffy supported scale factor that would probably be ideal though. We'd just convert the output coordinates back immediately when we update the node sizes and transforms etc.

@nicoburns
Copy link
Contributor

I think this one probably ought to block on DioxusLabs/taffy#478

@alice-i-cecile alice-i-cecile removed this from the 0.11 milestone Jun 19, 2023
@alice-i-cecile alice-i-cecile added the S-Blocked This cannot move forward until something else changes label Jun 19, 2023
@ickshonpe
Copy link
Contributor Author

Yep, I'm not sure about this one at all now.

#8720 fixes a lot of the same problems, and doesn't have any of the possible negatives that this has.

@alice-i-cecile
Copy link
Member

I'm going to close this in favor of #8720; we can revisit it later if y'all change your minds :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change S-Blocked This cannot move forward until something else changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants