Skip to content

Commit

Permalink
Merge branch 'daksh4469-master' of https://github.com/daksh4469/music…
Browse files Browse the repository at this point in the history
…blocks into daksh4469-daksh4469-master
  • Loading branch information
walterbender committed Mar 12, 2021
2 parents a99ce41 + 7aa8aa5 commit 0f906f7
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 74 deletions.
169 changes: 103 additions & 66 deletions js/widgets/musickeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,29 @@
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA

/*global logo,blocks, _, platformColor, docById, MATRIXSOLFEHEIGHT, toFraction, Singer,
SOLFEGECONVERSIONTABLE, slicePath, wheelnav, DEFAULTVOICE, PITCHES, PITCHES2,
MATRIXSOLFEWIDTH, i18nSolfege, getNote, FIXEDSOLFEGE1, NOTESSHARP, NOTESFLAT,
last, SHARP, FLAT, PREVIEWVOLUME, noteToFrequency, SOLFEGENAMES, PITCHES3,
EIGHTHNOTEWIDTH, convertFromSolfege, FIXEDSOLFEGE*/

/* global docById,platformColor,FIXEDSOLFEGE,FIXEDSOLFEGE1,SHARP,FLAT,last,Singer,_,noteToFrequency,
EIGHTHNOTEWIDTH,MATRIXSOLFEHEIGHT,i18nSolfege,MATRIXSOLFEWIDTH,toFraction,wheelnav,slicePath,blocks,getNote,PREVIEWVOLUME,
DEFAULTVOICE,PITCHES3,SOLFEGENAMES,SOLFEGECONVERSIONTABLE,NOTESSHARP,NOTESFLAT,PITCHES,PITCHES2,convertFromSolfege,logo */
/*
Globals location
- lib/wheelnav
slicePath, wheelnav
- js/utils/musicutils.js
EIGHTHNOTEWIDTH, noteToFrequency, PITCHES, PITCHES2, NOTESSHARP, NOTESFLAT,
FLAT, SHARP, MATRIXSOLFEHEIGHT, toFraction, SOLFEGECONVERSIONTABLE, DEFAULTVOICE,
MATRIXSOLFEWIDTH, i18nSolfege, FIXEDSOLFEGE1, SOLFEGENAMES, PITCHES3,
getNote, convertFromSolfege, FIXEDSOLFEGE
- js/utils/utils.js
_, last, docById
- js/turtle-singer.js
Singer
- js/utils/platformstyle.js
platformColorcl
- js/activity.js
Global Locations
- lib/wheelnav
slicePath, wheelnav
- js/utils/utils.js
_,docById,last
- js/turtle-singer.js
Singer
- js/utils/musicutils.js
noteToFrequency,getNote,FIXEDSOLFEGE,FIXEDSOLFEGE1,SHARP,FLAT,EIGHTHNOTEWIDTH,MATRIXSOLFEHEIGHT,i18nSolfege,MATRIXSOLFEWIDTH,
toFraction,DEFAULTVOICE,PITCHES,PITCHES2,PITCHES3,SOLFEGENAMES,SOLFEGECONVERSIONTABLE,NOTESSHARP,
NOTESFLAT,convertFromSolfege
- js/utils/platformstyle.js
platformColor
- js/activity.js
blocks
- js/logo.js
PREVIEWVOLUME
*/

/*exported MusicKeyboard*/
- js/logo.js
PREVIEWVOLUME
*/
/* exported MusicKeyboard */

function MusicKeyboard() {
const FAKEBLOCKNUMBER = 100000;
Expand Down Expand Up @@ -84,7 +73,6 @@ function MusicKeyboard() {
this.blockNumberMapper = {};
this.instrumentMapper = {};
let selectedNotes = [];

this._rowBlocks = [];

// Each element in the array is [start time, note, id, duration, voice].
Expand Down Expand Up @@ -299,7 +287,28 @@ function MusicKeyboard() {
});
}
this._createTable();

