Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widgets/status.js: Improved UI of status widget #2838

Merged
merged 2 commits into from
Feb 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions js/widgets/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ class StatusMatrix {
*/
init() {
this.isOpen = true;

this.isMaximized = false;
this._cellScale = window.innerWidth / 1200;
let iconSize = StatusMatrix.ICONSIZE * this._cellScale;

this.widgetWindow = window.widgetWindows.windowFor(this, "status", "status");
this.widgetWindow.clear();
this.widgetWindow.show();

// For the button callbacks
let cell;

// The status table
this._statusTable = document.createElement("table");
this.widgetWindow.getWidgetBody().append(this._statusTable);
Expand All @@ -58,20 +57,21 @@ class StatusMatrix {
iconSize = Math.floor(this._cellScale * 24);

cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.backgroundColor = "#FFFFFF";
cell.className = "headcol";
cell.style.height = Math.floor(MATRIXBUTTONHEIGHT * this._cellScale) + "px";
cell.style.width = StatusMatrix.BUTTONSIZE * this._cellScale + "px";
// cell.style.width = StatusMatrix.BUTTONSIZE * this._cellScale*2 + "px";
cell.style.width = "212.5px";

cell.innerHTML = " ";

// One column per mouse/turtle
for (const turtle of turtles.turtleList) {
if (turtle.inTrash) {
continue;
}

cell = row.insertCell();
cell.style.backgroundColor = platformColor.labelColor;
cell.style.backgroundColor = "#FFFFFF";

if (_THIS_IS_MUSIC_BLOCKS_) {
cell.innerHTML =
Expand All @@ -96,7 +96,18 @@ class StatusMatrix {
iconSize +
'">  ';
}
cell.style.width = StatusMatrix.BUTTONSIZE * this._cellScale + "px";
cell.style.width = "212.5px";
this.widgetWindow.onmaximize = () => {
this.isMaximized = !(this.isMaximized);
console.log("Maximized " + this.isMaximized);
cell.style.width = "100vw";
cell.style.paddingLeft = "30px";
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
if(!(this.isMaximized)){
cell.style.width = "212.5px";
}
};
// cell.style.width = StatusMatrix.BUTTONSIZE * this._cellScale*2 + "px";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.className = "headcol";
}
Expand All @@ -109,7 +120,7 @@ class StatusMatrix {
const row = header.insertRow();

cell = row.insertCell(); // i + 1);
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";

// console.debug(statusField[1]);

Expand Down Expand Up @@ -144,16 +155,18 @@ class StatusMatrix {
label = logo.blocks.blockList[statusField[0]].protoblock.staticLabels[0];
break;
}

cell.innerHTML = "&nbsp;<b>" + label + "</b>";
let str = label;
str = label.charAt(0).toUpperCase() + label.slice(1);
// console.log(str);
cell.innerHTML = "&nbsp;<b>" + str + "</b>";
cell.style.height = Math.floor(MATRIXBUTTONHEIGHT * this._cellScale) + "px";
cell.style.backgroundColor = platformColor.selectorBackground;

cell.style.paddingLeft = "10px";
turtles.turtleList.forEach(() => {
cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
cell.innerHTML = "";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.style.textAlign = "center";
Expand All @@ -163,16 +176,18 @@ class StatusMatrix {
if (_THIS_IS_MUSIC_BLOCKS_) {
const row = header.insertRow();
cell = row.insertCell();
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
cell.innerHTML = "&nbsp;<b>" + _("note") + "</b>";
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
const str = _("note");
const label = str.charAt(0).toUpperCase() + str.slice(1);
cell.innerHTML = "&nbsp;<b>" + label + "</b>";
cell.style.height = Math.floor(MATRIXBUTTONHEIGHT * this._cellScale) + "px";
cell.style.backgroundColor = platformColor.selectorBackground;

cell.style.paddingLeft = "10px";
turtles.turtleList.forEach(() => {
cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) + "%";
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
cell.innerHTML = "";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.style.textAlign = "center";
Expand Down