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

Add Text Insets #65

Merged
merged 3 commits into from
Jan 16, 2025
Merged

Conversation

thecoolwinter
Copy link
Contributor

@thecoolwinter thecoolwinter commented Jan 12, 2025

Description

  • Adds a textInsets property that allows insetting the drawn text further than other drawn content in the view.
    This works in addition to the edgeInsets property, and only effects where text is drawn. This enables adding a padded area where text is not drawn, and selections are not drawn, and further inset the text from that edge.
    This is useful when adding trailing padding to a text view that is not wrapping lines. In a case like that, the textview needs to have a larger width than just the text, but also needs to draw the selection rect in that padded area. To achieve this, the text inset would be set to the padded area.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Text insets and edge insets have left and right set to 30. All content is inset by 30px and the text is further inset by another 30px on the right side.

Screen.Recording.2025-01-12.at.1.58.42.PM.mov

An example of negative text insets on top of positive edge insets, showing it works as expected.

Screen.Recording.2025-01-12.at.1.57.42.PM.mov

No wrapping lines, text inset is >0 on the right edge, meaning the textview has some room to scroll after the text, while still drawing the selection rect in some of that padded area.

Screen.Recording.2025-01-12.at.1.59.14.PM.mov

The updated example app with two new controls:

Screenshot 2025-01-12 at 2 05 48 PM

@thecoolwinter thecoolwinter merged commit 8ceb3fd into CodeEditApp:main Jan 16, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants