bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.4k stars 3.59k forks source link

UI ninepatch border geometry should match the borders in the layout (maybe) #14943

Open ickshonpe opened 3 months ago

ickshonpe commented 3 months ago

What problem does this solve or what need does it fill?

Borders created using the UI's texture slicing api aren't borders in the UI layout. This means that for example that left-aligned text will align at the left edge of the uinode, not the inner edge of the border, and write over the ninepatch border:

nbh

What solution would you like?

Have an option to draw borders from the UI layout using the ninepatch api.

What alternative(s) have you considered?

You can add an invisable border the same size as the ninepatch border. This might be awkward to keep synchronised though.

alice-i-cecile commented 3 months ago

Yeah I think that this should end up creating borders? I don't hold that opinion very strongly though.

ickshonpe commented 3 months ago

Yeah I think that this should end up creating borders? I don't hold that opinion very strongly though.

Yeah I'm not very clear about how this should work. I've reimplemented UI texture slicing using a shader and I was trying to match my changes to the old api but it feels like it would actually be easier just to use the border geometry from the layout because I'm not sure what the min_corner_scale field does :sweat:.

ickshonpe commented 2 months ago

Another problem is that the nine-patcher doesn't just draw a border but also a background in the center. We could just not draw the center patch though, depending.

ickshonpe commented 2 months ago

Thought about this and I think all it needs is a UiImageScaleMode component copying ImageScaleMode but without the max_corner_size field, and it will work fine.