Skip to content

Commit

Permalink
Collapsible define temperament and define mode blocks #2934
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksh authored and walterbender committed May 13, 2021
1 parent 6763a56 commit 6eef801
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
17 changes: 16 additions & 1 deletion js/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@
const TEXTWIDTH = 240; // 90
const STRINGLEN = 9;
const LONGPRESSTIME = 1500;
const INLINECOLLAPSIBLES = ["newnote", "interval", "osctime"];
const INLINECOLLAPSIBLES = ["newnote", "interval", "osctime", "definemode"];
const COLLAPSIBLES = [
"drum",
"start",
"action",
"temperament1",
"matrix",
"pitchdrummatrix",
"rhythmruler2",
Expand Down Expand Up @@ -1440,6 +1441,13 @@ class Block {
platformColor.blockText
);
break;
case "temperament1":
that.collapseText = new createjs.Text(
_("temperament"),
fontSize + "px Sans",
platformColor.blockText
);
break;
case "start":
that.collapseText = new createjs.Text(
_("start"),
Expand Down Expand Up @@ -1559,6 +1567,13 @@ class Block {
platformColor.blockText
);
break;
case "definemode":
that.collapseText = new createjs.Text(
_("mode"),
fontSize + "px Sans",
platformColor.blockText
);
break;
default:
that.collapseText = new createjs.Text(
"foobar",
Expand Down
1 change: 1 addition & 0 deletions js/blocks/ActionBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ function setupActionBlocks(activity) {
this.formBlock({
name: _("define temperament"),
args: 1,
canCollapse: true,
argLabels: [""],
defaults: ["custom"],
argTypes: ["text"]
Expand Down
1 change: 1 addition & 0 deletions js/blocks/IntervalsBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ function setupIntervalsBlocks(activity) {
//.TRANS: define a custom mode
name: _("define mode"),
args: 1,
canCollapse: true,
argTypes: ["textin"],
defaults: _("custom")
});
Expand Down
6 changes: 4 additions & 2 deletions js/widgets/modewidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ class ModeWidget {
collapsed: true
}
],
100,
150,
100,
[null, 1, 2, null]
],
Expand Down Expand Up @@ -1018,7 +1018,9 @@ class ModeWidget {

// And save a stack of pitchnumbers to be used with the define mode
newStack = [
[0, "definemode", 150, 120, [null, 1, 3, 2]],
[0, ["definemode", {
collapsed: true
}], 150, 150, [null, 1, 3, 2]],
[
1,
[
Expand Down
34 changes: 20 additions & 14 deletions js/widgets/temperament.js
Original file line number Diff line number Diff line change
Expand Up @@ -1549,11 +1549,25 @@ function TemperamentWidget() {
}

setOctaveRatio(this.powerBase);

const len = this._logo.synth.startingPitch.length;
const note = this._logo.synth.startingPitch.substring(0, len - 1);
const octave = this._logo.synth.startingPitch.slice(-1);
const newStack1 = [
[0, "settemperament", 150, 150, [null, 1, 2, 3, null]],
[1, ["temperamentname", { value: this.inTemperament }], 0, 0, [0]],
[2, ["notename", { value: note }], 0, 0, [0]],
[3, ["number", { value: octave }], 0, 0, [0]]
];
this.activity.blocks.loadNewBlocks(newStack1);

const value = this.activity.blocks.findUniqueTemperamentName(this.inTemperament);
// Change from temporary "custom" to "custom1" or "custom2" ...
this.inTemperament = value;
const newStack = [
[0, "temperament1", 100, 100, [null, 1, 2, null]],
[0, ["temperament1", {
collapsed: true
}], 150, 100, [null, 1, 2, null]],
[1, ["text", { value: value }], 0, 0, [0]],
[2, ["storein"], 0, 0, [0, 3, 4, 5]],
[3, ["text", { value: this._logo.synth.startingPitch }], 0, 0, [2]],
Expand Down Expand Up @@ -1717,20 +1731,12 @@ function TemperamentWidget() {
previousBlock = idx + 10;
}
}
this.activity.blocks.loadNewBlocks(newStack);
this.activity.textMsg(_("New action block generated!"));

const len = this._logo.synth.startingPitch.length;
const note = this._logo.synth.startingPitch.substring(0, len - 1);
const octave = this._logo.synth.startingPitch.slice(-1);
const newStack1 = [
[0, "settemperament", 100, 100, [null, 1, 2, 3, null]],
[1, ["temperamentname", { value: this.inTemperament }], 0, 0, [0]],
[2, ["notename", { value: note }], 0, 0, [0]],
[3, ["number", { value: octave }], 0, 0, [0]]
];
this.activity.blocks.loadNewBlocks(newStack1);
this.activity.textMsg(_("New action block generated!"));
const that = this;
setTimeout(() => {
that.activity.blocks.loadNewBlocks(newStack);
that.activity.textMsg(_("New action block generated!"));
}, 500);

if (isCustomTemperament(this.inTemperament)) {
deleteTemperamentFromList(this.inTemperament);
Expand Down

0 comments on commit 6eef801

Please sign in to comment.