From 637498c87bf1ac780d8527d0596936fcdd2c6dfc Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 6 Jun 2011 18:01:05 +0000 Subject: hopefully fixed the "clones aren't treated as clones" bug fixed stupid behaviour of shrink and expand part --- muse2/muse/arranger/pcanvas.cpp | 7 +++++-- muse2/muse/functions.cpp | 26 +++++++++++++++++++------- muse2/muse/functions.h | 4 ++-- muse2/muse/midiedit/scoreedit.cpp | 4 +--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index e17d08e1..f7a2abde 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -349,14 +349,15 @@ UndoOp PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) // This increments aref count if cloned, and chains clones. // It also gives the new part a new serial number. dpart = dtrack->newPart(spart, clone); - dpart->events()->incARef(-1); // the later song->applyOperationGroup() will increment it - // so we must decrement it first :/ dpart->setTick(dtick); if(t == MOVE_MOVE) item->setPart(dpart); if (t == MOVE_COPY && !clone) { + dpart->events()->incARef(-1); // the later song->applyOperationGroup() will increment it + // so we must decrement it first :/ + // // Copy Events // @@ -368,6 +369,8 @@ UndoOp PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) de->add(ev); } } + + if (t == MOVE_COPY || t == MOVE_CLONE) { // These will not increment ref count, and will not chain clones... // TODO: is this still correct (by flo93)? diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp index 3d10a878..b47874fd 100644 --- a/muse2/muse/functions.cpp +++ b/muse2/muse/functions.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -831,10 +832,14 @@ void select_not_in_loop(const std::set& parts) } -void shrink_parts() +void shrink_parts(int raster) { Undo operations; + unsigned min_len; + if (raster<0) raster=config.division; + if (raster>=0) min_len=raster; else min_len=config.division; + TrackList* tracks = song->tracks(); for (iTrack track = tracks->begin(); track != tracks->end(); track++) for (iPart part = (*track)->parts()->begin(); part != (*track)->parts()->end(); part++) @@ -847,10 +852,10 @@ void shrink_parts() if (ev->second.endTick() > len) len=ev->second.endTick(); - if (len > part->second->lenTick()) - len = part->second->lenTick(); + if (raster) len=ceil((float)len/raster)*raster; + if (lensecond->lenTick()) + if (len < part->second->lenTick()) { MidiPart* new_part = new MidiPart(*(MidiPart*)part->second); new_part->setLenTick(len); @@ -861,10 +866,14 @@ void shrink_parts() song->applyOperationGroup(operations); } -void expand_parts() +void expand_parts(int raster) { Undo operations; + unsigned min_len; + if (raster<0) raster=config.division; + if (raster>=0) min_len=raster; else min_len=config.division; + TrackList* tracks = song->tracks(); for (iTrack track = tracks->begin(); track != tracks->end(); track++) for (iPart part = (*track)->parts()->begin(); part != (*track)->parts()->end(); part++) @@ -876,8 +885,11 @@ void expand_parts() for (iEvent ev=events->begin(); ev!=events->end(); ev++) if (ev->second.endTick() > len) len=ev->second.endTick(); - - if (len != part->second->lenTick()) + + if (raster) len=ceil((float)len/raster)*raster; + if (len part->second->lenTick()) { MidiPart* new_part = new MidiPart(*(MidiPart*)part->second); new_part->setLenTick(len); diff --git a/muse2/muse/functions.h b/muse2/muse/functions.h index 8a1eb3ed..633457a9 100644 --- a/muse2/muse/functions.h +++ b/muse2/muse/functions.h @@ -85,8 +85,8 @@ void select_in_loop(const std::set& parts); void select_not_in_loop(const std::set& parts); //functions for parts -void shrink_parts(); -void expand_parts(); +void shrink_parts(int raster=-1); //negative values mean "config.division" +void expand_parts(int raster=-1); void clean_parts(); //functions for reading and writing default values diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 450d6f98..1a885d99 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4452,14 +4452,12 @@ void staff_t::update_part_indices() /* BUGS and potential bugs - * o clones aren't marked as clones any more :( - * * o when the keymap is not used, this will probably lead to a bug * o tied notes don't work properly when there's a key-change in * between, for example, when a cis is tied to a des * * CURRENT TODO - * o either remove these "hidden notes", or deal with them in the score editor + * o clones should have same size * o insert empty measure should also work inside parts, that is, * move notes _within_ parts * -- cgit v1.2.3