diff options
author | Florian Jung <flo@windfisch.org> | 2011-05-22 13:26:40 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-05-22 13:26:40 +0000 |
commit | 8fbfa07b464210054a177b1e92f47b5f2744d1cc (patch) | |
tree | fb8c2d49db90f51744251380a7b8d77689341282 /muse2/muse/midiedit/ecanvas.cpp | |
parent | 14f8a08279d9266467d457707166b439fd080fa2 (diff) |
moving events in canvases and reordering the drum map have
been speeded up by using operation groups.
HOWEVER: there might be bugs, in fact, i may even have messed
up the whole thing!
use with CAUTION and TEST intensively!
Diffstat (limited to 'muse2/muse/midiedit/ecanvas.cpp')
-rw-r--r-- | muse2/muse/midiedit/ecanvas.cpp | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/muse2/muse/midiedit/ecanvas.cpp b/muse2/muse/midiedit/ecanvas.cpp index 7a421411..e084c212 100644 --- a/muse2/muse/midiedit/ecanvas.cpp +++ b/muse2/muse/midiedit/ecanvas.cpp @@ -101,21 +101,12 @@ QPoint EventCanvas::raster(const QPoint& p) const } //--------------------------------------------------------- -// startUndo +// update //--------------------------------------------------------- -void EventCanvas::startUndo(DragType) +void EventCanvas::updateSong(DragType dtype, int flags) { - song->startUndo(); - } - -//--------------------------------------------------------- -// endUndo -//--------------------------------------------------------- - -void EventCanvas::endUndo(DragType dtype, int flags) - { - song->endUndo(flags | ((dtype == MOVE_COPY || dtype == MOVE_CLONE) + song->update(flags | ((dtype == MOVE_COPY || dtype == MOVE_CLONE) ? SC_EVENT_INSERTED : SC_EVENT_MODIFIED)); } @@ -545,3 +536,33 @@ void EventCanvas::viewDropEvent(QDropEvent* event) } } + +//--------------------------------------------------------- +// endMoveItems +// dir = 0 move in all directions +// 1 move only horizontal +// 2 move only vertical +//--------------------------------------------------------- + +void EventCanvas::endMoveItems(const QPoint& pos, DragType dragtype, int dir) + { + int dp = y2pitch(pos.y()) - y2pitch(Canvas::start.y()); + int dx = pos.x() - Canvas::start.x(); + + if (dir == 1) + dp = 0; + else if (dir == 2) + dx = 0; + + + + int modified = 0; + + Undo operations = moveCanvasItems(moving, dp, dx, dragtype, &modified); + song->applyOperationGroup(operations); + updateSong(dragtype, modified); + + moving.clear(); + updateSelection(); + redraw(); + } |