X-Git-Url: https://ruin.nu/git/?p=moosique.git;a=blobdiff_plain;f=MooTrackView.java;fp=MooTrackView.java;h=c1d8b5878cdb66b4f4b0d1ceef38a3f62c499f83;hp=8133cda05f372feff297b0718db8b6e0853abef2;hb=19db604db6c736c9afc31650b2efac6eb8e2f70b;hpb=1f2ba8a0848ee0c5f0ea94f7bc40ea502c0dff74 diff --git a/MooTrackView.java b/MooTrackView.java index 8133cda..c1d8b58 100644 --- a/MooTrackView.java +++ b/MooTrackView.java @@ -324,11 +324,23 @@ public class MooTrackView extends JPanel { * @param ticks the number of ticks to move the selection. */ public void moveSelectedNotes(int ticks) { - Iterator it = selection.iterator(); - while(it.hasNext()) { - MooNoteElement elem = (MooNoteElement)it.next(); - elem.getNote().setTick(elem.getNote().getTick() + ticks); - layoutElement(elem, true); + if (ticks > 0) { + // If the selection should be moved downwards, traverses the list in the natural order. + Iterator it = selection.iterator(); + while(it.hasNext()) { + MooNoteElement elem = (MooNoteElement)it.next(); + elem.getNote().setTick(elem.getNote().getTick() + ticks); + layoutElement(elem, true); + } + } else { + // If the selection should be moved upwards, traverses the list in the opposite order. + ArrayList selectedList = new ArrayList(selection); + ListIterator it = selectedList.listIterator(selectedList.size()); + while(it.hasPrevious()) { + MooNoteElement elem = (MooNoteElement)it.previous(); + elem.getNote().setTick(elem.getNote().getTick() + ticks); + layoutElement(elem, true); + } } }