From 7f9372cf3bf9be1276a489d4473e12816383abab Mon Sep 17 00:00:00 2001 From: StarToaster <startoaster23@gmail.com> Date: Wed, 9 Nov 2022 20:29:15 -0500 Subject: [PATCH] Fixed formatting issues. --- src/calculate_nodes.rs | 12 +++++++--- src/event_dispatcher.rs | 3 ++- src/focus_tree.rs | 4 +++- src/layout_dispatcher.rs | 4 +--- src/render/nine_patch/extract.rs | 7 ++++-- src/render/texture_atlas/extract.rs | 7 ++++-- src/tree.rs | 36 ++++++++++++++--------------- src/widget_context.rs | 10 ++------ 8 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/calculate_nodes.rs b/src/calculate_nodes.rs index 7d6a7a9..d3d0f61 100644 --- a/src/calculate_nodes.rs +++ b/src/calculate_nodes.rs @@ -114,12 +114,17 @@ pub fn calculate_nodes( dirty_entity, &mut styles, node_query - .get(dirty_entity.0).map(|(_, node)| node.raw_styles.clone().unwrap_or_default()) + .get(dirty_entity.0) + .map(|(_, node)| node.raw_styles.clone().unwrap_or_default()) .unwrap_or_default(), &all_styles_query, ); - let children = tree.children.get(&dirty_entity).cloned().unwrap_or_default(); + let children = tree + .children + .get(&dirty_entity) + .cloned() + .unwrap_or_default(); let width = styles.width.resolve().value_or(0.0, 0.0); let height = styles.height.resolve().value_or(0.0, 0.0); @@ -146,7 +151,8 @@ pub fn calculate_nodes( } } node.old_z = node_query - .get(dirty_entity.0).map(|old_node| old_node.1.z) + .get(dirty_entity.0) + .map(|old_node| old_node.1.z) .unwrap_or(0.0); node.z = current_z; new_nodes.insert(dirty_entity.0, (node, needs_layout)); diff --git a/src/event_dispatcher.rs b/src/event_dispatcher.rs index 970bc86..41d9227 100644 --- a/src/event_dispatcher.rs +++ b/src/event_dispatcher.rs @@ -421,7 +421,8 @@ impl EventDispatcher { for child in children { let child_z = world .entity(child.0) - .get::<Node>().map(|node| node.z) + .get::<Node>() + .map(|node| node.z) .unwrap_or(0.0); stack_children.push((child_z, (*child, depth + 1))); } diff --git a/src/focus_tree.rs b/src/focus_tree.rs index ab45348..038e8c6 100644 --- a/src/focus_tree.rs +++ b/src/focus_tree.rs @@ -208,7 +208,9 @@ impl FocusTracker { pub fn get_focusability(&self, index: WrappedIndex) -> Option<bool> { if let Some(focusable) = self.widgets.get(&index) { Some(*focusable) - } else { self.parents.get(&index).copied() } + } else { + self.parents.get(&index).copied() + } } } diff --git a/src/layout_dispatcher.rs b/src/layout_dispatcher.rs index 29be716..913c7ea 100644 --- a/src/layout_dispatcher.rs +++ b/src/layout_dispatcher.rs @@ -18,9 +18,7 @@ impl LayoutEventDispatcher { pub fn dispatch(context: &mut KayakRootContext, world: &mut World) { let on_event_entities = { let mut query = world.query_filtered::<Entity, With<OnLayout>>(); - query - .iter(world) - .collect::<HashSet<_>>() + query.iter(world).collect::<HashSet<_>>() }; if let Ok(layout_cache) = context.layout_cache.try_read() { diff --git a/src/render/nine_patch/extract.rs b/src/render/nine_patch/extract.rs index 7def341..a4d0b63 100644 --- a/src/render/nine_patch/extract.rs +++ b/src/render/nine_patch/extract.rs @@ -31,10 +31,13 @@ pub fn extract_nine_patch( return vec![]; } - let image_size = image.map(|i| Vec2::new( + let image_size = image + .map(|i| { + Vec2::new( i.texture_descriptor.size.width as f32, i.texture_descriptor.size.height as f32, - )) + ) + }) .unwrap() * dpi; diff --git a/src/render/texture_atlas/extract.rs b/src/render/texture_atlas/extract.rs index 3714aa7..ebc6692 100644 --- a/src/render/texture_atlas/extract.rs +++ b/src/render/texture_atlas/extract.rs @@ -32,10 +32,13 @@ pub fn extract_texture_atlas( return vec![]; } - let image_size = image.map(|i| Vec2::new( + let image_size = image + .map(|i| { + Vec2::new( i.texture_descriptor.size.width as f32, i.texture_descriptor.size.height as f32, - )) + ) + }) .unwrap() * dpi; diff --git a/src/tree.rs b/src/tree.rs index ae02765..a3b9468 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -196,21 +196,19 @@ impl Tree { } pub fn get_parent(&self, index: WrappedIndex) -> Option<WrappedIndex> { - self.parents - .get(&index).copied() + self.parents.get(&index).copied() } pub fn get_first_child(&self, index: WrappedIndex) -> Option<WrappedIndex> { - self.children.get(&index).and_then(|children| { - children - .first().copied() - }) + self.children + .get(&index) + .and_then(|children| children.first().copied()) } pub fn get_last_child(&self, index: WrappedIndex) -> Option<WrappedIndex> { - self.children.get(&index).and_then(|children| { - children.last().copied() - }) + self.children + .get(&index) + .and_then(|children| children.last().copied()) } pub fn get_next_sibling(&self, index: WrappedIndex) -> Option<WrappedIndex> { @@ -218,10 +216,8 @@ impl Tree { self.children.get(&parent_index).and_then(|children| { children .iter() - .position(|child| *child == index).and_then(|child_index| { - children - .get(child_index + 1).copied() - }) + .position(|child| *child == index) + .and_then(|child_index| children.get(child_index + 1).copied()) }) } else { None @@ -233,10 +229,10 @@ impl Tree { self.children.get(&parent_index).and_then(|children| { children .iter() - .position(|child| *child == index).and_then(|child_index| { + .position(|child| *child == index) + .and_then(|child_index| { if child_index > 0 { - children - .get(child_index - 1).copied() + children.get(child_index - 1).copied() } else { None } @@ -285,12 +281,14 @@ impl Tree { let children_a = children_a .unwrap() - .iter().copied() + .iter() + .copied() .enumerate() .collect::<Vec<(usize, WrappedIndex)>>(); let children_b = children_b .unwrap() - .iter().copied() + .iter() + .copied() .enumerate() .collect::<Vec<(usize, WrappedIndex)>>(); @@ -834,7 +832,7 @@ impl<'a> Hierarchy<'a> for Tree { fn is_first_child(&self, node: WrappedIndex) -> bool { if let Some(parent) = self.parent(node) { if let Some(first_child) = self.get_first_child(parent) { - return first_child == node + return first_child == node; } } diff --git a/src/widget_context.rs b/src/widget_context.rs index d070384..588e1cc 100644 --- a/src/widget_context.rs +++ b/src/widget_context.rs @@ -197,10 +197,7 @@ impl KayakWidgetContext { // We need to add it to the ordered tree if let Ok(mut tree) = self.order_tree.try_write() { - tree.add( - WrappedIndex(entity.unwrap()), - parent_id.map(WrappedIndex), - ) + tree.add(WrappedIndex(entity.unwrap()), parent_id.map(WrappedIndex)) } } entity.unwrap() @@ -221,10 +218,7 @@ impl KayakWidgetContext { assert!(parent != entity, "Parent cannot equal entity!"); } if let Ok(mut tree) = self.new_tree.write() { - tree.add( - WrappedIndex(entity), - parent.map(WrappedIndex), - ); + tree.add(WrappedIndex(entity), parent.map(WrappedIndex)); } } -- GitLab