-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 an API to get the "min" width of text widgets with wrapping that would be needed to show the text without wrapping #4826
Comments
I'm not sure I agree that the only solution is a messy one... Can't you just get the minimum before turning on wrapping and cache that value? |
What about when you need to update the text while it's already displayed (and update the positioning of an icon you want to position immediately to the right of the text string)? BTW here is a case internally where it would be useful - https://github.com/fyne-io/fyne/blob/develop/dialog/text.go#L38 |
This could also supersede #4648 |
What I'm not really getting is why it's not just a right aligned icon with text filling the available space |
As far as I can tell you can't achieve the desired positioning:
|
This is a complex topic as discussed on Slack, but I'm not convinced that different types of min are the way to go. It seems that for this specific use-cases you are changing between two so it's likely more than just a custom layout as you say. Perhaps using tricks like for complex tables where we switch between different widgets depending on some factors. I'd say that there are many ways to approach this:
Overall I think we have a solid underpinning so I'm not sure the Label widget is missing a bunch of APIs, but I think we should be open to exploring this going forward if we can more generally find a solution that helps out with complex layout requirements such as that above. |
Just for reference and in case it's helpful for anyone (or useful info on use cases when we eventually try to design an API to solve this issue) - here is the custom component I have to show the "MoreVerticalIcon" immediately to the right of a hyperlink text, which is allowed to truncate - https://github.com/dweymouth/supersonic/blob/main/ui/widgets/optionhyperlink.go |
Checklist
Is your feature request related to a problem?
Complex positioning with truncating text widgets is very difficult. For example, to place an icon immediately to the right of a line of text that is allowed to truncate if shrunk, with a custom layout similar to HBox that uses the non-wrapping width as the packed width of the text line instead of its minSize - if there is enough room.
Is it possible to construct a solution with the existing API?
Yes, but messily, by making a custom text widget that includes another non-wrapping non-displayed text widget just to figure out the non-wrapping width
Describe the solution you'd like to see.
label.NonWrappingWidth() float32
hyperlink.NonWrappingWidth() float32
richText.NonWrappingWidth() float32
The text was updated successfully, but these errors were encountered: