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

Expose computed grid-template and grid-placement values #714

Closed
Tracked by #345
Atlas16A opened this issue Oct 1, 2024 · 2 comments
Closed
Tracked by #345

Expose computed grid-template and grid-placement values #714

Atlas16A opened this issue Oct 1, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Atlas16A
Copy link

Atlas16A commented Oct 1, 2024

What problem does this solve or what need does it fill?

It is useful to be able to access the computed values for both grid-template-{rows,columns} (concrete pixel values for the sizes of the rows/columns) and grid-{row,column} (concrete integer values for the start/end row/column positions).

Example use cases include:

  • Introspectability for devtools
  • Accessing via javascript
  • For frameworks building on opt of Taffy that want to be able to run logic based on the grid structure.

What solution would you like?

Getter functions on UI Grid styles, such as the grid_placement styles, should return the computed values, not the values set by the setter/at spawn.

What alternative(s) have you considered?

An Alternative getter function would also work. Perhaps get_recent or get_state

@Atlas16A Atlas16A added the enhancement New feature or request label Oct 1, 2024
@nicoburns
Copy link
Collaborator

Likely design for this is:

  • Add a method to the low-level algorithm implementations that allows them to output the intermediate data structures. Consumers of the low-level API can choose whether to store this data or simply discard it.
  • Add storage to nodes for this data in the TaffyTree. Probably as a Box<dyn Any> so it doesn't take up too much memory if it's not being used.
  • Make this a runtime configuration option as to whether the TaffyTree saves this information or not.
  • Add APIs to get at the data from the TaffyTree.

In a future extension we could then potentially add the ability for the algorithms to take these intermediate data structures back in as a cached input. This could allow for finer-grained incremental computation and/or simply re-using the allocations.

@nicoburns nicoburns changed the title UI Grid Placement Styles should hold the calculated values during runtime. Expose computed grid-template and grid-placement values Dec 12, 2024
@nicoburns
Copy link
Collaborator

Implemented in #772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants