From 0fdc44ea09ec45f55d457e7faa629ea315c37838 Mon Sep 17 00:00:00 2001 From: Ickshonpe Date: Wed, 22 Feb 2023 12:28:32 +0000 Subject: [PATCH 1/4] Expanded the doc comment for the `padding` field of `Style`. --- crates/bevy_ui/src/ui_node.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 588cb141d3f38..27996080b2fb8 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -239,7 +239,9 @@ pub struct Style { pub position: UiRect, /// The margin of the node pub margin: UiRect, - /// The padding of the node + /// The space between the edges of the node and its contents + /// + /// If a percentage value is used, the percentage is calculated based on the width of the parent node. pub padding: UiRect, /// The border of the node pub border: UiRect, From 544caa1d652d732496eea069c5454c6c50ffe0b9 Mon Sep 17 00:00:00 2001 From: Ickshonpe Date: Wed, 22 Feb 2023 15:17:43 +0000 Subject: [PATCH 2/4] add comment for margins --- crates/bevy_ui/src/ui_node.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 27996080b2fb8..18b303373d113 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -237,10 +237,12 @@ pub struct Style { pub justify_content: JustifyContent, /// The position of the node as described by its Rect pub position: UiRect, - /// The margin of the node + /// The amount of space around the node outside its border + /// + /// If a percentage value is used, the percentage is calculated based on the width of the parent node. pub margin: UiRect, /// The space between the edges of the node and its contents - /// + /// /// If a percentage value is used, the percentage is calculated based on the width of the parent node. pub padding: UiRect, /// The border of the node From 7330a0658587e140909e2295d47103120a2e7717 Mon Sep 17 00:00:00 2001 From: Ickshonpe Date: Wed, 22 Feb 2023 23:27:06 +0000 Subject: [PATCH 3/4] included examples with the comments --- crates/bevy_ui/src/ui_node.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 18b303373d113..9a2e5df86322d 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -240,10 +240,40 @@ pub struct Style { /// The amount of space around the node outside its border /// /// If a percentage value is used, the percentage is calculated based on the width of the parent node. + /// For example, if a node has the style component: + /// ``` + /// # use bevy_ui::{Style, UiRect, Val}; + /// let style = Style { + /// flex_basis: Val::Percent(100.), + /// margin: UiRect { + /// left: Val::Percent(10.), + /// right: Val::Percent(10.), + /// top: Val::Percent(15.), + /// bottom: Val::Percent(15.) + /// }, + /// ..Default::default() + /// }; + /// ``` + /// and a parent with dimensions of 100px by 300px, then the node's margins will be 10px on both left and right, and 15px on both top and bottom. pub margin: UiRect, /// The space between the edges of the node and its contents /// /// If a percentage value is used, the percentage is calculated based on the width of the parent node. + /// For example, if a node has the style component: + /// ``` + /// # use bevy_ui::{Style, UiRect, Val}; + /// let style = Style { + /// flex_basis: Val::Percent(100.), + /// padding: UiRect { + /// left: Val::Percent(1.), + /// right: Val::Percent(2.), + /// top: Val::Percent(3.), + /// bottom: Val::Percent(4.) + /// }, + /// ..Default::default() + /// }; + /// ``` + /// and a parent with dimensions of 300px by 100px, then the node's padding will be 3px on the left, 6px on the right, 9px on the top and 12px on the bottom. pub padding: UiRect, /// The border of the node pub border: UiRect, From 238aaa6e24b39aaf8b7bb86b67e52b8402571057 Mon Sep 17 00:00:00 2001 From: Ickshonpe Date: Thu, 23 Feb 2023 09:33:12 +0000 Subject: [PATCH 4/4] improved examples --- crates/bevy_ui/src/ui_node.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/bevy_ui/src/ui_node.rs b/crates/bevy_ui/src/ui_node.rs index 9a2e5df86322d..38b88ecbdcbe7 100644 --- a/crates/bevy_ui/src/ui_node.rs +++ b/crates/bevy_ui/src/ui_node.rs @@ -237,14 +237,14 @@ pub struct Style { pub justify_content: JustifyContent, /// The position of the node as described by its Rect pub position: UiRect, - /// The amount of space around the node outside its border + /// The amount of space around a node outside its border. /// /// If a percentage value is used, the percentage is calculated based on the width of the parent node. - /// For example, if a node has the style component: + /// + /// # Example /// ``` /// # use bevy_ui::{Style, UiRect, Val}; /// let style = Style { - /// flex_basis: Val::Percent(100.), /// margin: UiRect { /// left: Val::Percent(10.), /// right: Val::Percent(10.), @@ -254,16 +254,16 @@ pub struct Style { /// ..Default::default() /// }; /// ``` - /// and a parent with dimensions of 100px by 300px, then the node's margins will be 10px on both left and right, and 15px on both top and bottom. + /// A node with this style and a parent with dimensions of 100px by 300px, will have calculated margins of 10px on both left and right edges, and 15px on both top and bottom egdes. pub margin: UiRect, - /// The space between the edges of the node and its contents + /// The amount of space between the edges of a node and its contents. /// /// If a percentage value is used, the percentage is calculated based on the width of the parent node. - /// For example, if a node has the style component: + /// + /// # Example /// ``` /// # use bevy_ui::{Style, UiRect, Val}; /// let style = Style { - /// flex_basis: Val::Percent(100.), /// padding: UiRect { /// left: Val::Percent(1.), /// right: Val::Percent(2.), @@ -273,7 +273,7 @@ pub struct Style { /// ..Default::default() /// }; /// ``` - /// and a parent with dimensions of 300px by 100px, then the node's padding will be 3px on the left, 6px on the right, 9px on the top and 12px on the bottom. + /// A node with this style and a parent with dimensions of 300px by 100px, will have calculated padding of 3px on the left, 6px on the right, 9px on the top and 12px on the bottom. pub padding: UiRect, /// The border of the node pub border: UiRect,