-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPush to next measure.qml
116 lines (96 loc) · 3.96 KB
/
Push to next measure.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*========================================================================
Move Selection
https://github.com/Ash-86/Move-Selection
Copyright (C)2023 Ashraf El Droubi (Ash-86)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=========================================================================*/
import QtQuick 2.0
import MuseScore 3.0
MuseScore {
menuPath: "Plugins.Move/Duplicate Selection. Push music to next measure."
description: "Pushes the music, from selection till end of staff, forward to the next measure."
version: "1.0"
//4.4 title:"Push music to next measure."
//4.4 thumbnailName: "do.png"
//4.4 categoryCode: "composing-arranging-tools"
Component.onCompleted : {
if (mscoreMajorVersion >= 4) {
title= "Push music to next measure."
thumbnailName = "do.png"
categoryCode = "composing-arranging-tools"
}
}
function insertBar() {
///// get start and end tics,staff,and track, for selection
var cursor = curScore.newCursor(); // get the selection
//end
cursor.rewind(2); // go to the end of the selection
var endTick = cursor.tick;
if (endTick == 0) { // dealing with some bug when selecting to end.
var endTick = score.lastSegment.tick+1;
}
var endStaff = cursor.staffIdx +1;
var endTrack = endStaff * 4;
//start
cursor.rewind(1); // go to the beginning of the selection
var startSegTick= curScore.selection.startSegment.tick;
var startTick = cursor.tick;
var startStaff = cursor.staffIdx;
var startTrack = startStaff * 4;
///////////////////////////////////////////////////////////////
endTick = curScore.lastSegment.tick + 1;
curScore.selection.selectRange(startTick, endTick, startStaff, endStaff)
cmd("copy");
var e = curScore.selection.elements
for (var i in e) {
// if (e[i].type==Element.NOTE ){ //special handling of chords //// crashes when undoing
// removeElement(e[i].parent)
// }
// else{
removeElement(e[i]) /// deletes everything exept tuplets when there are single notes (no chords)
// }
}
////////////////////////////////
for (var track=startTrack; track<endTrack; track++){
cursor.track=track
cursor.rewindToTick(startTick)
while(cursor.element && cursor.tick < endTick ) {
var e = cursor.element;
var a = cursor.segment.annotations
if(e.tuplet) {
removeElement(e.tuplet); // must specifically remove tuplets
}
else {
removeElement(e);
}
for (var i in a){
removeElement(a[i])
}
cursor.next();
}
}
cursor.track=startTrack;
cursor.rewindToTick(startSegTick);
cursor.nextMeasure()
if (cursor.element.type==Element.CHORD){
curScore.selection.select(cursor.element.notes[0])
}else {
curScore.selection.select(cursor.element)
}
cmd("paste");
}
onRun: {
curScore.startCmd()
insertBar();
curScore.endCmd()
}
}