Dimchikkk / bevy_cosmic_edit

Apache License 2.0
86 stars 9 forks source link

Simplify UI bundle code #85

Closed bytemunch closed 1 year ago

bytemunch commented 1 year ago

Original comment: https://github.com/StaffEngineer/bevy_cosmic_edit/issues/84#issuecomment-1760018462

Use Sprites for all rendering, have a Node component on "UI" bundles for positioning.

Will simplify the codebase and allow for use of sprite-specific bevy features, such as shaders.

Think I remember reading about UI Sprites somewhere in the bevy repo, will edit with a link if I can find it.

On my machine Sprites look a bit fuzzier than UI Images, this will need to be addressed. Probably a Z positioning thing or something.

Dimchikkk commented 1 year ago

I had blurred text with sprites in velo, it was fixed by rounding coordinates of sprites: https://github.com/StaffEngineer/velo/blob/c7e9fb846449f33abb8b74fff891d27c95781856/src/ui_plugin/systems/update_rectangle_position.rs#L49

bytemunch commented 1 year ago

Ah makes sense! I'll try something similar see if it solves the issue

bytemunch commented 1 year ago

Trying to implement a sprite only solution didn't feel right, I don't think Sprites are meant to be interchangeable with UiImages. Bundles can definitely be simplified down to reduce code repetition, might need to approach from a different angle, maybe pointing the UiImage handle at a widget controlled sprite texture or something? Will try again after some time if and when the "right" way of doing things occurs to me haha

Dimchikkk commented 1 year ago

Yeah, the main goal is not really simplify the code but allow shaders.... maybe there is another (more simple way) to bring them 🤔