From f114631ca52bf848c5d105225ef3c72e57c37cad Mon Sep 17 00:00:00 2001 From: Taylor Holliday Date: Sat, 19 Aug 2023 10:27:49 -0700 Subject: [PATCH] fmt --- examples/counter_redux_nested.rs | 25 ++++++++++++++----------- examples/counter_redux_redux.rs | 10 ++++++---- src/context.rs | 6 ++++-- src/viewid.rs | 2 +- src/views/anim.rs | 7 +++---- src/views/background.rs | 3 +-- src/views/canvas.rs | 11 +++++++---- src/views/clip.rs | 17 ++++++++++------- src/views/command.rs | 10 +++++----- src/views/drag.rs | 24 ++++++++++++------------ src/views/env.rs | 4 ++-- src/views/flex.rs | 6 +++--- src/views/geom.rs | 17 ++++++++++------- src/views/handle.rs | 5 ++--- src/views/hover.rs | 2 +- src/views/key.rs | 2 +- src/views/list.rs | 20 +++++++++++++++++--- src/views/offset.rs | 5 ++--- src/views/padding.rs | 13 +++++-------- src/views/role.rs | 4 ++-- src/views/shapes.rs | 22 ++++++++++++++-------- src/views/size.rs | 6 +++--- src/views/stack.rs | 8 ++++++-- src/views/tap.rs | 4 ++-- src/views/window.rs | 12 ++++++------ 25 files changed, 139 insertions(+), 106 deletions(-) diff --git a/examples/counter_redux_nested.rs b/examples/counter_redux_nested.rs index d1079da..3f0bdcf 100644 --- a/examples/counter_redux_nested.rs +++ b/examples/counter_redux_nested.rs @@ -30,17 +30,20 @@ fn main() { rui(redux(AppState::new, reduce, |app_state| { vstack(( format!("{}", app_state.count).padding(Auto), - state(|| 0, |handle, _| { - button("increment every 5 clicks", move|cx| { - cx[handle] += 1; - if cx[handle] == 5 { - cx[handle] = 0; - Action::Increment - } else { - Action::None - } - }) - }), + state( + || 0, + |handle, _| { + button("increment every 5 clicks", move |cx| { + cx[handle] += 1; + if cx[handle] == 5 { + cx[handle] = 0; + Action::Increment + } else { + Action::None + } + }) + }, + ), )) })); } diff --git a/examples/counter_redux_redux.rs b/examples/counter_redux_redux.rs index 24b2bf9..ea722dc 100644 --- a/examples/counter_redux_redux.rs +++ b/examples/counter_redux_redux.rs @@ -52,9 +52,11 @@ fn main() { rui(redux(AppState::new, reduce, |app_state| { vstack(( format!("{}", app_state.count).padding(Auto), - redux(|| LocalState{ count: 0 }, reduce_local, |_| { - button_a("increment every 5 clicks", LocalAction::Increment) - }), + redux( + || LocalState { count: 0 }, + reduce_local, + |_| button_a("increment every 5 clicks", LocalAction::Increment), + ), )) })); -} \ No newline at end of file +} diff --git a/src/context.rs b/src/context.rs index c98b218..a99a72a 100644 --- a/src/context.rs +++ b/src/context.rs @@ -182,7 +182,7 @@ impl Context { // Get a new accesskit tree. let mut nodes = vec![]; - + view.access(&mut path, self, &mut nodes); assert_eq!(path.len(), 1); @@ -334,7 +334,9 @@ impl Context { pub(crate) fn update_layout(&mut self, path: &IdPath, layout_box: LayoutBox) { match self.layout.get_mut(path) { Some(bref) => *bref = layout_box, - None => { self.layout.insert(path.clone(), layout_box); } + None => { + self.layout.insert(path.clone(), layout_box); + } } } diff --git a/src/viewid.rs b/src/viewid.rs index b15a1c0..8248572 100644 --- a/src/viewid.rs +++ b/src/viewid.rs @@ -39,4 +39,4 @@ pub fn hh(index: &H) -> u64 { let mut hasher = DefaultHasher::new(); index.hash(&mut hasher); hasher.finish() -} \ No newline at end of file +} diff --git a/src/views/anim.rs b/src/views/anim.rs index 65dee0a..01bf492 100644 --- a/src/views/anim.rs +++ b/src/views/anim.rs @@ -32,10 +32,9 @@ where (self.func)(cx, 1.0 / 60.0) // XXX: assume 60fps for now. } - path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -86,7 +85,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/background.rs b/src/views/background.rs index f51a8c1..a9a1973 100644 --- a/src/views/background.rs +++ b/src/views/background.rs @@ -41,8 +41,7 @@ where let child_size = self.child.layout(path, args); path.pop(); path.push(1); - self.background - .layout(path, &mut args.size(child_size)); + self.background.layout(path, &mut args.size(child_size)); path.pop(); child_size } diff --git a/src/views/canvas.rs b/src/views/canvas.rs index 85e4fb9..50521cc 100644 --- a/src/views/canvas.rs +++ b/src/views/canvas.rs @@ -19,10 +19,13 @@ where } fn layout(&self, path: &mut IdPath, args: &mut LayoutArgs) -> LocalSize { - args.cx.update_layout(path, LayoutBox { - rect: LocalRect::new(LocalPoint::zero(), args.sz), - offset: LocalOffset::zero(), - }); + args.cx.update_layout( + path, + LayoutBox { + rect: LocalRect::new(LocalPoint::zero(), args.sz), + offset: LocalOffset::zero(), + }, + ); args.sz } diff --git a/src/views/clip.rs b/src/views/clip.rs index d65b49c..ec5cfe9 100644 --- a/src/views/clip.rs +++ b/src/views/clip.rs @@ -30,8 +30,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -49,10 +49,13 @@ path.pop(); path.push(0); self.child.layout(path, args); path.pop(); - args.cx.update_layout(path, LayoutBox { - rect: LocalRect::new(LocalPoint::zero(), args.sz), - offset: LocalOffset::zero(), - }); + args.cx.update_layout( + path, + LayoutBox { + rect: LocalRect::new(LocalPoint::zero(), args.sz), + offset: LocalOffset::zero(), + }, + ); // XXX: should this expand to the available space? args.sz } @@ -93,7 +96,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/command.rs b/src/views/command.rs index fd81d2f..439f309 100644 --- a/src/views/command.rs +++ b/src/views/command.rs @@ -41,8 +41,8 @@ where } } path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -277,8 +277,8 @@ where }); } path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -328,7 +328,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/drag.rs b/src/views/drag.rs index ebb872a..b854b41 100644 --- a/src/views/drag.rs +++ b/src/views/drag.rs @@ -61,7 +61,7 @@ where actions.push(Box::new((self.func)( cx, - [0.0,0.0].into(), + [0.0, 0.0].into(), GestureState::Began, cx.mouse_button, ))); @@ -298,13 +298,12 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } impl private::Sealed for DragS {} - #[cfg(test)] mod tests { @@ -316,12 +315,7 @@ mod tests { let ui = state( || vec![], - |states, _| { - rectangle() - .drag(move |cx, _delta, state, _| { - cx[states].push(state) - }) - }, + |states, _| rectangle().drag(move |cx, _delta, state, _| cx[states].push(state)), ); let sz = [100.0, 100.0].into(); let mut path = vec![0]; @@ -362,7 +356,13 @@ mod tests { } assert_eq!(path.len(), 1); - assert_eq!(cx[s], vec![GestureState::Began, GestureState::Changed, GestureState::Ended]); - + assert_eq!( + cx[s], + vec![ + GestureState::Began, + GestureState::Changed, + GestureState::Ended + ] + ); } -} \ No newline at end of file +} diff --git a/src/views/env.rs b/src/views/env.rs index 87b9360..df82e02 100644 --- a/src/views/env.rs +++ b/src/views/env.rs @@ -120,8 +120,8 @@ where ) { let old = cx.set_env(&self.env_val); path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); old.and_then(|s| cx.set_env(&s)); } diff --git a/src/views/flex.rs b/src/views/flex.rs index 34dad3d..61712ea 100644 --- a/src/views/flex.rs +++ b/src/views/flex.rs @@ -18,8 +18,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -69,7 +69,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } fn is_flexible(&self) -> bool { diff --git a/src/views/geom.rs b/src/views/geom.rs index 724f777..d7aa206 100644 --- a/src/views/geom.rs +++ b/src/views/geom.rs @@ -20,8 +20,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -37,10 +37,13 @@ path.pop(); let sz = self.child.layout(path, args); path.pop(); - args.cx.update_layout(path, LayoutBox { - rect: LocalRect::new(LocalPoint::zero(), sz), - offset: LocalOffset::zero(), - }); + args.cx.update_layout( + path, + LayoutBox { + rect: LocalRect::new(LocalPoint::zero(), sz), + offset: LocalOffset::zero(), + }, + ); sz } @@ -80,7 +83,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/handle.rs b/src/views/handle.rs index 668a166..290ecd9 100644 --- a/src/views/handle.rs +++ b/src/views/handle.rs @@ -40,8 +40,7 @@ where ) { let mut child_actions = vec![]; path.push(0); - self.child - .process(event, path, cx, &mut child_actions); + self.child.process(event, path, cx, &mut child_actions); path.pop(); for action in child_actions { @@ -94,7 +93,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/hover.rs b/src/views/hover.rs index b93af72..af6da41 100644 --- a/src/views/hover.rs +++ b/src/views/hover.rs @@ -88,7 +88,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/key.rs b/src/views/key.rs index c55f4f1..abcb683 100644 --- a/src/views/key.rs +++ b/src/views/key.rs @@ -82,7 +82,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/list.rs b/src/views/list.rs index e02ae93..09f115e 100644 --- a/src/views/list.rs +++ b/src/views/list.rs @@ -38,7 +38,12 @@ where fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { for child in &self.ids { path.push(hh(child)); - let offset = args.cx.layout.get(path).map(|b| b.offset).unwrap_or_default(); + let offset = args + .cx + .layout + .get(path) + .map(|b| b.offset) + .unwrap_or_default(); args.vger.save(); @@ -90,7 +95,13 @@ where match args.cx.layout.get_mut(path) { Some(boxref) => boxref.offset = child_offset, None => { - args.cx.layout.insert(path.clone(), LayoutBox { rect: LocalRect::default(), offset: child_offset }); + args.cx.layout.insert( + path.clone(), + LayoutBox { + rect: LocalRect::default(), + offset: child_offset, + }, + ); } } @@ -219,7 +230,10 @@ where .collect(); builder.set_children(children); - nodes.push((hash(path).access_id(), builder.build(&mut cx.access_node_classes))); + nodes.push(( + hash(path).access_id(), + builder.build(&mut cx.access_node_classes), + )); Some(hash(path).access_id()) } } diff --git a/src/views/offset.rs b/src/views/offset.rs index 05361ab..653ecbb 100644 --- a/src/views/offset.rs +++ b/src/views/offset.rs @@ -42,8 +42,7 @@ where fn dirty(&self, path: &mut IdPath, xform: LocalToWorld, cx: &mut Context) { path.push(0); - self.child - .dirty(path, xform.pre_translate(self.offset), cx); + self.child.dirty(path, xform.pre_translate(self.offset), cx); path.pop(); } @@ -75,7 +74,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/padding.rs b/src/views/padding.rs index 8c04e20..c0e8a2a 100644 --- a/src/views/padding.rs +++ b/src/views/padding.rs @@ -20,8 +20,7 @@ where ) { let off = LocalOffset::new(self.padding, self.padding); path.push(0); - self.child - .process(&event.offset(-off), path, cx, actions); + self.child.process(&event.offset(-off), path, cx, actions); path.pop(); } @@ -56,11 +55,9 @@ where fn hittest(&self, path: &mut IdPath, pt: LocalPoint, cx: &mut Context) -> Option { path.push(0); - let hit_id = self.child.hittest( - path, - pt - LocalOffset::new(self.padding, self.padding), - cx, - ); + let hit_id = + self.child + .hittest(path, pt - LocalOffset::new(self.padding, self.padding), cx); path.pop(); hit_id } @@ -86,7 +83,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/role.rs b/src/views/role.rs index 3ca79d1..2db9d4e 100644 --- a/src/views/role.rs +++ b/src/views/role.rs @@ -29,8 +29,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { diff --git a/src/views/shapes.rs b/src/views/shapes.rs index ea72dd3..83040f4 100644 --- a/src/views/shapes.rs +++ b/src/views/shapes.rs @@ -30,10 +30,13 @@ impl View for Circle { } fn layout(&self, path: &mut IdPath, args: &mut LayoutArgs) -> LocalSize { - args.cx.update_layout(path, LayoutBox { - rect: LocalRect::new(LocalPoint::zero(), args.sz), - offset: LocalOffset::zero(), - }); + args.cx.update_layout( + path, + LayoutBox { + rect: LocalRect::new(LocalPoint::zero(), args.sz), + offset: LocalOffset::zero(), + }, + ); args.sz } @@ -100,10 +103,13 @@ impl View for Rectangle { } fn layout(&self, path: &mut IdPath, args: &mut LayoutArgs) -> LocalSize { - args.cx.update_layout(path, LayoutBox { - rect: LocalRect::new(LocalPoint::zero(), args.sz), - offset: LocalOffset::zero(), - }); + args.cx.update_layout( + path, + LayoutBox { + rect: LocalRect::new(LocalPoint::zero(), args.sz), + offset: LocalOffset::zero(), + }, + ); args.sz } diff --git a/src/views/size.rs b/src/views/size.rs index e85e0db..70bf7c8 100644 --- a/src/views/size.rs +++ b/src/views/size.rs @@ -22,8 +22,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -73,7 +73,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/stack.rs b/src/views/stack.rs index 21583ab..e9388d2 100644 --- a/src/views/stack.rs +++ b/src/views/stack.rs @@ -56,7 +56,12 @@ impl View for Stack let mut c = 0; self.children.foreach_view(&mut |child| { path.push(c); - let layout_box = args.cx.layout.get(path).map(|b| b.clone()).unwrap_or_default(); + let layout_box = args + .cx + .layout + .get(path) + .map(|b| b.clone()) + .unwrap_or_default(); args.vger.save(); @@ -122,7 +127,6 @@ impl View for Stack } for c in 0..(self.children.len() as u64) { - let ab = intervals[c as usize]; let child_offset = align_v( diff --git a/src/views/tap.rs b/src/views/tap.rs index 71297bd..a7ebef7 100644 --- a/src/views/tap.rs +++ b/src/views/tap.rs @@ -91,7 +91,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } @@ -185,7 +185,7 @@ where path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } diff --git a/src/views/window.rs b/src/views/window.rs index 6b800ba..c84553e 100644 --- a/src/views/window.rs +++ b/src/views/window.rs @@ -31,8 +31,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -86,7 +86,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } } @@ -118,8 +118,8 @@ where actions: &mut Vec>, ) { path.push(0); -self.child.process(event, path, cx, actions); -path.pop(); + self.child.process(event, path, cx, actions); + path.pop(); } fn draw(&self, path: &mut IdPath, args: &mut DrawArgs) { @@ -170,7 +170,7 @@ path.pop(); path.push(0); let node_id = self.child.access(path, cx, nodes); path.pop(); - node_id + node_id } }