Open latidoremi opened 1 year ago
I've had a similar problem while trying to implement a hex viewer widget (https://github.com/manokara/iced_widgets/issues/1). Looking back, I was overengineering the rendering of the rows by splitting each row into batches of highlighted and non highlighted text primitives (code), which was causing misaligned pairs as you can see in the GIF there. It could be easily solved by using two text primitives overlayed on top of each other with the appropriate blank space for highlighted and non-highlighted pairs. But on the other hand, if I were to give the option for the user to choose a font and they chose a non-monospace one, it would probably look weird again.
I remember bringing this up on Zulip around that time to and I think we agreed on it it as a "wontfix, for now at least". Could we bring that discussion up again now that iced is a little bit more mature, @hecrj?
Is there an existing issue for this?
Is this issue related to iced?
What happened?
This might seem a bit trivial but it's way more noticeable in my actual project
Notice the thin black line under the pick lists, the black background is a
widget::Container
with height set toLength::Shrink
, which means the buttons are a little bit higher than the pick lists, but they're actually using the same text size and padding, and the weird thing is, this happens when text size is set to exactly 15 or a multiple of 15 like 30, 60, etc.I checked out the source code and noticed that
widget::PickList
is using thetext_size
variable as the height of the intrinsic size, while the text on a button which iswidget::Text
is using theheight
calculated fromtext::Renderer::measure()
I added some println!s so that I can log the size and stuff, here's the result with all text size set to 15
So it ceils 15.000001 to 16.0, that's what makes the buttons bigger
A simple solution is using the
size
variable as the height and the black line is goneI'd like to know what you guys think
Test file: text_bounds_bug.rs.txt
What is the expected behavior?
Version
master
Operative System
macOS
Do you have any log output?
No response