Skip to content

Border & CornerRadius#8381

Closed
fxtressia wants to merge 31 commits intobevyengine:mainfrom
asteria-archive-otori:ui-renderer-0.11.0
Closed

Border & CornerRadius#8381
fxtressia wants to merge 31 commits intobevyengine:mainfrom
asteria-archive-otori:ui-renderer-0.11.0

Conversation

@fxtressia
Copy link

@fxtressia fxtressia commented Apr 14, 2023

Objective

Solution

  • Fix all merge conflicts and migrate the API.

Changelog

  • Everything in the original PR, plus
  • Added corner and corner_radius properties to ButtonBundle
  • Fixed the not working button example
  • Added a warning to CornerRadius, which will be discussed more down in this text.

Migration Guide

As we added the corner and corner_radius properties to ButtonBundle, this might break the API for people who don't use ..default(), but that seems rare. You can set it to a value you like or use Default::default() as usual.

oceantume and others added 28 commits February 19, 2022 12:19
…sual-features

# Conflicts:
#	crates/bevy_ui/src/render/pipeline.rs
Move some work from fragment shader to vertex shader
Add branching to skip complexity when there's no rounding or border
Remove softness since we're not using it
# Conflicts:
#	examples/ui/button.rs
#	examples/ui/ui.rs
…antume/bevy

Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
aa
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
aa
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Rendering Drawing game state to the screen labels Apr 14, 2023
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Apr 14, 2023
@alice-i-cecile
Copy link
Member

Breaking change here is totally fine, but we should note it just in case :)

@fxtressia
Copy link
Author

fxtressia commented Apr 14, 2023

Breaking change here is totally fine, but we should note it just in case :)

Okay! It's just the new fields in ButtonBundle!

@IceSentry
Copy link
Contributor

Can you update the Migration guide section to not say the As mentioned earlier part?

We auto generate the full migration guide based on that section and it wouldn't be useful for a user to read this.

@mockersf
Copy link
Member

mockersf commented Apr 14, 2023

there is also #7795 for borders in UI

@fxtressia fxtressia changed the title UI renderer Border & CornerRadius Apr 14, 2023
@fxtressia
Copy link
Author

there is also #7795 for borders in UI

Yes, I'm aware of that. I wonder how to merge that with this honestly.

@fxtressia
Copy link
Author

Can you update the Migration guide section to not say the As mentioned earlier part?

We auto generate the full migration guide based on that section and it wouldn't be useful for a user to read this.

Done!! ^_^

@ickshonpe
Copy link
Contributor

#3991 had a couple of problems iirc:

  • I used it to do the rounded buttons for https://ickshonpe.itch.io/pillars and there were some compatibility issues. On some systems, it just rendered flat grey rectangles instead of the buttons.
  • It only renders uniform borders. I tried for a little while to get non-uniform borders working with it but couldn't quite get them right.
  • It doesn't support different coloured edges. That shouldn't be difficult to add though.

#7995 is pretty simple, it should be easy to combine them but needs non-uniform border support.

if (in.radius > 0.0 || in.border_width > 0.0) {
var distance = distance_round_border(in.point, in.size * 0.5, in.radius);

var inner_alpha = 1.0 - smoothstep(0.0, 0.0, distance);
Copy link
Contributor

@JMS55 JMS55 Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var inner_alpha = 1.0 - smoothstep(0.0, 0.0, distance);
var inner_alpha = 1.0 - smoothstep(0.0, 1.0, distance);

I believe this should be 1.0, otherwise you're not getting any anti-aliasing. Something still looks off though, the transition between straight edges/corners is too sharp.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a button with the title "Button" showing pixelated edges

Ah, I see!

an anti-aliased button with 25px corner radius
an anti-aliased button with 15px corner radius

Though, it looks a bit cool, if only it's more consistent between all corners.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JMS55 this is fixed now, but it's great if I could get assistance with the sharp transition issue.

I don't have many experiences with rendering, unfortunately.

@JMS55 JMS55 added this to the 0.11 milestone Apr 22, 2023
@fxtressia
Copy link
Author

I'm really sorry. I haven't been able to look into this PR for the last few weeks.

  • I used it to do the rounded buttons for https://ickshonpe.itch.io/pillars and there were some compatibility issues. On some systems, it just rendered flat grey rectangles instead of the buttons.

Ah, what systems are they?

@fxtressia
Copy link
Author

It only renders uniform borders. I tried for a little while to get non-uniform borders working with it but couldn't quite get them right.

What was the problem?

@ickshonpe
Copy link
Contributor

ickshonpe commented Apr 27, 2023

I'm really sorry. I haven't been able to look into this PR for the last few weeks.

  • I used it to do the rounded buttons for https://ickshonpe.itch.io/pillars and there were some compatibility issues. On some systems, it just rendered flat grey rectangles instead of the buttons.

Ah, what systems are they?

It was a while ago and only a small sample size but the problems were with the wasm build for some linux users.

@ickshonpe
Copy link
Contributor

It only renders uniform borders. I tried for a little while to get non-uniform borders working with it but couldn't quite get them right.

What was the problem?

I think what I struggled with was getting the radii of the corners of the inner and outer rectangles to match perfectly when the border edges had non-uniform thicknesses.

@Dimchikkk
Copy link
Contributor

Would be amazing to start making pretty ui with corner radius in bevy 0.11, how far is it from completion? :)

@nicoburns nicoburns mentioned this pull request Jun 2, 2023
@fxtressia fxtressia marked this pull request as ready for review June 3, 2023 05:46
@fxtressia
Copy link
Author

fxtressia commented Jun 3, 2023

Would be amazing to start making pretty ui with corner radius in bevy 0.11, how far is it from completion? :)

It should be okay to be used in a private fork, but I believe this needs some reviews first before being merged.

Natalia Asteria added 3 commits June 11, 2023 04:48
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
Signed-off-by: Natalia Asteria <fortressnordlys@outlook.com>
@fxtressia fxtressia requested a review from JMS55 June 11, 2023 12:45
@fxtressia fxtressia mentioned this pull request Jun 12, 2023
@alice-i-cecile
Copy link
Member

Completed in #7795 :) Thanks a ton for this regardless: it was helpful to see another take on the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add proper border support for UI nodes

8 participants