asny / three-d

2D/3D renderer - makes it simple to draw stuff across platforms (including web)
MIT License
1.33k stars 110 forks source link

egui anchoring #286

Closed bananaturtlesandwich closed 2 years ago

bananaturtlesandwich commented 2 years ago

Sorry to be a pain about the egui integration again but I think there might be an issue with anchoring For example, in spawning a SidePanel (I'll use the screen demo as an example)

By modifying the demo to use SidePanel::right instead of SidePanel::left, a crash occurs when the ui width is subtracted from the full width of the window due to a cast to u32 from a negative result

The reason for the crash can be seen with the dbg! macro to inspect panel_width - with SidePanel::left, panel_width is 228 while with SidePanel::right, panel_width is 10000 - larger than the full width of the window

This issue also occurs when using the egui-notify crate as the notifications are anchored to the top right by default

I'm honestly not experienced enough to know why this happens but I hope my observations are useful

asny commented 2 years ago

No worries, it's just nice to get some feedback and get the bugs fixed 👍

I have fixed one issue in ca30cd0e , unfortunately you'll have to pass in the viewport in GUI::update instead of GUI::render.

You also need to use panel_width = gui_context.used_rect().width() as f64; instead of panel_width = gui_context.used_size().x as f64;.