Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Node Border Radius and Shadows #8973

Closed
wants to merge 76 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
e772dfe
`bevy_ui` changes
ickshonpe Jun 27, 2023
7a49efb
Added invert corners mode to `ui.wgsl`
ickshonpe Jun 27, 2023
b86bd5a
Corruption resolved, the rect field for the inner border rect should …
ickshonpe Jun 27, 2023
728b866
Check for border radius should have greater than not greater or equal…
ickshonpe Jun 27, 2023
b8f784e
Implemented inner radius for partial borders
ickshonpe Jun 27, 2023
3b6fa71
Cleaned up `ui.wgsl` a bit
ickshonpe Jun 27, 2023
8cf677a
cleaned up fragnment shader
ickshonpe Jun 27, 2023
f8f035d
`ui.wgsl`
ickshonpe Jun 27, 2023
8c7b7e4
`extract_uinode_borders`
ickshonpe Jun 27, 2023
0a2e8b5
cargo fmt --all
ickshonpe Jun 27, 2023
9c2fbc6
Merge branch 'main' into rounded-nodes
ickshonpe Jun 27, 2023
87e1429
Clean up.
ickshonpe Jun 27, 2023
661eb8a
Adds support for non-uniform corner rounding.
ickshonpe Jun 28, 2023
8dc2f88
Most bugs seem to be fixed, remaining case is with two adjacent roun…
ickshonpe Jun 28, 2023
c0cf89e
Clean up, cargo fmt
ickshonpe Jun 28, 2023
26d8451
Removed unused import.
ickshonpe Jun 28, 2023
0350886
`UiCornerRadius`:
ickshonpe Jun 29, 2023
c900671
cargo fmt
ickshonpe Jun 29, 2023
b9cc579
`bevy_ui::node_bundles`
ickshonpe Jun 30, 2023
49618a4
`many_buttons`
ickshonpe Jun 30, 2023
e855a8b
Use the `as_rainbow` function for border colors too.
ickshonpe Jun 30, 2023
a7cbf3a
cargo fmt --all
ickshonpe Jun 30, 2023
588c0ae
Use percentages for border values
ickshonpe Jun 30, 2023
eaf714d
Merge branch 'many-buttons-bordered' into rounded-nodes
ickshonpe Jun 30, 2023
667d69e
Removed `FromReflect` derive from `UiBorderRadius`.
ickshonpe Jun 30, 2023
67630fe
Fixed textures.
ickshonpe Jun 30, 2023
d9e98eb
fixes for ci lints
ickshonpe Jun 30, 2023
ae2b5c3
Merge branch 'many-buttons-bordered' into rounded-nodes
ickshonpe Jun 30, 2023
c95b5b4
Added more doc comments.
ickshonpe Jun 30, 2023
e7d86a8
Update crates/bevy_ui/src/ui_node.rs
ickshonpe Jun 30, 2023
c575717
add missing `UiBorderRadius` import to doc comment example
ickshonpe Jun 30, 2023
2513156
added border and round corners to game menu example
ickshonpe Jun 30, 2023
b49bdcd
Added missing default to `Style` declaration in the `border_radius` d…
ickshonpe Jun 30, 2023
8330dc7
better AA
ickshonpe Jul 1, 2023
1543c9b
`UiNodeShadow`
ickshonpe Jul 3, 2023
8a7d9e0
Added an index buffer to UI renderer.
ickshonpe Jul 3, 2023
9cb44bb
Almost there, but 0 size borders rendered
ickshonpe Jul 3, 2023
9db2de6
Fixed corner and border values to map correctly from bevy types to sh…
ickshonpe Jul 3, 2023
c95317b
chopped
ickshonpe Jul 4, 2023
adb8ace
Added `with_left`, `with_right`, `with_top`, `with_bottom` `UiRect` …
ickshonpe Jul 4, 2023
d099ae4
Merge branch 'rounded-nodes' into rounded-nodes-index-buffer-two-colors
ickshonpe Jul 4, 2023
86f851a
`bevy_ui::geometry::UiRect`
ickshonpe Jul 4, 2023
fbdd5a9
Merge branch 'ui-rect-builder-funcs' into rounded-nodes-index-buffer-…
ickshonpe Jul 4, 2023
b6b0ca2
All unrounded cases seem to be working now.
ickshonpe Jul 4, 2023
2560785
Update examples/stress_tests/many_buttons.rs
ickshonpe Jul 4, 2023
29139ef
rounded rects displaying correctly
ickshonpe Jul 4, 2023
91e0795
Clean up ui shader dead code
ickshonpe Jul 4, 2023
f342980
`bevy_ui::render`
ickshonpe Jul 4, 2023
bdda002
cargo fmt
ickshonpe Jul 4, 2023
49ce0c4
formatting
ickshonpe Jul 4, 2023
77f625c
`ui.wgsl`
ickshonpe Jul 5, 2023
ceda428
`bevy_ui::render`
ickshonpe Jul 5, 2023
afe327e
`ui.wgsl`
ickshonpe Jul 5, 2023
1d6b976
Merge branch 'rounded-nodes-box-shadow' into border-radius-box-shadow
ickshonpe Jul 5, 2023
7d908b1
fix merge
ickshonpe Jul 5, 2023
0663393
`UiNodeShadow`
ickshonpe Jul 5, 2023
87ee2c7
Clean up + cargo fmt
ickshonpe Jul 5, 2023
7963803
`bevy_ui::render` module
ickshonpe Jul 5, 2023
8d0af9d
cargo fmt
ickshonpe Jul 5, 2023
b2cd4ae
Merge branch 'rounded-nodes' of https://github.com/ickshonpe/bevy int…
ickshonpe Jul 5, 2023
0ceaba9
Merge branch 'border-radius-box-shadow' into rounded-nodes
ickshonpe Jul 5, 2023
a32ef6b
comments
ickshonpe Jul 5, 2023
19da4b1
Reordered UiBorderRadius methods.
ickshonpe Jul 5, 2023
dfebacf
fix whitespace
ickshonpe Jul 5, 2023
4294fd9
formatting
ickshonpe Jul 6, 2023
3d2c438
Adjusted shadow defaults.
ickshonpe Jul 6, 2023
d84c61e
`UiShadow`
ickshonpe Jul 7, 2023
65c92be
`ui.wgsl` changes:
ickshonpe Jul 7, 2023
737ea7f
`bevy_ui::render`
ickshonpe Jul 7, 2023
6018ab6
Added an alternative sdf function that sets the inner radius to zero …
ickshonpe Jul 7, 2023
2adc733
Swapped the default inner radius behaviour back to how it was. Slight…
ickshonpe Jul 7, 2023
e4eca30
`ui.wgsl`: `sd_rounded_box` refactor
ickshonpe Jul 7, 2023
b2896bd
`bevy_ui::render`
ickshonpe Jul 10, 2023
5e9fab2
`ExtractedUiNode`
ickshonpe Jul 11, 2023
63b1967
`ui.wgsl`
ickshonpe Jul 13, 2023
c04e484
`prepare_uinodes`
ickshonpe Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions crates/bevy_ui/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,82 @@ impl UiRect {
..Default::default()
}
}

