From 2e5004cbd168410ca624f8335003a24b37b4477a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 3 Oct 2020 00:35:30 +0100 Subject: [PATCH] wip pinning Signed-off-by: Ian Jackson --- src/api.rs | 2 +- templates/script.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/api.rs b/src/api.rs index 8acee6c3..1db1a859 100644 --- a/src/api.rs +++ b/src/api.rs @@ -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. diff --git a/templates/script.ts b/templates/script.ts index f8fa74f7..567096ce 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -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; -- 2.30.2