Comments (7)
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?
from fyne.
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
from fyne.
This could also supersede #4648
from fyne.
What I'm not really getting is why it's not just a right aligned icon with text filling the available space
from fyne.
As far as I can tell you can't achieve the desired positioning:
- If you put the label and icon in an HBox, the text will always be forced to its minSize of "..." (using TruncateEllipsis)
- If you put the label and icon in a border with label as center, and icon as right, then the icon will float all the way to the right with the available space, rather than immediately to the right of the end of the label's text
- Writing a custom layout, you still need to know how much space the text takes up if the full thing can be displayed in the label (which is different from label MinSize which is only big enough for "...")
from fyne.
This is a complex topic as discussed on Slack, but I'm not convinced that different types of min are the way to go.
There are many combinations of text wrap/trunc etc that can lead to different space being needed and we should not add APIs for them all. In essence you've got two widgets with different configurations.
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:
- managing multiple widgets similar to how you are doing or by actually switching which is visible in some custom code.
- introducing a whole preferred size API into Fyne (which creates huge complexity increase to handle such corner cases). As discussed it is not clear if this would be in the layout or widget APIs.
- Adding a set of new text APIs that allow you to measure text based on certain wrapping characteristics not just the text style as it currently exists.
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.
from fyne.
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
from fyne.
Related Issues (20)
- Unable to run some apps on M1 Macbook Pro HOT 2
- Build fails with transparent image for iOS icon HOT 3
- Disabled app tabs can still be selected in popup menu HOT 1
- Labels clipping some text below baseline HOT 6
- Wrong font rendering when overriding theme HOT 8
- Font can't be displayed correctly after fyne package HOT 2
- The text is not Alignment in button with custom font. HOT 1
- App crashed in windows10 enterprise HOT 6
- Notification actions/callbacks HOT 3
- BorderLayout does not show border objects when used in an AppTab HOT 2
- Window periodically misdraws into a smaller area on startup HOT 1
- Notifications are not working on iOS HOT 2
- Mobile simulator should follow light/dark mode HOT 2
- iOS notifications only work in the foreground HOT 5
- Optionally allow internal callback for Hyperlink and HyperlinkSegment to handle clicks and taps internally HOT 4
- MacOS not asking for permission to show notifications HOT 10
- Menu tests are failing on some developer computers HOT 6
- Stop printing diffs between failed image matches
- Annoying extra output when tests are failing
- Objects added to a container that is part of a theme override don't get the overridden theme HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fyne.