]> ruin.nu Git - moosique.git/blobdiff - MooTrackView.java
*** empty log message ***
[moosique.git] / MooTrackView.java
index 8133cda05f372feff297b0718db8b6e0853abef2..c1d8b5878cdb66b4f4b0d1ceef38a3f62c499f83 100644 (file)
@@ -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);
+                       }
                }
        }