Skip to content

Commit 592bd56

Browse files
authored
fix regression in status block (#378)
1 parent a42388b commit 592bd56

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

js/macros.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function getMacroExpansion (blkname, x, y) {
3131
const FILLOBJ = [[0, 'fill', x, y, [null, null, 1]], [1, 'hidden', 0, 0, [0, null]]];
3232
const HOLLOWOBJ = [[0, 'hollowline', x, y, [null, null, 1]], [1, 'hidden', 0, 0, [0, null]]];
3333
const SETTURTLENAMEOBJ = [[0, 'setturtlename', x, y, [null, 1, 2, null]], [1, 'turtlename', 0, 0, [0]], [2, ['text', {'value': 'Mozart'}], 0, 0, [0]]];
34-
const STATUSOBJ = [[0, 'status', x, y, [null, 1, null]], [1, 'print', 0, 0, [0, 2, 3]], [2, 'x', 0, 0, [1]], [3, 'print', 0, 0, [1, 4, 5]], [4, 'y', 0, 0, [3]], [5, 'print', 0, 0, [3, 6, null]], [6, 'heading', 0, 0, [5]]];
34+
const STATUSOBJ = [[0, 'status', x, y, [null, 1, 7]], [1, 'print', 0, 0, [0, 2, 3]], [2, 'x', 0, 0, [1]], [3, 'print', 0, 0, [1, 4, 5]], [4, 'y', 0, 0, [3]], [5, 'print', 0, 0, [3, 6, null]], [6, 'heading', 0, 0, [5]], [7, 'hiddennoflow', 0, 0, [0,null]]];
3535
const SWITCHOBJ = [[0, 'switch', x, y, [null, 1, 2, 5]], [1, ['number', {'value': 1}], 0, 0, [0]], [2, 'case', 0, 0, [0, 3, null, 4]], [3, ['number', {'value': 1}], 0, 0, [2]], [4, 'defaultcase', 0, 0, [2, null, null]], [5, 'hidden', 0, 0, [0, null]]];
3636
const XTURTLEOBJ = [[0, 'xturtle', x, y, [null, 1, null]], [1, 'turtlename', 0, 0, [0]]];
3737
const YTURTLEOBJ = [[0, 'yturtle', x, y, [null, 1, null]], [1, 'turtlename', 0, 0, [0]]];

js/widgets/status.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2016-17 Walter Bender
1+
// Copyright (c) 2016-18 Walter Bender
22
//
33
// This program is free software; you can redistribute it and/or
44
// modify it under the terms of the The GNU Affero General Public
@@ -19,6 +19,7 @@ function StatusMatrix() {
1919
const ICONSIZE = 32;
2020
const OUTERWINDOWWIDTH = 620;
2121
const INNERWINDOWWIDTH = OUTERWINDOWWIDTH - BUTTONSIZE * 1.5;
22+
var x, y; //Drop coordinates of statusDiv
2223

2324
docById('statusDiv').style.visibility = 'hidden';
2425

@@ -38,8 +39,6 @@ function StatusMatrix() {
3839
var statusDiv = docById('statusDiv');
3940
statusDiv.style.visibility = 'visible';
4041
statusDiv.setAttribute('draggable', 'true');
41-
statusDiv.style.left = '200px';
42-
statusDiv.style.top = '150px';
4342

4443
// The status buttons
4544
var statusButtonsDiv = docById('statusButtonsDiv');
@@ -93,9 +92,9 @@ function StatusMatrix() {
9392
canvas.ondrop = function(e) {
9493
if (that._dragging) {
9594
that._dragging = false;
96-
var x = e.clientX - that._dx;
95+
x = e.clientX - that._dx;
9796
statusDiv.style.left = x + 'px';
98-
var y = e.clientY - that._dy;
97+
y = e.clientY - that._dy;
9998
statusDiv.style.top = y + 'px';
10099
dragCell.innerHTML = that._dragCellHTML;
101100
}
@@ -108,9 +107,9 @@ function StatusMatrix() {
108107
statusDiv.ondrop = function(e) {
109108
if (that._dragging) {
110109
that._dragging = false;
111-
var x = e.clientX - that._dx;
110+
x = e.clientX - that._dx;
112111
statusDiv.style.left = x + 'px';
113-
var y = e.clientY - that._dy;
112+
y = e.clientY - that._dy;
114113
statusDiv.style.top = y + 'px';
115114
dragCell.innerHTML = that._dragCellHTML;
116115
}
@@ -261,6 +260,8 @@ function StatusMatrix() {
261260
this.updateAll = function() {
262261
// Update status of all of the voices in the matrix.
263262
var table = docById('statusTable');
263+
statusDiv.style.top = y + 'px';
264+
statusDiv.style.left = x + 'px';
264265

265266
this._logo.updatingStatusMatrix = true;
266267

@@ -281,6 +282,14 @@ function StatusMatrix() {
281282
case 'heading':
282283
var value = this._logo.blocks.blockList[this._logo.statusFields[i][0]].value.toFixed(2);
283284
break;
285+
case 'mynotevalue':
286+
var value = mixedNumber(this._logo.blocks.blockList[this._logo.statusFields[i][0]].value);
287+
case 'elapsednotes2':
288+
var blk = this._logo.statusFields[i][0];
289+
var cblk = this._logo.blocks.blockList[blk].connections[1];
290+
var notevalue = this._logo.parseArg(this._logo, turtle, cblk, blk, null);
291+
var value = mixedNumber(this._logo.blocks.blockList[this._logo.statusFields[i][0]].value) + ' × ' + mixedNumber(notevalue);
292+
break;
284293
case 'elapsednotes':
285294
var value = mixedNumber(this._logo.blocks.blockList[this._logo.statusFields[i][0]].value);
286295
break;
@@ -292,6 +301,12 @@ function StatusMatrix() {
292301
var value = '';
293302
}
294303
break;
304+
case 'beatvalue':
305+
var value = mixedNumber(this._logo.currentBeat[turtle]);
306+
break;
307+
case 'measurevalue':
308+
var value = this._logo.currentMeasure[turtle];
309+
break;
295310
default:
296311
var value = this._logo.blocks.blockList[this._logo.statusFields[i][0]].value;
297312
break;
@@ -313,10 +328,11 @@ function StatusMatrix() {
313328
if (this._logo.noteStatus[turtle] != null) {
314329
var notes = this._logo.noteStatus[turtle][0];
315330
for (var j = 0; j < notes.length; j++) {
316-
note += notes[j];
317331
if (typeof(notes[j]) === 'number') {
332+
note += toFixed2(notes[j]);
318333
note += 'Hz ';
319334
} else {
335+
note += notes[j];
320336
note += ' ';
321337
}
322338
}
@@ -328,7 +344,7 @@ function StatusMatrix() {
328344

329345
var cell = table.rows[activeTurtles + 1].cells[i + 1];
330346
if (cell != null) {
331-
cell.innerHTML = note.replace(/#/g, '♯').replace(/b/, '♭');
347+
cell.innerHTML = note.replace(/#/g, '♯').replace(/b/g, '♭');
332348
}
333349
}
334350

@@ -344,7 +360,7 @@ function StatusMatrix() {
344360
cell.style.width = BUTTONSIZE + 'px';
345361
cell.style.minWidth = cell.style.width;
346362
cell.style.maxWidth = cell.style.width;
347-
cell.style.height = cell.style.width;
363+
cell.style.height = cell.style.width;
348364
cell.style.minHeight = cell.style.height;
349365
cell.style.maxHeight = cell.style.height;
350366
cell.style.backgroundColor = MATRIXBUTTONCOLOR;

0 commit comments

Comments
 (0)