chiark / gitweb /
wip pinning
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Oct 2020 23:35:30 +0000 (00:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 2 Oct 2020 23:35:30 +0000 (00:35 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/api.rs
templates/script.ts

index 8acee6c3f73982018d2ae1db1e8fd2a5a6527df4..1db1a8599fc3b96953b8ea9381ebc695491b1d1d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2020 Ian Jackson
+p// Copyright 2020 Ian Jackson
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
index f8fa74f7f45fee490d2d09545fc7a5322d9d7dad..567096cea4f10f88e2f8fefc7c354135881d6597 100644 (file)
@@ -67,6 +67,7 @@ type PieceInfo = {
   cseq_updatesvg : number | null,
   z : number,
   zg : Generation,
+  pinned: boolean,
   uos : UoDescription[],
   uelem : SVGGraphicsElement,
   delem : SVGGraphicsElement,
@@ -254,6 +255,29 @@ function recompute_keybindings() {
       desc: "lower (send to bottom)",
     });
   }
+  if (all_targets.length) {
+    let got = 0;
+    for (let t of all_targets) {
+      got |= 1 << Number(pieces[t]!.pinned);
+    }
+    if (got == 1) {
+      add_uo(all_targets, {
+       def_key: 'P',
+       kind: 'ClientExtra',
+       opname: 'pin',
+       desc: 'Pin to table',
+       wrc: 'Predictable',
+      });
+    } else if (got == 2) {
+      add_uo(all_targets, {
+       def_key: 'P',
+       kind: 'ClientExtra',
+       opname: 'unpin',
+       desc: 'Unpin from table',
+       wrc: 'Predictable',
+      });
+    }
+  }
   add_uo(null, {
     def_key: 'W',
     kind: 'ClientExtra',
@@ -584,6 +608,7 @@ type PieceStateMessage = {
   pos: Pos,
   z: number,
   zg: Generation,
+  pinned: boolean,
   uos: UoDescription[],
 }
 
@@ -605,6 +630,7 @@ function piece_modify(piece: PieceId, p: PieceInfo, info: PieceStateMessage,
   p.uelem.setAttributeNS(null, "x", info.pos[0]+"");
   p.uelem.setAttributeNS(null, "y", info.pos[1]+"");
   p.held = info.held;
+  p.pinned = info.pinned;
   piece_set_zlevel(piece,p, (oldtop_piece)=>{
     p.z  = info.z;
     p.zg = info.zg;