summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-06-06 18:01:05 +0000
committerFlorian Jung <flo@windfisch.org>2011-06-06 18:01:05 +0000
commit637498c87bf1ac780d8527d0596936fcdd2c6dfc (patch)
tree5257fadc43d8d8eb44b763b720b5ae373e070d79 /muse2/muse
parent2359a1c010c298eb66b5b03e0e23f55b4fd9ff4b (diff)
hopefully fixed the "clones aren't treated as clones" bug
fixed stupid behaviour of shrink and expand part
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/arranger/pcanvas.cpp7
-rw-r--r--muse2/muse/functions.cpp26
-rw-r--r--muse2/muse/functions.h4
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp4
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 <sys/stat.h>
#include <sys/types.h>
#include <sys/mman.h>
+#include <math.h>
#include <QMimeData>
#include <QByteArray>
@@ -831,10 +832,14 @@ void select_not_in_loop(const std::set<Part*>& 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 (len<min_len) len=min_len;
- if (len != part->second->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<min_len) len=min_len;
+
+ 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<Part*>& parts);
void select_not_in_loop(const std::set<Part*>& 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
*