chiark / gitweb /
organise: Swap piece and bbox
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 10:45:14 +0000 (11:45 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 15:41:44 +0000 (16:41 +0100)
This will make the sort work nicely.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/organise.rs

index 91af5b6fdf8446fb27b71f365ca9b45520a33547..23ddbf070934747dddd99c2b6280fc936f3fa501 100644 (file)
@@ -82,7 +82,7 @@ impl Attempt {
 
 #[throws(InternalError)]
 fn try_layout(region: &Rect,
-              pieces: &IndexVec<InHand, (PieceId, Rect)>,
+              pieces: &IndexVec<InHand, (Rect, PieceId)>,
               att: Attempt)
               -> Option<IndexVec<InHand, Pos>> {
   let mut out = default();
@@ -96,7 +96,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 (bbox, piece) in pieces {
     let place = 'placed: loop {
       for xi in 0..3 {
         let place = (cur - att.tl(&bbox)?)?;
@@ -166,7 +166,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),
+        (bbox, piece),
         gpc.zlevel.clone())
       )
     }
@@ -175,7 +175,7 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str,
     }
   }).unzip::<
     _,_,
-    IndexVec<InHand, (PieceId, Rect)>,
+    IndexVec<InHand, (Rect, PieceId)>,
     IndexVec<InHand, ZLevel>,
   >();
 
@@ -207,7 +207,7 @@ 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 ((_bbox, 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;