Skip to content
Snippets Groups Projects
Commit 7f9372cf authored by StarToaster's avatar StarToaster
Browse files

Fixed formatting issues.

parent c55bc0c1
No related branches found
No related tags found
No related merge requests found
......@@ -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));
......
......@@ -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)));
}
......
......@@ -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()
}
}
}
......
......@@ -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() {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
}
......
......@@ -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));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment