-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 option to truncate text at wrap width #3244
Conversation
elide
option to truncate text at wrap width
elide
option to truncate text at wrap widthThere 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.
Great feature! Nothing strikes me in particular with the implementation. I just have a weak preference for truncate
instead of elide
for the API until we have various forms of elision.
### What As the title says. Also fixes `StoreHub::remove_recording_id()` to only change selection _if_ the currently selected recording is being removed (otherwise the selection remains unchanged). TODO: - [x] blocked on emilk/egui#3244 <img width="1293" alt="image" src="https://github.com/rerun-io/rerun/assets/49431240/e2272633-86bb-423c-935d-c7dd8e68fe67"> ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/2976) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/2976) - [Docs preview](https://rerun.io/preview/pr%3Aantoine%2Frecording-close-button/docs) - [Examples preview](https://rerun.io/preview/pr%3Aantoine%2Frecording-close-button/examples) --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
|
You can now easily elide text that doesn't fit a certain max width.
This is done using
Label::new(long_text).truncate(true)
. The text will be truncated to fit the max width of the parentUi
, and the…
ellipsis will replace the omitted text. The text may get truncated in the middle of a word. When hovering a label with elided text, the full non-elided text will be shown in a tool-tip.You can use the options in
TextWrapping
for finer control.TextWrapping::max_rows == 0
will now output zero rows. Useusize::MAX
to set no limit.TextWrapping::max_rows
will now count total rows (not rows per paragraph, as previous).ADDED:
Galley::elided
, to see if the text layout elided the input textMost of the implementation had already be done by @awaken1ng in #1291
Future work
There are normally three modes of elision that can be desired:
… jumps over the lazy dog
The quick … the lazy dog
The quick brown fox jumps…
This PR only adds support for the latter kind.
It would also be good to have an option to only omit whole words, never breaking them.
Finally, being able to set the truncate character to a string (e.g.
…
with a leading space) would be nice.