-
Notifications
You must be signed in to change notification settings - Fork 3
/
UltraStarAnnotate.qml
99 lines (93 loc) · 2.71 KB
/
UltraStarAnnotate.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
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2
// FileDialog
import Qt.labs.folderlistmodel 2.1
import QtQml 2.2
import MuseScore 1.0
import FileIO 1.0
// This MuseScore Plugin is licensed under the GPL Version 2
//Copyright Joseph Eoff, April 2015
MuseScore {
menuPath: "View." +qsTr("UltraStar Annotator")
description: qsTr("Annotate Score for UltraStar Export")
pluginType: "dock"
dockArea: "left"
onRun: {
}
Rectangle {
color: "lightgrey"
anchors.fill: parent
width: grid.width + 20
height: grid.height + 20
ColumnLayout {
id: grid
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 10
Button {
id: lineBreak
text: qsTr("Make Line Break")
onClicked: {
annotateItem("/")
}
}
Button {
id: goldenNote
text: qsTr("Make Golden Note")
onClicked: {
annotateItem("*")
}
}
Button {
id: freestyleNote
text: qsTr("Make Freestyle Note")
onClicked: {
annotateItem("F")
}
}
}
}
function annotateItem(annotation) {
var cursor = curScore.newCursor(true)
cursor.rewind(0)
cursor.rewind(1)
cursor.next()
var segment = getSelectedItem(cursor)
console.log(segment)
if (segment) {
for (var i = 0; i < segment.annotations.length; i++) {
var ann = segment.annotations[i].text
if (ann === "/" || ann === "*" || ann === "F") {
//already marked
return
}
}
var marker = newElement(Element.STAFF_TEXT)
marker.text = annotation
marker.visible = false
curScore.startCmd()
cursor.add(marker)
curScore.endCmd(false)
}
}
function getSelectedItem(cursor) {
cursor.filter = -1
for (var i = 0; i < curScore.ntracks; i++) {
cursor.track = i
cursor.rewind(0)
cursor.rewind(1)
while (cursor.element) {
for (var i = 0; i < cursor.element.notes.length; i++) {
if (cursor.element.notes[i].selected) {
console.log("element.notes")
return cursor.segment
}
}
cursor.next()
}
}
return null
}
}