if (this.widgetWindow._maximized) {
this.widgetWindow.getWidgetBody().style.position = "absolute";
this.widgetWindow.getWidgetBody().style.height = "calc(100vh - 64px)";
this.widgetWindow.getWidgetBody().style.width = "200vh";
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "725px";
docById("mkbOuterDiv").style.height = "calc(100vh - 64px)";
docById("mkbOuterDiv").style.width = "calc(200vh - 64px)";
docById("keyboardHolder2").style.width = "calc(200vh - 64px)";
docById("mkbInnerDiv").style.width = "95.5vw";
const innerDiv = docById("mkbInnerDiv");
innerDiv.scrollLeft = innerDiv.scrollWidth;
this.widgetWindow.getWidgetBody().style.left = "60px";
} else {
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "400px";
this.widgetWindow.getWidgetBody().style.position = "relative";
this.widgetWindow.getWidgetBody().style.left = "0px";
this.widgetWindow.getWidgetBody().style.height = "550px";
this.widgetWindow.getWidgetBody().style.width = "1000px";
docById("mkbOuterDiv").style.width = w + "px";
}
delete startTime[id];
delete temp1[id];
delete temp2[id];
Expand Down Expand Up @@ -392,12 +401,30 @@ function MusicKeyboard() {
blockNumber: this.blockNumberMapper[element.id]
});
this._createTable();
};

element.onmouseout = function () {
// __endNote();
if (this.widgetWindow._maximized) {
this.widgetWindow.getWidgetBody().style.position = "absolute";
this.widgetWindow.getWidgetBody().style.height = "calc(100vh - 64px)";
this.widgetWindow.getWidgetBody().style.width = "200vh";
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "725px";
docById("mkbOuterDiv").style.height = "calc(100vh - 64px)";
docById("mkbOuterDiv").style.width = "calc(200vh - 64px)";
docById("keyboardHolder2").style.width = "calc(200vh - 64px)";
docById("mkbInnerDiv").style.width = "95.5vw";
this.widgetWindow.getWidgetBody().style.left = "60px";
} else {
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "400px";
this.widgetWindow.getWidgetBody().style.position = "relative";
this.widgetWindow.getWidgetBody().style.left = "0px";
this.widgetWindow.getWidgetBody().style.height = "550px";
this.widgetWindow.getWidgetBody().style.width = "1000px";
docById("mkbOuterDiv").style.width = w + "px";
}
};


