From f1648fa3c8ff5399750222dd416b416ceeb0888a Mon Sep 17 00:00:00 2001
From: Robert Jonsson <spamatica@gmail.com>
Date: Wed, 27 Mar 2013 20:39:43 +0000
Subject: fixed moving drum events

---
 muse2/ChangeLog                 |  2 ++
 muse2/muse/midiedit/dcanvas.cpp | 14 ++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

(limited to 'muse2')

diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 1a7345a3..4ede0d3b 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,5 @@
+27.03.2013:
+         - Fixed moving events with keyboard in Drum editor (rj)
 10.03.2013:
          - Added color settings for: midi events in arranger,wave events in arranger, wave events in wave editor (rj)
 05.03.2013:
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index c16375d1..ff30eb64 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -1281,7 +1281,7 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int val, bool delta_mode
                   case NoteInfo::VAL_PITCH:
                         if (old_style_drummap_mode)
                         {
-                        int pitch = val; 
+                        int pitch = -val;
                         if(delta_mode)
                           pitch += event.pitch();  
                         if (pitch > 127)
@@ -1291,7 +1291,17 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int val, bool delta_mode
                         newEvent.setPitch(pitch);
                         }
                         else
-                          printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_PITCH not implemented for new style drum editors\n");
+                        {
+                          int direction = -val;
+                          for (int i = 0; i < instrument_map.size(); ++i) {
+                              if (instrument_map.at(i).pitch == event.pitch()) {
+                                  int nextPos = i + direction;
+                                  if (nextPos> -1 && nextPos < instrument_map.size())
+                                    newEvent.setPitch(instrument_map.at(nextPos).pitch);
+                                  break;
+                              }
+                          }
+                        }
                         break;
                   }
             MusEGlobal::song->changeEvent(event, newEvent, part);
-- 
cgit v1.2.3