-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
text: Improve accuracy and performance of caret placement in text #18446
Merged
torokati44
merged 8 commits into
ruffle-rs:master
from
kjarosh:screen-position-to-index-fix
Nov 4, 2024
Merged
text: Improve accuracy and performance of caret placement in text #18446
torokati44
merged 8 commits into
ruffle-rs:master
from
kjarosh:screen-position-to-index-fix
Nov 4, 2024
Conversation
This file contains 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
kjarosh
added
text
Issues relating to text rendering/input
A-core
Area: Core player, where no other category fits
T-fix
Type: Bug fix (in something that's supposed to work already)
labels
Nov 2, 2024
adrian17
approved these changes
Nov 2, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure, this also corrects for scrolling? (I’m not familiar what the abstractions cover there)
kjarosh
force-pushed
the
screen-position-to-index-fix
branch
from
November 2, 2024 10:20
b5eaad6
to
89f11cc
Compare
Yes, scrolling worked okay, nonetheless I've added the test |
When transforming TextField local coordinates to layout coordinates, we want to subtract the gutter, not add it. This fixes the weird 4px constant translation when selecting text.
This method allows finding lines by their y coordinates with binary search.
This simplifies code a lot and makes it more performant.
This test verifies how the caret is placed in text with different leadings.
This test verifies how caret placement works depending on the align.
This test verifies how the caret placement works when bounds do not start with 0,0.
This test verifies how the caret placement works with non-zero vertical and horizontal scroll.
torokati44
force-pushed
the
screen-position-to-index-fix
branch
from
November 4, 2024 11:04
89f11cc
to
f4a15fd
Compare
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.
This PR fixes
screen_position_to_index
and makes some refactors:screen_position_to_index
(it was broken when the bounds did not start at(0,0)
),screen_position_to_index
.This makes
screen_position_to_index
a lot more accurate.Four tests are added:
text_caret_placement_leading
– it checks how the caret is being placed in text depending on text leading,text_caret_placement_align
– it checks how the caret is being placed in text depending on text align,text_caret_placement_translated_bounds
– it checks how the caret is being placed when bounds do not start at(0,0)
,text_caret_placement_scroll
– it checks how the caret is being placed with non-zero horizontal and vertical scroll.