Skip to content

Commit ca873e7

Browse files
authored
Implement serialize and deserialize for some UI types (#10044)
# Objective - Add serde Deserialize and Serialize for structs that doesn't implement it, even if they could benefit from it ## Solution - Derive these traits for the structs Style, BackgroundColor, BorderColor and Outline. ---
1 parent a52ca17 commit ca873e7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/bevy_ui/src/ui_node.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ impl Default for Node {
117117
/// - [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different CSS Grid properties and how they work.
118118
/// - [CSS Grid Garden](https://cssgridgarden.com/). An interactive tutorial/game that teaches the essential parts of CSS Grid in a fun engaging way.
119119
120-
#[derive(Component, Clone, PartialEq, Debug, Reflect)]
121-
#[reflect(Component, Default, PartialEq)]
120+
#[derive(Component, Clone, PartialEq, Debug, Deserialize, Serialize, Reflect)]
121+
#[reflect(Component, Default, PartialEq, Deserialize, Serialize)]
122122
pub struct Style {
123123
/// Which layout algorithm to use when laying out this node's contents:
124124
/// - [`Display::Flex`]: Use the Flexbox layout algorithm
@@ -1420,8 +1420,8 @@ pub enum GridPlacementError {
14201420
///
14211421
/// This serves as the "fill" color.
14221422
/// When combined with [`UiImage`], tints the provided texture.
1423-
#[derive(Component, Copy, Clone, Debug, Reflect)]
1424-
#[reflect(Component, Default)]
1423+
#[derive(Component, Copy, Clone, Debug, Deserialize, Serialize, Reflect)]
1424+
#[reflect(Component, Default, Deserialize, Serialize)]
14251425
pub struct BackgroundColor(pub Color);
14261426

14271427
impl BackgroundColor {
@@ -1453,8 +1453,8 @@ pub struct UiTextureAtlasImage {
14531453
}
14541454

14551455
/// The border color of the UI node.
1456-
#[derive(Component, Copy, Clone, Debug, Reflect)]
1457-
#[reflect(Component, Default)]
1456+
#[derive(Component, Copy, Clone, Debug, Deserialize, Serialize, Reflect)]
1457+
#[reflect(Component, Default, Deserialize, Serialize)]
14581458
pub struct BorderColor(pub Color);
14591459

14601460
impl From<Color> for BorderColor {
@@ -1473,8 +1473,8 @@ impl Default for BorderColor {
14731473
}
14741474
}
14751475

1476-
#[derive(Component, Copy, Clone, Default, Debug, Reflect)]
1477-
#[reflect(Component, Default)]
1476+
#[derive(Component, Copy, Clone, Default, Debug, Deserialize, Serialize, Reflect)]
1477+
#[reflect(Component, Default, Deserialize, Serialize)]
14781478
/// The [`Outline`] component adds an outline outside the edge of a UI node.
14791479
/// Outlines do not take up space in the layout
14801480
///

0 commit comments

Comments
 (0)