summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit/dcanvas.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-10-11 16:02:53 +0000
committerFlorian Jung <flo@windfisch.org>2011-10-11 16:02:53 +0000
commitabedca49b707bd5bced2bee2caa8bb4417dcfa51 (patch)
tree7f933fc8de2e0e3e5ebb0024a00b562e27734aa9 /muse2/muse/midiedit/dcanvas.cpp
parent4b27437712d5341129b019ec98fb8e4d3fa7ad0d (diff)
improved creating new notes in drum canvas
Diffstat (limited to 'muse2/muse/midiedit/dcanvas.cpp')
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 03d38fbf..0d2f7640 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -380,20 +380,31 @@ CItem* DrumCanvas::newItem(int tick, int instrument, int velocity)
{
if (!old_style_drummap_mode && !instrument_map[instrument].tracks.contains(curPart->track()))
{
- printf("FINDMICH: tried to create a new Item which cannot be inside the current track. returning NULL\n");
- return NULL;
- }
- else
- {
- tick -= curPart->tick();
- MusECore::Event e(MusECore::Note);
- e.setTick(tick);
- e.setPitch(instrument_map[instrument].pitch);
- e.setVelo(velocity);
- e.setLenTick(ourDrumMap[instrument].len);
-
- return new DEvent(e, curPart, instrument);
+ if (debugMsg)
+ printf("tried to create a new Item which cannot be inside the current track. looking for destination part...\n");
+
+ QSet<MusECore::Part*> parts = parts_at_tick(tick, instrument_map[instrument].tracks);
+
+ if (parts.count() != 1)
+ {
+ QMessageBox::warning(this, tr("Creating event failed"), tr("Couldn't create the event, because the currently selected part isn't the same track, and the selected instrument could be either on no or on multiple parts, which is ambiguous.\nSelect the destination part, then try again."));
+ return NULL;
+ }
+ else
+ {
+ setCurrentPart(*parts.begin());
+ }
}
+ // else or if we found an alternative part (which has now been set as curPart)
+
+ tick -= curPart->tick();
+ MusECore::Event e(MusECore::Note);
+ e.setTick(tick);
+ e.setPitch(instrument_map[instrument].pitch);
+ e.setVelo(velocity);
+ e.setLenTick(ourDrumMap[instrument].len);
+
+ return new DEvent(e, curPart, instrument);
}
//---------------------------------------------------------