Skip to content

Commit 9ee91a2

Browse files
author
laurent
committed
Reverse loop mode
1 parent 8487f77 commit 9ee91a2

File tree

2 files changed

+37
-23
lines changed

2 files changed

+37
-23
lines changed

workoutbuilder.qml

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MuseScore {
2626

2727
pluginType: "dialog"
2828
requiresScore: false
29-
width: 1350
29+
width: 1375
3030
height: 700
3131

3232
id: mainWindow
@@ -118,6 +118,13 @@ MuseScore {
118118
"label": "No repetition",
119119
"image": "none.png",
120120
"id": "--"
121+
}, {
122+
"type": 2,
123+
"label": "Reverse pattern",
124+
"short": "Reversed",
125+
"image": "reverse.png",
126+
//"shift": 1,
127+
"id": "R"
121128
}, {
122129
"type": 1,
123130
"label": "Cycle pattern",
@@ -365,7 +372,7 @@ MuseScore {
365372
"notes": p,
366373
"loopAt": mode,
367374
"chord": cSymb,
368-
"name": idPattName.itemAt(i).text
375+
"name": idPattName.itemAt(i).text
369376
};
370377
patts.push(pattern);
371378

@@ -784,7 +791,7 @@ MuseScore {
784791
var scale = pattern.chord.scale;
785792
var loopAt = pattern.loopAt;
786793

787-
extpattern.representation = (pattern.name && pattern.name!=="")?pattern.name:patternToString(pattern.notes, pattern.loopAt);
794+
extpattern.representation = (pattern.name && pattern.name !== "") ? pattern.name : patternToString(pattern.notes, pattern.loopAt);
788795

789796
extpattern["subpatterns"] = [];
790797

@@ -798,7 +805,7 @@ MuseScore {
798805

799806
// looping patterns
800807

801-
if ((loopAt.type > 0) && (Math.abs(loopAt.shift) < basesteps.length) && (loopAt.shift != 0)) {
808+
if ((loopAt.type == 1) && (Math.abs(loopAt.shift) < basesteps.length) && (loopAt.shift != 0)) {
802809
// 1) Regular loopAt mode, where we loop from the current pattern, restarting the pattern (and looping)
803810
// from the next step of it : A-B-C, B-C-A, C-A-B
804811
console.log("Looping patterns : regular mode");
@@ -869,8 +876,16 @@ MuseScore {
869876

870877
extpattern["subpatterns"].push(p);
871878
}
872-
} else if (loopAt.type < 0) {
873-
// 2) Scale loopAt mode, we decline the pattern along the scale (up/down, by degree/Triad)
879+
} else if (loopAt.type == 2) {
880+
// 2) REverse loopAt mode, we simply reverse the pattern
881+
console.log("Looping patterns : reverse mode ");
882+
883+
var reversed = [].concat(basesteps); // clone the basesteps
884+
reversed.reverse();
885+
extpattern["subpatterns"].push(reversed);
886+
887+
} else if (loopAt.type == -1) {
888+
// 3) Scale loopAt mode, we decline the pattern along the scale (up/down, by degree/Triad)
874889
var shift = loopAt.shift; //Math.abs(loopAt) * (-1);
875890
console.log("Looping patterns : scale mode (" + shift + ")");
876891
// We clear all the patterns because will be restarting from the last step
@@ -1121,10 +1136,10 @@ MuseScore {
11211136
mode = _loops[mode].id;
11221137

11231138
var scale = idChordType.itemAt(index).editText;
1124-
1125-
var name= idPattName.itemAt(index).text;
11261139

1127-
var p = new patternClass(steps, mode, scale,name);
1140+
var name = idPattName.itemAt(index).text;
1141+
1142+
var p = new patternClass(steps, mode, scale, name);
11281143

11291144
console.log(p.label);
11301145

@@ -1162,13 +1177,12 @@ MuseScore {
11621177
}
11631178
}
11641179
}
1165-
1180+
11661181
console.log("pasting mode index " + modeidx);
11671182
idLoopingMode.itemAt(index).currentIndex = modeidx;
11681183

1169-
var name=(pattern && pattern.name)?pattern.name:"";
1170-
idPattName.itemAt(index).text=name;
1171-
1184+
var name = (pattern && pattern.name) ? pattern.name : "";
1185+
idPattName.itemAt(index).text = name;
11721186

11731187
}
11741188

@@ -1629,13 +1643,13 @@ MuseScore {
16291643
ImageButton {
16301644
id: btnSetName
16311645
imageSource: "edittext.svg"
1632-
ToolTip.text: "Set pattern's name"+
1633-
((idPattName.itemAt(index).text!="")?("\n\""+idPattName.itemAt(index).text+"\""):"\n--default--")
1634-
highlighted: (idPattName.itemAt(index).text!="")
1646+
ToolTip.text: "Set pattern's name" +
1647+
((idPattName.itemAt(index).text != "") ? ("\n\"" + idPattName.itemAt(index).text + "\"") : "\n--default--")
1648+
highlighted: (idPattName.itemAt(index).text != "")
16351649
onClicked: {
16361650
patternNameInputDialog.index = index;
16371651
patternNameInputDialog.open();
1638-
1652+
16391653
}
16401654
}
16411655
}
@@ -2254,7 +2268,7 @@ MuseScore {
22542268

22552269
onVisibleChanged: {
22562270
if (visible) {
2257-
txtInputPatternName.text = ((index === -1)) ? "??" :idPattName.itemAt(index).text;
2271+
txtInputPatternName.text = ((index === -1)) ? "??" : idPattName.itemAt(index).text;
22582272
}
22592273
}
22602274

@@ -2328,7 +2342,7 @@ MuseScore {
23282342
icon: StandardIcon.Critical
23292343
standardButtons: StandardButton.Ok
23302344
title: 'Invalid libraries'
2331-
text: "Invalid 'zparkingb/notehelper.js' versions.\nExpecting "+ noteHelperVersion + ".\n" + pluginName + " will stop here."
2345+
text: "Invalid 'zparkingb/notehelper.js' versions.\nExpecting " + noteHelperVersion + ".\n" + pluginName + " will stop here."
23322346
onAccepted: {
23332347
Qt.quit()
23342348
}
@@ -2424,10 +2438,10 @@ MuseScore {
24242438
label += "-";
24252439
label += _degrees[steps[i]];
24262440
}
2427-
2428-
if (name && name!=="") {
2429-
label+=" ("+name+")";
2430-
}
2441+
2442+
if (name && name !== "") {
2443+
label += " (" + name + ")";
2444+
}
24312445

24322446
if ((loopMode !== "--") && (loopMode !== undefined)) {
24332447
var m = loopMode;

workoutbuilder/reverse.png

787 Bytes
Loading

0 commit comments

Comments
 (0)