CosmicBuffer is a public type but not not used or accessible in any public API#17748
Merged
alice-i-cecile merged 6 commits intobevyengine:mainfrom Feb 10, 2025
Merged
CosmicBuffer is a public type but not not used or accessible in any public API#17748alice-i-cecile merged 6 commits intobevyengine:mainfrom
alice-i-cecile merged 6 commits intobevyengine:mainfrom
Conversation
Contributor
|
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
UkoeHB
approved these changes
Feb 9, 2025
Contributor
|
Thanks, the publicity of |
rparrett
reviewed
Feb 9, 2025
rparrett
reviewed
Feb 9, 2025
Typo fix Co-authored-by: Rob Parrett <robparrett@gmail.com>
Grammar fix Co-authored-by: Rob Parrett <robparrett@gmail.com>
rparrett
reviewed
Feb 9, 2025
Co-authored-by: Rob Parrett <robparrett@gmail.com>
rparrett
approved these changes
Feb 9, 2025
Contributor
rparrett
left a comment
There was a problem hiding this comment.
This was useful to me when I tested a previous iteration of the cosmic integration where this was available.
Open
Closed
This was referenced Feb 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Currently CosmicBuffer is a public type with a public field that is not used or accessible in any public API. Since it is prominently shown in the docs it is the obvious place to start when trying to access
cosmic_stringfeatures such as for mapping between screen coordinates and positions in the displayed text.The only place
CosmicBufferis currently used is as a field ofComputedTextBlock, where a comment explains why the field is private:Unfortunately this comment does not appear in the docs, so a user looking for a way to access
CosmicBufferwill not find it unless they check the source code.Also there does not seem to be any alternative way to map between screen coordinates and positions in the displayed text, which would be highly useful for things like text edit widgets or tool tips. The reasons given for making the field private only apply for mutable access, so non-mutable access would presumably be fine.
Solution
I added a getter to
ComputedTextBlock, and added the explanation for why there is no mutable access in the comment:Testing
I tested that the getter could be used to map from screen coordinates to string positions by creating a rudimentary text edit widget and trying it out.
Alternatives
An alternative to making
CosmicBufferaccessible would be to make the type private so that no one wastes time looking for a way of accessing it, and adding additional methods toComputedTextBlockthat make use of the buffer as implementation detail and offer access to currently inaccessible functionality.