Skip to content

Commit

Permalink
cargo fmt --all
Browse files Browse the repository at this point in the history
  • Loading branch information
ickshonpe committed Mar 1, 2023
1 parent 33c8e91 commit 796b2e1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_text/src/text2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bevy_ecs::{
event::EventReader,
prelude::With,
reflect::ReflectComponent,
system::{Local, Query, Res, ResMut, Commands},
system::{Commands, Local, Query, Res, ResMut},
};
use bevy_math::{Vec2, Vec3};
use bevy_reflect::Reflect;
Expand Down
11 changes: 5 additions & 6 deletions crates/bevy_ui/src/flex/convert.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use taffy::prelude::Rect;
use taffy::prelude::LengthPercentage;
use taffy::prelude::LengthPercentageAuto;
use taffy::style::Dimension;
use crate::Breadth;
use crate::JustifySelf;
use crate::{
AlignContent, AlignItems, AlignSelf, Display, FlexDirection, FlexWrap, JustifyContent,
PositionType, Style, Val,
};
use taffy::prelude::LengthPercentage;
use taffy::prelude::LengthPercentageAuto;
use taffy::prelude::Rect;
use taffy::style::Dimension;

fn from_val(scale_factor: f64, val: Val) -> LengthPercentageAuto {
match val {
Expand Down Expand Up @@ -48,7 +48,7 @@ pub fn from_style(scale_factor: f64, style: &Style) -> taffy::style::Style {
align_self: style.align_self.into(),
align_content: Some(style.align_content.into()),
justify_content: Some(style.justify_content.into()),
justify_self: style.justify_self.into(),
justify_self: style.justify_self.into(),
margin: Rect {
left: from_val(scale_factor, style.margin.left),
right: from_val(scale_factor, style.margin.right),
Expand Down Expand Up @@ -184,7 +184,6 @@ impl From<JustifySelf> for Option<taffy::style::AlignItems> {
}
}


impl From<PositionType> for taffy::style::Position {
fn from(value: PositionType) -> Self {
match value {
Expand Down
11 changes: 8 additions & 3 deletions crates/bevy_ui/src/flex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use bevy_window::{PrimaryWindow, Window, WindowResolution, WindowScaleFactorChan
use std::fmt;
use taffy::{
prelude::{AvailableSpace, Size},
Taffy, style_helpers::TaffyMaxContent,
style_helpers::TaffyMaxContent,
Taffy,
};

#[derive(Resource)]
Expand Down Expand Up @@ -63,11 +64,15 @@ impl FlexSurface {
let taffy = &mut self.taffy;
let taffy_node = self.entity_to_taffy.entry(entity).or_insert_with(|| {
added = true;
taffy.new_leaf(convert::from_style(scale_factor, style)).unwrap()
taffy
.new_leaf(convert::from_style(scale_factor, style))
.unwrap()
});

if !added {
self.taffy.set_style(*taffy_node, convert::from_style(scale_factor, style)).unwrap();
self.taffy
.set_style(*taffy_node, convert::from_style(scale_factor, style))
.unwrap();
}
}

Expand Down
17 changes: 8 additions & 9 deletions crates/bevy_ui/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Val, Breadth};
use crate::{Breadth, Val};
use bevy_reflect::Reflect;
use std::ops::{Div, DivAssign, Mul, MulAssign};

Expand Down Expand Up @@ -367,9 +367,10 @@ pub struct Size<T: Default + Copy + Clone + PartialEq = Val> {
pub height: T,
}

impl <T> Size<T> where T: Default + Copy + Clone + PartialEq {


impl<T> Size<T>
where
T: Default + Copy + Clone + PartialEq,
{
/// Creates a new [`Size`] from a width and a height.
///
/// # Example
Expand Down Expand Up @@ -420,7 +421,7 @@ impl <T> Size<T> where T: Default + Copy + Clone + PartialEq {
pub fn width(width: T) -> Self {
Self {
width,
.. Self::default()
..Self::default()
}
}

Expand All @@ -437,9 +438,9 @@ impl <T> Size<T> where T: Default + Copy + Clone + PartialEq {
/// assert_eq!(size.height, Val::Px(10.));
/// ```
pub fn height(height: T) -> Self {
Self {
Self {
height,
.. Self::default()
..Self::default()
}
}
}
Expand All @@ -455,8 +456,6 @@ impl Size<Breadth> {
pub const DEFAULT_BREADTH: Self = Self::all(Breadth::DEFAULT);
}



impl From<(Val, Val)> for Size {
fn from(vals: (Val, Val)) -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/ui_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ pub struct Style {
/// ..Default::default()
/// };
/// ```
/// 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.
/// 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<Breadth>,
/// The border of the node
pub border: UiRect<Breadth>,
Expand Down Expand Up @@ -493,7 +493,7 @@ impl Style {
align_self: AlignSelf::DEFAULT,
align_content: AlignContent::DEFAULT,
justify_content: JustifyContent::DEFAULT,
justify_self: JustifySelf::DEFAULT,
justify_self: JustifySelf::DEFAULT,
margin: UiRect::all(Val::Px(0.)),
padding: UiRect::all(Breadth::Px(0.)),
border: UiRect::all(Breadth::Px(0.)),
Expand Down

0 comments on commit 796b2e1

Please sign in to comment.