mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
90e57c2b18
There are many times when an application wants to know metadata about shaped text without allocating a stateful text widget such as widget.Selectable. This commit introduces widget.TextInfo and adds an extra LayoutDetailed method to widget.Label returning this struct. Currently the struct only provides the information necessary to determine whether the text was truncated (useful for deciding whether a tooltip makes sense), but it can be expanded to include text metrics in the future for applications which require those. In the future other text widgets may surface methods of acquiring widget.TextInfos, but the critical gap in the API is that we can't currently determine whether a stateless label was truncated, so I'm starting here. I considered making Label.Layout() always return this, but I didn't want to introduce a breaking API change yet. I have some other thoughts I want to explore about the label API which might trigger breaking changes (moving parameters into fields). Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>