Skip to content

TextSection trait#23423

Merged
alice-i-cecile merged 7 commits intobevyengine:mainfrom
ickshonpe:text-section-trait
Mar 22, 2026
Merged

TextSection trait#23423
alice-i-cecile merged 7 commits intobevyengine:mainfrom
ickshonpe:text-section-trait

Conversation

@ickshonpe
Copy link
Copy Markdown
Contributor

@ickshonpe ickshonpe commented Mar 19, 2026

Objective

There are three separate traits for primary text components: TextRoot, TextSpanAccess and TextSpanComponent.
They all provide the same functionality and can be consolidated into a single trait.

The method names on TextSpanAccess's (read_span and write_span) aren't ideal either. The names imply performing an action, not just the return of a reference, and should be changed to something more idiomatic.

Solution

  • Renamed TextSpanAccess to TextSection and added a From<String> trait bound.
  • Renamed read_span to get_text.
  • Renamed write_span to get_text_mut.
  • Removed the TextRoot and TextSpanComponent.
  • Replaced all usages of TextRoot and TextSpanComponent with TextSection.
  • Renamed the private TextSection struct in the pipeline module to TextSectionView.

@ickshonpe ickshonpe added A-Text Rendering and layout for characters C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Mar 19, 2026
@ickshonpe ickshonpe added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Mar 21, 2026
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 22, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 22, 2026
Merged via the queue into bevyengine:main with commit 1eed8f9 Mar 22, 2026
42 checks passed
splo pushed a commit to splo/bevy that referenced this pull request Mar 31, 2026
# Objective

There are three separate traits for primary text components: `TextRoot`,
`TextSpanAccess` and `TextSpanComponent`.
They all provide the same functionality and can be consolidated into a
single trait.

The method names on `TextSpanAccess`'s (`read_span` and `write_span`)
aren't ideal either. The names imply performing an action, not just the
return of a reference, and should be changed to something more
idiomatic.

## Solution

* Renamed `TextSpanAccess` to `TextSection` and added a `From<String>`
trait bound.
* Renamed `read_span` to `get_text`.
* Renamed `write_span` to `get_text_mut`.
* Removed the `TextRoot` and `TextSpanComponent`.
* Replaced all usages of `TextRoot` and `TextSpanComponent` with
`TextSection`.
* Renamed the private `TextSection` struct in the `pipeline` module to
`TextSectionView`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Text Rendering and layout for characters C-Code-Quality A section of code that is hard to understand or change D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants