-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(layouts): text truncation & proper text alignment (#120)
feat(layouts): text truncation & proper text alignment You can now set `truncate` to true in a text element, like this: ```toml wrap_width = 130.0 truncate = true ``` The text is truncated at the given wrap width instead of wrapped. While I was truncating text and just generally figuring out what these imgui functions do, I returned to the problem of correctly-aligning wrapped text. For right- and center-aligned text, this requires looping through the full text rendering it one line at a time, adjusting the position of each line to match its bounds. Further, because imgui does not export any of its word-wrapping implementation, we have to do additional work to find word boundaries. To do this, we look for the nearest space preceding the imgui-selected wrap position. If it's near enough, we break the line at that position, recalculate bounds, and draw. I broke out the text rendering cases so that simple cases do the least work possible, and the space-seeking and bounds-adjusting work is only done when required. The implementation of drawing text is somewhat verbose as a result but each case is simple by itself. Fixes [#104](#104) Fixes [[#98](#98)]
- Loading branch information
Showing
8 changed files
with
93 additions
and
28 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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