/// Returns the [`UiRect`] with its `left` field set to the given value.
///
/// # Example
///
/// ```
/// # use bevy_ui::{UiRect, Val};
/// #
/// let ui_rect = UiRect::all(Val::Vw(25.)).with_left(Val::Px(10.);
/// assert_eq!(ui_rect.left, Val::Vw(10.));
/// assert_eq!(ui_rect.right, Val::Px(25.));
/// assert_eq!(ui_rect.top, Val::Vw(25.));
/// assert_eq!(ui_rect.bottom, Val::Vw(25.0));
/// ```
#[inline]
pub fn with_left(mut self, left: Val) -> UiRect {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should probably use Self instead of UiRect here. (Repeat with similar methods)

Suggested change
pub fn with_left(mut self, left: Val) -> UiRect {
pub fn with_left(mut self, left: Val) -> Self {

self.left = left;
self
}

/// Returns the [`UiRect`] with its `right` field set to the given value.
///
/// # Example
///
/// ```
/// # use bevy_ui::{UiRect, Val};
/// #
/// let ui_rect = UiRect::all(Val::Vw(25.)).with_right(Val::Px(10.);
/// assert_eq!(ui_rect.left, Val::Vw(25.));
/// assert_eq!(ui_rect.right, Val::Px(10.));
/// assert_eq!(ui_rect.top, Val::Vw(25.));
/// assert_eq!(ui_rect.bottom, Val::Vw(25.0));
/// ```
#[inline]
pub fn with_right(mut self, right: Val) -> UiRect {
self.right = right;
self
}

/// Returns the [`UiRect`] with its `top` field set to the given value.
///
/// # Example
///
/// ```
/// # use bevy_ui::{UiRect, Val};
/// #
/// let ui_rect = UiRect::all(Val::Vw(25.)).with_top(Val::Px(10.);
/// assert_eq!(ui_rect.left, Val::Vw(25.));
/// assert_eq!(ui_rect.right, Val::Vw(25.));
/// assert_eq!(ui_rect.top, Val::Px(10.));
/// assert_eq!(ui_rect.bottom, Val::Vw(25.0));
/// ```
#[inline]
pub fn with_top(mut self, top: Val) -> UiRect {
self.top = top;
self
}

/// Returns the [`UiRect`] with its `bottom` field set to the given value.
///
/// # Example
///
/// ```
/// # use bevy_ui::{UiRect, Val};
/// #
/// let ui_rect = UiRect::all(Val::Vw(25.)).with_bottom(Val::Px(10.);
/// assert_eq!(ui_rect.left, Val::Vw(25.));
/// assert_eq!(ui_rect.right, Val::Vw(25.));
/// assert_eq!(ui_rect.top, Val::Vw(25.));
/// assert_eq!(ui_rect.bottom, Val::Px(10.0));
/// ```
#[inline]
pub fn with_bottom(mut self, bottom: Val) -> UiRect {
self.bottom = bottom;
self
}
}

impl Default for UiRect {
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_ui/src/layout/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ mod tests {
],
grid_column: GridPlacement::start(4),
grid_row: GridPlacement::span(3),
border_radius: Default::default(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
border_radius: Default::default(),
border_radius: UiBorderRadius::default(),

};
let viewport_values = LayoutContext::new(1.0, bevy_math::Vec2::new(800., 600.));
let taffy_style = from_style(&viewport_values, &bevy_style);
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ impl Plugin for UiPlugin {
.register_type::<UiRect>()
.register_type::<Val>()
.register_type::<BorderColor>()
.register_type::<UiBorderRadius>()
.register_type::<UiShadow>()
.register_type::<widget::Button>()
.register_type::<widget::Label>()
.register_type::<ZIndex>()
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_ui/src/node_bundles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub struct ImageBundle {
///
/// Combines with `UiImage` to tint the provided image.
pub background_color: BackgroundColor,
/// The color of the Node's border
pub border_color: BorderColor,
/// The image of the node
pub image: UiImage,
/// The size of the image in pixels
Expand Down
Loading