dmackdev/egui_json_tree

Improve vertical alignment

juancampa opened this issue · 5 comments

Screenshot 2023-09-06 at 11 36 17 PM

Keys and open/close delimiters should probably be horizontally aligned.

I think this must be something specific to how you've styled the egui::Ui in which you are rendering the JsonTree, because I do not see this problem in this repo's examples, and I notice that the vertical line beneath the collapsing header icon is not present in your screenshot.

Are you able to provide a reproduction? I suspect it's because ui.spacing().icon_width has changed - changing this in the demo causes a similar misalignment.

Interesting, I didn't change icon_width but I did change the font size (and the font itself). Perhaps I need to adjust icon_width accordingly

To be clear, you don't see either of the misalignments?

Screenshot 2023-09-07 at 2 11 46 AM You're right, changing it to `8.0` fixed the key alignment issue

I am not seeing a misalignment in the repo's examples when changing the font size and style alone, e.g. setting the following on a JsonTree:

 .style(JsonTreeStyle {
                font_id: Some(FontId::proportional(40.0)),
                ..Default::default()
            })

Did you change something else?
Wondering if we should set an appropriately scaled icon_width based on something in the Ui.