Changeset View
Changeset View
Standalone View
Standalone View
src/activities/piano_composition/piano_composition.js
Context not available. | |||||
31 | var notesDetails = NoteNotations.get() | 31 | var notesDetails = NoteNotations.get() | ||
---|---|---|---|---|---|
32 | var userDir = "file://" + GCompris.ApplicationInfo.getSharedWritablePath() + "/" + "piano_composition" | 32 | var userDir = "file://" + GCompris.ApplicationInfo.getSharedWritablePath() + "/" + "piano_composition" | ||
33 | var userFile = userDir + "/melodies.json" | 33 | var userFile = userDir + "/melodies.json" | ||
34 | var undoStack = [] | ||||
35 | var undidChange = false | ||||
34 | var instructions = [{ | 36 | var instructions = [{ | ||
35 | "text": qsTr("This is the treble cleff staff for high pitched notes") | 37 | "text": qsTr("This is the treble cleff staff for high pitched notes") | ||
36 | }, | 38 | }, | ||
Context not available. | |||||
93 | items.background.staffMode = "add" | 95 | items.background.staffMode = "add" | ||
94 | items.multipleStaff.noteToReplace = [-1, -1] | 96 | items.multipleStaff.noteToReplace = [-1, -1] | ||
95 | items.staffModesOptions.currentIndex = 0 | 97 | items.staffModesOptions.currentIndex = 0 | ||
98 | undoStack = [] | ||||
99 | } | ||||
100 | | ||||
101 | function pushToStack(noteIndex, staffIndex, oldNoteName, oldNoteType, newNoteName, newNoteType) { | ||||
102 | undoStack.push({"noteIndex_": noteIndex, "staffIndex_": staffIndex, | ||||
103 | "oldNoteName_": oldNoteName, "oldNoteType_": oldNoteType}) | ||||
104 | // Maintain most recent 5 changes. Remove older ones (stack behaves as queue here). | ||||
105 | if(undoStack.length > 5) | ||||
106 | undoStack.shift() | ||||
107 | } | ||||
108 | | ||||
109 | function undoChange() { | ||||
110 | if(undoStack.length > 0) { | ||||
111 | var undoNoteDetails = undoStack[undoStack.length - 1] | ||||
112 | undoStack.pop() | ||||
113 | if(undoNoteDetails.noteName_ != "none") | ||||
114 | undidChange = true | ||||
115 | items.multipleStaff.undoChange(undoNoteDetails) | ||||
116 | } | ||||
96 | } | 117 | } | ||
97 | 118 | | |||
98 | function getNoteDetails(noteName, noteType) { | 119 | function getNoteDetails(noteName, noteType) { | ||
Context not available. |