the width being that of the button that fits the widest content?
Calling .width(Length::Fill) on the buttons fills available space, e.g. the window, which is not what I’m after. Calling .size().width doesn’t give a numeric width that can be calculated with. Alternatives?
I think you were right on setting .width(Length::Fill) on your buttons but also make sure their container (the column) doesn’t grow more than it needs. What if you call .width(Length::Shrink) on it?
You’re right. The best solution I could come up with implies that the widths of your buttons are know before runtime, that they don’t change during runtime, and that you can place your widest button first. Under those conditions, this works:
@lufte Thanks for your help. Yes, it seems there’s no path forward unless I reorder the buttons. That’s unfotunate.
I’m trying the same thing in egui. It also doesn’t do this out-of-box, but since it can give me numeric sizes, I can do a two-pass calculation to manually set the button sizes.
I guess this is the kind of thing that makes it pre-1.0.
It is certainly possible to do so today. You can use the responsive widget to calculate the size they must have lazily and then set their widths to that Length::Fixed with that amount
But, I’d still like for the buttons to be the width of the button that fits the longest string and no wider than that. The responsive container says it takes up all available space, and so in the above example the buttons stretch across as far as they can.
I tried to constrain it with Shrink and horizontal_space but wasn’t able to do so: