Changeset View
Changeset View
Standalone View
Standalone View
src/activities/piano_composition/Staff.qml
Context not available. | |||||
60 | 60 | | |||
---|---|---|---|---|---|
61 | Repeater { | 61 | Repeater { | ||
62 | model: nbLines | 62 | model: nbLines | ||
63 | | ||||
64 | Rectangle { | 63 | Rectangle { | ||
65 | width: staff.width | 64 | width: staff.width | ||
66 | height: 5 | 65 | height: 5 | ||
Context not available. | |||||
70 | y: index * verticalDistanceBetweenLines | 69 | y: index * verticalDistanceBetweenLines | ||
71 | } | 70 | } | ||
72 | } | 71 | } | ||
72 | | ||||
73 | Rectangle { | 73 | Rectangle { | ||
74 | width: 5 | 74 | width: 5 | ||
75 | border.width: 5 | 75 | border.width: 5 | ||
Context not available. | |||||
78 | x: staff.width | 78 | x: staff.width | ||
79 | y: 0 | 79 | y: 0 | ||
80 | } | 80 | } | ||
81 | // end of partition line | 81 | | ||
82 | // End of partition line | ||||
82 | Rectangle { | 83 | Rectangle { | ||
83 | width: 5 | 84 | width: 5 | ||
84 | border.width: 5 | 85 | border.width: 5 | ||
Context not available. | |||||
123 | print("total distance " + metronome.x) | 124 | print("total distance " + metronome.x) | ||
124 | } | 125 | } | ||
125 | 126 | | |||
127 | function calculateTimerDuration(noteType) { | ||||
128 | noteType = noteType.toLowerCase() | ||||
129 | if(noteType === "whole") | ||||
130 | return 2000 | ||||
131 | else if(noteType === "half") | ||||
132 | return 1500 | ||||
133 | else if(noteType === "quarter") | ||||
134 | return 1000 | ||||
135 | else | ||||
136 | return 812.5 | ||||
137 | } | ||||
138 | | ||||
126 | function addNote(noteName, noteType, blackType, highlightWhenPlayed) { | 139 | function addNote(noteName, noteType, blackType, highlightWhenPlayed) { | ||
127 | var duration | 140 | var duration | ||
128 | if(noteType == "Whole") | 141 | if(noteType === "Rest") | ||
129 | duration = 2000 / 1 | 142 | duration = calculateTimerDuration(noteName) | ||
130 | else if(noteType == "Half") | | |||
131 | duration = 3000 / 2 | | |||
132 | else if(noteType == "Quarter") | | |||
133 | duration = 4000 / 4 | | |||
134 | else | 143 | else | ||
135 | duration = 6500 / 8 | 144 | duration = calculateTimerDuration(noteType) | ||
136 | 145 | | |||
137 | notes.append({"noteName_": noteName, "noteType_": noteType, "mDuration": duration, | 146 | notes.append({"noteName_": noteName, "noteType_": noteType, "mDuration": duration, | ||
138 | "highlightWhenPlayed": highlightWhenPlayed}); | 147 | "highlightWhenPlayed": highlightWhenPlayed}); | ||
Context not available. | |||||
144 | } | 153 | } | ||
145 | 154 | | |||
146 | function eraseAllNotes() { | 155 | function eraseAllNotes() { | ||
147 | notes.clear(); | 156 | notes.clear() | ||
148 | } | 157 | } | ||
149 | 158 | | |||
150 | property int noteWidth: (staff.width - 10 - clefImage.width) / 10 | 159 | property int noteWidth: (staff.width - 10 - clefImage.width) / 10 | ||
Context not available. | |||||
162 | width: (notes.count == 1 && items.staffLength === "long") ? Math.min(items.background.width,items.background.height) * 0.1 : noteWidth | 171 | width: (notes.count == 1 && items.staffLength === "long") ? Math.min(items.background.width,items.background.height) * 0.1 : noteWidth | ||
163 | height: staff.height | 172 | height: staff.height | ||
164 | 173 | | |||
165 | noteDetails: Activity.getNoteDetails(noteName) | 174 | noteDetails: Activity.getNoteDetails(noteName, noteType) | ||
166 | rotation: { | 175 | rotation: { | ||
167 | if(noteDetails.positonOnStaff < 0 && noteType === "Whole") | 176 | if(noteDetails.positonOnStaff < 0 && noteType === "Whole") | ||
168 | return 0 | 177 | return 0 | ||
Context not available. |