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

ComputedNodeTarget improvements #17929

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Feb 19, 2025

Objective

Couple of things need improving with ComputedNodeTarget:

  • There aren't aren't any doc comments for its fields and methods.
  • The camera field should be optional with absent cameras represented by None instead of Entity::PLACEHOLDER.
  • The inverse_scale_factor field should be removed from ComputedNode, ComputedNodeTarget should be the single source of truth for scale factor. ComputedNodeTarget is updated in Prepare and then ComputedNode isn't updated until Layout. So it could cause errors if any systems use ComputedNode's inverse_scale_factor after update_ui_context_system in Prepare but before ui_layout_system in Layout.
  • update_ui_context_system is misnamed, intially ComputedNodeTarget was called UiContext and this system should have been renamed to match the new component name.
  • All ComputedNodes should be marked as changed on changes to their ComputedNodeTarget to make certain everything is recomputed.

Solution

  • Added doc comments to ComputedNodeTarget.
  • Remove ComputedNode's inverse_scale_factor field.
  • Make the camera field of ComputedNodeTarget optional.
  • Rename update_ui_context_system to compute_node_targets_system.
  • Add a query for ComputedNodeTargettotext_systemand remove theinverse_scale_factorparameter fromqueue_text` function.
  • UI extraction functions that require the scale factor for responsive coordinate resolution now retrieve it from ComputedNodeTarget.
  • In ui_layout_system call set_changed on every descendent's ComputedNode if a root node's ComputedNodeTarget is changed.

Testing

If you change your desktop's scale factor with any of the UI examples running you can that the layout and text is recomputed correctly in response.

The multiple_windows and split_screen demonstrate camera target propagation still works correctly.

* Renamed `update_ui_context_system` to `compute_node_targets_system`. In the initial draft the  `ComputedNodeTarget` component was called `UiContext` instead and this system should have been renamed to match it.

* The `camera` field of `ComputedNodeTarget` has been made optional instead of using `Entity::PLACEHOLDER` to represent an absent camera target.

* Removed `ComputedNode`'s `inverse_scale_factor` field. `ComputedNodeTarget` should be the single source of truth for local scale factor.

* `text_system` queries for `ComputedNodeTarget` and the `queue_text` function has been changed to take just the scale factor
value and not its inverse as well.

* UI extraction functions that require the scale factor for responsive coordinate resolution now query for `ComputedNodeTarget`.

* Added doc comments for `ComputedNodeTarget`.
…nctions where `ComputedNodeTarget` has replaced `UiTargetCamera`
@ickshonpe ickshonpe added C-Docs An addition or correction to our documentation A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change C-Docs An addition or correction to our documentation S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant