diff --git a/crates/behavior/src/hit.rs b/crates/behavior/src/hit.rs index b8e32eaff..b8d863a65 100644 --- a/crates/behavior/src/hit.rs +++ b/crates/behavior/src/hit.rs @@ -307,7 +307,14 @@ pub fn resolve_mapped(shapes: &[Shape], point: Pos2, what: ResolveFo .then_with(|| distance(b).partial_cmp(&distance(a)).unwrap_or(Ordering::Equal)) .then(ia.cmp(ib)) }) - .map(|(index, shape)| Winner { index, owner: shape.owner, part: shape.part, sense: shape.sense, local: shape.local, drag_to_root: shape.drag_to_root }) + .map(|(index, shape)| Winner { + index, + owner: shape.owner, + part: shape.part, + sense: shape.sense, + local: shape.local, + drag_to_root: shape.drag_to_root, + }) } #[cfg(test)] diff --git a/crates/review/src/comments.rs b/crates/review/src/comments.rs index d66c726d5..9b5c4169d 100644 --- a/crates/review/src/comments.rs +++ b/crates/review/src/comments.rs @@ -126,7 +126,9 @@ pub struct CommentMessage { pub deletable: bool, } -fn message_deletable() -> bool { true } +fn message_deletable() -> bool { + true +} /// A comment and its replies. #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] diff --git a/crates/review/src/ui/thread/note_popup.rs b/crates/review/src/ui/thread/note_popup.rs index 4f4f665bd..9c37e0c6c 100644 --- a/crates/review/src/ui/thread/note_popup.rs +++ b/crates/review/src/ui/thread/note_popup.rs @@ -497,8 +497,10 @@ struct NoteWindow { impl NoteWindow { fn new(label: Label, overlay: Overlay, look: NoteLook, close_label: Label, allowed: bool, anchor: Option<(Rect, bool)>, selected: bool) -> Self { - let props = - ContainerProps::new().mount(Mount::Layer(overlay)).surface(SurfaceKind::Floating).header(HeaderRegion::new().band(DragBand::Move).trailing(true)); + let props = ContainerProps::new() + .mount(Mount::Layer(overlay)) + .surface(SurfaceKind::Floating) + .header(HeaderRegion::new().band(DragBand::Move).trailing(true)); NoteWindow { common: Common::new(), props, diff --git a/crates/review/tests/it/comments.rs b/crates/review/tests/it/comments.rs index 6e356db47..29efcf8b8 100644 --- a/crates/review/tests/it/comments.rs +++ b/crates/review/tests/it/comments.rs @@ -27,7 +27,9 @@ fn a_locked_comment_still_offers_reply_actions() { item.messages.push(message("Bo", "Reply")); let mut state = CommentsPanelState::default(); state.selected = Selection::single(ThreadId(1)); - let mut fixture = Fixture::new(move |ui| { let _ = CommentsPanel::new("Comments", std::slice::from_ref(&item), &mut state).show(ui); }); + let mut fixture = Fixture::new(move |ui| { + let _ = CommentsPanel::new("Comments", std::slice::from_ref(&item), &mut state).show(ui); + }); fixture.settle(); let more = fixture.by_label("More").expect("the reply menu"); fixture.click(&more).settle(); @@ -40,7 +42,9 @@ fn a_locked_comment_still_offers_reply_actions() { item.messages.push(reply); let mut state = CommentsPanelState::default(); state.selected = Selection::single(ThreadId(2)); - let mut fixture = Fixture::new(move |ui| { let _ = CommentsPanel::new("Comments", std::slice::from_ref(&item), &mut state).show(ui); }); + let mut fixture = Fixture::new(move |ui| { + let _ = CommentsPanel::new("Comments", std::slice::from_ref(&item), &mut state).show(ui); + }); fixture.settle(); let menus = fixture.by_role(Role::BUTTON); let reply_menu = menus.into_iter().filter(|target| fixture.tree().name_of(target.node) == Some("More")).last().expect("the reply menu"); diff --git a/crates/review/tests/it/signature.rs b/crates/review/tests/it/signature.rs index ded6af396..b036f2ed9 100644 --- a/crates/review/tests/it/signature.rs +++ b/crates/review/tests/it/signature.rs @@ -53,13 +53,11 @@ fn pad(draft: SignatureDraft) -> Rc> { fn clearing_a_scan_does_not_let_the_scan_restore_the_image() { let pad = pad(SignatureDraft { tab: SignatureTab::Scan, ..SignatureDraft::default() }); let mut pending = true; - pad.borrow_mut().dialog = SignaturePadDialog::new(SignatureDraft { tab: SignatureTab::Scan, ..SignatureDraft::default() }) - .scan(move |_, draft, event| { - match event { - ScanEvent::Clear => pending = false, - ScanEvent::Show(_) if pending => draft.image = Some(SignatureImage::new(5, 1, PHOTO.to_vec())), - ScanEvent::Show(_) => {} - } + pad.borrow_mut().dialog = + SignaturePadDialog::new(SignatureDraft { tab: SignatureTab::Scan, ..SignatureDraft::default() }).scan(move |_, draft, event| match event { + ScanEvent::Clear => pending = false, + ScanEvent::Show(_) if pending => draft.image = Some(SignatureImage::new(5, 1, PHOTO.to_vec())), + ScanEvent::Show(_) => {} }); let shown = pad.clone(); let mut fx = Fixture::new(move |ui| show(&shown, ui)); diff --git a/crates/ui-contract/src/primitives/sensing.rs b/crates/ui-contract/src/primitives/sensing.rs index 8767d4a6a..278179337 100644 --- a/crates/ui-contract/src/primitives/sensing.rs +++ b/crates/ui-contract/src/primitives/sensing.rs @@ -320,7 +320,8 @@ fn rotate(state: &mut ArenaState, pass_nr: u64) { } fn own_part_shape(part: &PartDecl, root: Id, position: u32, target: f32) -> Shape { - let mut shape = Shape::new(part.shape.clone(), part.sense, root, Some(part.part_ref()), part.priority, position).stacking(part.stacking).min_across(target); + let mut shape = + Shape::new(part.shape.clone(), part.sense, root, Some(part.part_ref()), part.priority, position).stacking(part.stacking).min_across(target); shape.drag_to_root = part.drag_to_root; shape } diff --git a/crates/ui-contract/src/runtime/keys.rs b/crates/ui-contract/src/runtime/keys.rs index a113f01ee..47708d5f9 100644 --- a/crates/ui-contract/src/runtime/keys.rs +++ b/crates/ui-contract/src/runtime/keys.rs @@ -37,11 +37,11 @@ pub(crate) use intents::lent_taken; pub use intents::settle; #[doc(hidden)] pub use intents::take_submit; -pub use intents::{with_canvas_window_intents, with_window_intents}; pub(crate) use intents::{ Lent, context_part, context_request, give_back, lend, request_context, route_whole_reset, scope_escape, take_cancel, take_every_escape, take_window_cancel, }; +pub use intents::{with_canvas_window_intents, with_window_intents}; pub(crate) use nodes::{redirect_node, register_expanded, register_node}; pub use route::focus_holds; pub(crate) use route::{activated_member, begin, focus_in_dialog, layout_of, owner_at, pasted, pasted_text, queue_edit, routed_to, take_shortcuts}; diff --git a/crates/ui-contract/src/runtime/keys/intents.rs b/crates/ui-contract/src/runtime/keys/intents.rs index 0a5ca227c..f5799a625 100644 --- a/crates/ui-contract/src/runtime/keys/intents.rs +++ b/crates/ui-contract/src/runtime/keys/intents.rs @@ -292,9 +292,8 @@ fn offer_window_intents(ctx: &Context, rtl: bool, take: impl FnOnce(&mut Intents let focused = focus::focused_rec(ctx).map(|rec| rec.stop.id); let mut window = intents_of(ctx, None, rtl); // The focused stop's leftover Escape stays in its slot until taken. - let lent_cancel = focused - .filter(|id| !window.items.iter().any(|(item, _)| *item == Intent::Cancel) && holds(ctx, Some(*id), &Intent::Cancel)) - .map(|id| { + let lent_cancel = + focused.filter(|id| !window.items.iter().any(|(item, _)| *item == Intent::Cancel) && holds(ctx, Some(*id), &Intent::Cancel)).map(|id| { window.items.push((Intent::Cancel, false)); (id, window.items.len() - 1) }); diff --git a/crates/ui-contract/src/runtime/pointer.rs b/crates/ui-contract/src/runtime/pointer.rs index 2ae250732..3a66c1121 100644 --- a/crates/ui-contract/src/runtime/pointer.rs +++ b/crates/ui-contract/src/runtime/pointer.rs @@ -790,7 +790,8 @@ fn find_under(ctx: &Context, viewport: ViewportId, at: Pos2, targets: PressTarge .copied() .filter(|&index| { let shape = &entry.shapes[index]; - index != winner.index && shape.sense.contains(craft_behavior::Sense::DRAG) + index != winner.index + && shape.sense.contains(craft_behavior::Sense::DRAG) && (!winner.drag_to_root || (shape.owner == root && shape.part.is_none())) }) .collect(); diff --git a/crates/ui-panels/src/rails/drawer.rs b/crates/ui-panels/src/rails/drawer.rs index 8d3e1ced8..65d9e8ee8 100644 --- a/crates/ui-panels/src/rails/drawer.rs +++ b/crates/ui-panels/src/rails/drawer.rs @@ -494,7 +494,10 @@ fn insert(mut out: Vec>, tool: RailTool, at: DropAt) -> } DropAt::NewSlot { before } => { let id = match out.iter().map(|slot| slot.id).max() { - Some(max) => match max.checked_add(1) { Some(id) => id, None => return original }, + Some(max) => match max.checked_add(1) { + Some(id) => id, + None => return original, + }, None => 0, }; out.insert(before.min(out.len()), ToolSlot::new(id, vec![tool]));