bevy/crates/bevy_ui/src
Antony e7a31d000e
Add border radius to UI nodes (adopted) (#12500)
# Objective

Implements border radius for UI nodes. Adopted from #8973, but excludes
shadows.

## Solution

- Add a component `BorderRadius` which contains a radius value for each
corner of the UI node.
- Use a fragment shader to generate the rounded corners using a signed
distance function.

<img width="50%"
src="https://github.com/bevyengine/bevy/assets/26204416/16b2ba95-e274-4ce7-adb2-34cc41a776a5"></img>

## Changelog

- `BorderRadius`: New component that holds the border radius values.
- `NodeBundle` & `ButtonBundle`: Added a `border_radius: BorderRadius`
field.
- `extract_uinode_borders`: Stripped down, most of the work is done in
the shader now. Borders are no longer assembled from multiple rects,
instead the shader uses a signed distance function to draw the border.
- `UiVertex`: Added size, border and radius fields.
- `UiPipeline`: Added three vertex attributes to the vertex buffer
layout, to accept the UI node's size, border thickness and border
radius.
- Examples: Added rounded corners to the UI element in the `button`
example, and a `rounded_borders` example.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Zachary Harrold <zac@harrold.com.au>
Co-authored-by: Pablo Reinhardt <126117294+pablo-lua@users.noreply.github.com>
2024-03-19 22:44:00 +00:00
..
layout Fix #12255 Updating TargetCamera on multi camera scenes not allowing layout to be calculated (#12268) 2024-03-04 19:19:25 +00:00
render Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
widget feat: derive some common traits on some UI types (#12532) 2024-03-18 03:41:50 +00:00
accessibility.rs resolve all internal ambiguities (#10411) 2024-01-09 19:08:15 +00:00
focus.rs don't attempt to set cursor relative position for zero sized nodes (#12395) 2024-03-10 02:18:40 +00:00
geometry.rs Add with_left, with_right, with_top, with_bottom to UiRect (#12487) 2024-03-15 17:43:39 +00:00
lib.rs Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
measurement.rs Change the default for the measure_func field of ContentSize to None. (#9346) 2023-08-07 23:06:40 +00:00
node_bundles.rs Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
stack.rs Reduce steady-state allocations in ui_stack_system (#12413) 2024-03-12 13:57:57 +00:00
texture_slice.rs Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
ui_material.rs Fix incorrect link in UiMaterial documentation (#12361) 2024-03-07 22:09:57 +00:00
ui_node.rs Add border radius to UI nodes (adopted) (#12500) 2024-03-19 22:44:00 +00:00
update.rs Avoid panicking with non-UI nodes (#12213) 2024-02-29 21:36:45 +00:00