From 447a1f805c6200d5391dfc78a234878f1c5c7e23 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 3 Apr 2021 15:36:15 +0100 Subject: [PATCH] organise: Introduce PrimaryEnt (nfc) Signed-off-by: Ian Jackson --- src/organise.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/organise.rs b/src/organise.rs index 91af5b6f..f7967486 100644 --- a/src/organise.rs +++ b/src/organise.rs @@ -80,9 +80,14 @@ impl Attempt { } } +struct PrimaryEnt { + piece: PieceId, + bbox: Rect, +} + #[throws(InternalError)] fn try_layout(region: &Rect, - pieces: &IndexVec, + pieces: &IndexVec, att: Attempt) -> Option> { let mut out = default(); @@ -96,7 +101,7 @@ fn try_layout(region: &Rect, // Everything below n_y is overwriteable // Everything below and to the right of cur is overwriteable - for (piece, bbox) in pieces { + for PrimaryEnt { piece, bbox } in pieces { let place = 'placed: loop { for xi in 0..3 { let place = (cur - att.tl(&bbox)?)?; @@ -166,7 +171,7 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str, if let Some(bbox) = want!( Ok = ipc.show(vis).bbox_approx(), ?piece ); then { Some(( - (piece, bbox), + PrimaryEnt { piece, bbox }, gpc.zlevel.clone()) ) } @@ -175,7 +180,7 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str, } }).unzip::< _,_, - IndexVec, + IndexVec, IndexVec, >(); @@ -207,7 +212,9 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str, let updates = { let mut updates = Vec::with_capacity(pieces.len()); - for ((piece, _bbox), pos, zlevel) in izip!(pieces, layout, zlevels) { + for (PrimaryEnt { piece, .. }, pos, zlevel) in + izip!(pieces, layout, zlevels) + { want_let!{ Some(gpc) = gs.pieces.get_mut(piece); else continue; } gpc.pos = pos; gpc.zlevel = zlevel; -- 2.30.2