element.onmouseup = function () {
__endNote(this);
};
Expand All @@ -419,6 +446,29 @@ function MusicKeyboard() {
const tur = logo.turtles.ithTurtle(0);
this.bpm = tur.singer.bpm.length > 0 ? last(tur.singer.bpm) : Singer.masterBPM;

this.widgetWindow.onmaximize = function () {
if (widgetWindow._maximized) {
widgetWindow.getWidgetBody().style.position = "absolute";
widgetWindow.getWidgetBody().style.height = "calc(100vh - 64px)";
widgetWindow.getWidgetBody().style.width = "200vh";
docById("keyboardHolder2").style.width = "calc(200vh - 64px)";
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "725px";
docById("mkbOuterDiv").style.height = "calc(100vh - 64px)";
docById("mkbOuterDiv").style.width = "calc(200vh - 64px)";
widgetWindow.getWidgetBody().style.left = "60px";
}
else {
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "400px";
widgetWindow.getWidgetBody().style.position = "relative";
widgetWindow.getWidgetBody().style.left = "0px";
widgetWindow.getWidgetBody().style.height = "550px";
widgetWindow.getWidgetBody().style.width = "1000px";
docById("mkbOuterDiv").style.width = w + "px";
}
};

widgetWindow.onclose = () => {
let myNode;
document.onkeydown = saveOnKeyDown;
Expand Down Expand Up @@ -469,6 +519,21 @@ function MusicKeyboard() {
selectedNotes = [];
// if (!that.keyboardShown) {
this._createTable();
if (widgetWindow._maximized) {
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "725px";
docById("mkbOuterDiv").style.height = "calc(100vh - 64px)";
docById("mkbOuterDiv").style.width = "calc(200vh - 64px)";
widgetWindow.getWidgetBody().style.left = "60px";
} else {
const outerDiv = docById("mkbOuterDiv");
outerDiv.style.maxHeight = "400px";
widgetWindow.getWidgetBody().style.position = "relative";
widgetWindow.getWidgetBody().style.left = "0px";
widgetWindow.getWidgetBody().style.height = "550px";
widgetWindow.getWidgetBody().style.width = "1000px";
docById("mkbOuterDiv").style.width = w + "px";
}
// }
};

Expand Down Expand Up @@ -526,33 +591,6 @@ function MusicKeyboard() {
BUTTONDIVWIDTH
);

//Change widget size on fullscreen mode, else
//revert back to original size on unfullscreen mode
widgetWindow.onmaximize = function () {
if (widgetWindow._maximized) {
widgetWindow.getWidgetBody().style.position = "absolute";
widgetWindow.getWidgetBody().style.height = "calc(100vh - 64px)";
widgetWindow.getWidgetBody().style.width = "200vh";
docById("mkbOuterDiv").style.width = "calc(200vh - 64px)";
docById("keyboardHolder2").style.width = "calc(200vh - 64px)";
try {
docById("mkbInnerDiv").style.width = "calc(200vh - 64px)";
} catch (e) {
// Does this happen?
// eslint-disable-next-line no-console
console.debug("Error calculating InnerDiv width");
}

widgetWindow.getWidgetBody().style.left = "70px";
} else {
widgetWindow.getWidgetBody().style.position = "relative";
widgetWindow.getWidgetBody().style.left = "0px";
widgetWindow.getWidgetBody().style.height = "550px";
widgetWindow.getWidgetBody().style.width = "1000px";
docById("mkbOuterDiv").style.width = w + "px";
}
};

widgetWindow.sendToCenter();
};

Expand Down Expand Up @@ -1122,6 +1160,7 @@ function MusicKeyboard() {
let n = Math.max(Math.floor((window.innerHeight * 0.5) / 100), 8);

const outerDiv = docById("mkbOuterDiv");
outerDiv.style.overflowY = "hidden";
if (this.displayLayout.length > n) {
outerDiv.style.height = this._cellScale * MATRIXSOLFEHEIGHT * (n + 5) + "px";
} else {
Expand Down Expand Up @@ -2488,8 +2527,6 @@ function MusicKeyboard() {

this._save = function () {
this.processSelected();
// console.debug("Generating action stack for: ");
// console.debug(selectedNotes);
const newStack = [
[0, ["action", { collapsed: false }], 100, 100, [null, 1, 2, null]],
[1, ["text", { value: _("action") }], 0, 0, [0]],
Expand Down
18 changes: 10 additions & 8 deletions js/widgets/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ class StatusMatrix {
}
cell.style.width = "212.5px";
this.widgetWindow.onmaximize = () => {
this.isMaximized = !(this.isMaximized);
console.debug("Maximized " + this.isMaximized);
this.isMaximized = !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.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
if (!this.isMaximized) {
cell.style.width = "212.5px";
}
};
Expand All @@ -120,7 +120,8 @@ class StatusMatrix {
const row = header.insertRow();

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

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

Expand Down Expand Up @@ -169,7 +170,7 @@ class StatusMatrix {
cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
cell.innerHTML = "";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.style.textAlign = "center";
Expand All @@ -179,7 +180,8 @@ class StatusMatrix {
if (_THIS_IS_MUSIC_BLOCKS_) {
const row = header.insertRow();
cell = row.insertCell();
cell.style.fontSize = Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
const str = _("note");
const label = str.charAt(0).toUpperCase() + str.slice(1);
cell.innerHTML = "&nbsp;<b>" + label + "</b>";
Expand All @@ -190,7 +192,7 @@ class StatusMatrix {
cell = row.insertCell();
cell.style.backgroundColor = platformColor.selectorBackground;
cell.style.fontSize =
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR)*0.90 + "%";
Math.floor(this._cellScale * StatusMatrix.FONTSCALEFACTOR) * 0.9 + "%";
cell.innerHTML = "";
cell.style.height = Math.floor(MATRIXSOLFEHEIGHT * this._cellScale) + "px";
cell.style.textAlign = "center";
Expand Down

0 comments on commit 0f906f7

Please sign in to comment.