summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2010-07-10 14:12:19 +0000
committerRobert Jonsson <spamatica@gmail.com>2010-07-10 14:12:19 +0000
commit009177f39db16272e129391164f5db5589dbe940 (patch)
tree9f1b6d2ebd112e385fe25b1e78a833f9aef976bd
parenta20708aa3691ba4bcb2e8ebcfe14bc0ad99df4da (diff)
insert empty measure and insert copied parts
-rw-r--r--muse/ChangeLog6
-rw-r--r--muse/muse/app.cpp11
-rw-r--r--muse/muse/app.h2
-rw-r--r--muse/muse/arranger/arranger.cpp6
-rw-r--r--muse/muse/arranger/arranger.h3
-rw-r--r--muse/muse/arranger/pcanvas.cpp85
-rw-r--r--muse/muse/arranger/pcanvas.h6
-rw-r--r--muse/muse/shortcuts.cpp3
-rw-r--r--muse/muse/shortcuts.h3
-rw-r--r--muse/muse/song.h1
-rw-r--r--muse/muse/undo.cpp35
-rw-r--r--muse/muse/undo.h8
12 files changed, 154 insertions, 15 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 6f72163a..4b47cca7 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,9 +1,13 @@
+10.07.2010
+ * Added: Insert measure, inserts empty space and moves everything after playpointer to the right and
+ Part-insert, pastes parts and moves everything after the paste point to the right
+ it's currently not possible to change the shortcuts for these, wip (rj)
06.07.2010
* Added: Button in transport to enable/disable jack transport. (rj)
* Fixed: Dropdown Snap and Type in arranger toolbar no longer steal focus, annoyed the helloutame (rj)
* Fixed: Making edits to larger chunks in wave files no longer cause a crash, heap is used for allocation (rj)
* Improved: Part selection when navigating with keyboard, previously there was sometimes a need to use the mouse
- to get a part selected, now one should be arbitrarily selected (rj)
+ to get a part selected, now the first one should be selected (rj)
* Added: some automation (very)wip stuff, not enabled, just to get it off my harddrive (rj)
22.06.2010
* Fixed: Crashes loading a song while another is loaded. Or worse, it loads but saving corrupts the file! (T356)
diff --git a/muse/muse/app.cpp b/muse/muse/app.cpp
index 22460568..5ac48d23 100644
--- a/muse/muse/app.cpp
+++ b/muse/muse/app.cpp
@@ -1058,6 +1058,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow(0, "mainwindow")
menuEdit->setAccel(CTRL+Key_C, CMD_COPY);
menuEdit->insertItem(*editpasteIconSet, tr("&Paste"), CMD_PASTE);
menuEdit->setAccel(CTRL+Key_V, CMD_PASTE);
+ menuEdit->insertItem(*editpasteIconSet, tr("&Insert"), CMD_INSERT);
+ menuEdit->setAccel(CTRL+SHIFT+Key_I, CMD_INSERT);
menuEdit->insertItem(*editpasteCloneIconSet, tr("Paste c&lone"), CMD_PASTE_CLONE);
menuEdit->setAccel(CTRL+SHIFT+Key_V, CMD_PASTE_CLONE);
menuEdit->insertItem(*editpaste2TrackIconSet, tr("Paste to &track"), CMD_PASTE_TO_TRACK);
@@ -1065,6 +1067,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow(0, "mainwindow")
menuEdit->insertItem(*editpasteClone2TrackIconSet, tr("Paste clone to trac&k"), CMD_PASTE_CLONE_TO_TRACK);
menuEdit->setAccel(CTRL+SHIFT+Key_B, CMD_PASTE_CLONE_TO_TRACK);
+ menuEdit->insertItem(*editpasteIconSet, tr("&Insert empty measure"), CMD_INSERTMEAS);
+ menuEdit->setAccel(CTRL+SHIFT+Key_M, CMD_INSERTMEAS);
menuEdit->insertSeparator();
menuEdit->insertItem(QIconSet(*edit_track_delIcon),
tr("Delete Selected Tracks"), CMD_DELETE_TRACK);
@@ -2818,6 +2822,12 @@ void MusE::cmd(int cmd)
case CMD_PASTE_CLONE_TO_TRACK:
arranger->cmd(Arranger::CMD_PASTE_CLONE_PART_TO_TRACK);
break;
+ case CMD_INSERT:
+ arranger->cmd(Arranger::CMD_INSERT_PART);
+ break;
+ case CMD_INSERTMEAS:
+ arranger->cmd(Arranger::CMD_INSERT_EMPTYMEAS);
+ break;
case CMD_DELETE:
song->startUndo();
if (song->msgRemoveParts()) {
@@ -2920,6 +2930,7 @@ void MusE::clipboardChanged()
}
}
menuEdit->setItemEnabled(CMD_PASTE, flag);
+ menuEdit->setItemEnabled(CMD_INSERT, flag);
menuEdit->setItemEnabled(CMD_PASTE_CLONE, flag);
menuEdit->setItemEnabled(CMD_PASTE_TO_TRACK, flag);
menuEdit->setItemEnabled(CMD_PASTE_CLONE_TO_TRACK, flag);
diff --git a/muse/muse/app.h b/muse/muse/app.h
index 6fb5add4..64f10085 100644
--- a/muse/muse/app.h
+++ b/muse/muse/app.h
@@ -66,7 +66,7 @@ class EditInstrument;
class MusE : public QMainWindow
{
Q_OBJECT
- enum {CMD_CUT, CMD_COPY, CMD_PASTE, CMD_PASTE_CLONE,
+ enum {CMD_CUT, CMD_COPY, CMD_PASTE, CMD_INSERT, CMD_INSERTMEAS, CMD_PASTE_CLONE,
CMD_PASTE_TO_TRACK, CMD_PASTE_CLONE_TO_TRACK, CMD_DELETE,
CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT,
CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PARTS,
diff --git a/muse/muse/arranger/arranger.cpp b/muse/muse/arranger/arranger.cpp
index a0c322d4..d96b172c 100644
--- a/muse/muse/arranger/arranger.cpp
+++ b/muse/muse/arranger/arranger.cpp
@@ -662,6 +662,12 @@ void Arranger::cmd(int cmd)
case CMD_PASTE_CLONE_PART_TO_TRACK:
ncmd = PartCanvas::CMD_PASTE_CLONE_PART_TO_TRACK;
break;
+ case CMD_INSERT_PART:
+ ncmd = PartCanvas::CMD_INSERT_PART;
+ break;
+ case CMD_INSERT_EMPTYMEAS:
+ ncmd = PartCanvas::CMD_INSERT_EMPTYMEAS;
+ break;
default:
return;
}
diff --git a/muse/muse/arranger/arranger.h b/muse/muse/arranger/arranger.h
index 7a9fae00..ce738c11 100644
--- a/muse/muse/arranger/arranger.h
+++ b/muse/muse/arranger/arranger.h
@@ -197,7 +197,8 @@ class Arranger : public QWidget {
void controllerChanged(Track *t);
public:
- enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK };
+ enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK,
+ CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS };
Arranger(QMainWindow* parent, const char* name = 0);
void setMode(int);
diff --git a/muse/muse/arranger/pcanvas.cpp b/muse/muse/arranger/pcanvas.cpp
index f64c1966..0027516c 100644
--- a/muse/muse/arranger/pcanvas.cpp
+++ b/muse/muse/arranger/pcanvas.cpp
@@ -19,7 +19,7 @@
#include <qpoint.h>
#include <qlineedit.h>
#include <qmessagebox.h>
-#include <qdragobject.h>
+#include <qdragobject.h>>
#include <qpopupmenu.h>
#include <qurl.h>
#include <qmenudata.h>
@@ -37,6 +37,7 @@
#include "gconfig.h"
#include "app.h"
#include "filedialog.h"
+#include "marker/marker.h"
const char* partColorNames[] = {
"Default",
@@ -1697,6 +1698,16 @@ void PartCanvas::cmd(int cmd)
case CMD_PASTE_CLONE_PART_TO_TRACK:
paste(true);
break;
+ case CMD_INSERT_PART:
+ paste(false, false, true);
+ break;
+ case CMD_INSERT_EMPTYMEAS:
+ song->startUndo();
+ int startPos=song->vcpos();
+ int oneMeas=sigmap.ticksMeasure(startPos);
+ movePartsTotheRight(startPos,oneMeas);
+ song->endUndo(SC_PART_INSERTED);
+ break;
}
}
@@ -1807,7 +1818,7 @@ int PartCanvas::pasteAt(const QString& pt, Track* track, int pos, bool clone, bo
int done = 0;
bool end = false;
- song->startUndo();
+ //song->startUndo();
for (;;) {
Xml::Token token = xml.parse();
const QString& tag = xml.s1();
@@ -1856,7 +1867,9 @@ int PartCanvas::pasteAt(const QString& pt, Track* track, int pos, bool clone, bo
posOffset=pos-p->tick();
}
p->setTick(p->tick()+posOffset);
- finalPos=p->tick()+p->lenTick();
+ if (p->tick()+p->lenTick()>finalPos) {
+ finalPos=p->tick()+p->lenTick();
+ }
//pos += p->lenTick();
audio->msgAddPart(p,false);
}
@@ -1873,7 +1886,7 @@ int PartCanvas::pasteAt(const QString& pt, Track* track, int pos, bool clone, bo
break;
}
- song->endUndo(SC_PART_INSERTED);
+ //song->endUndo(SC_PART_INSERTED);
//return pos;
if(notDone)
@@ -2285,9 +2298,14 @@ Part* PartCanvas::readClone(Xml& xml, Track* track, bool toTrack)
//---------------------------------------------------------
//void PartCanvas::paste()
-void PartCanvas::paste(bool clone, bool toTrack)
+void PartCanvas::paste(bool clone, bool toTrack, bool doInsert)
{
Track* track = 0;
+
+ if (doInsert) // logic depends on keeping track of newly selected tracks
+ deselectAll();
+
+
// If we want to paste to a selected track...
if(toTrack)
{
@@ -2358,14 +2376,62 @@ void PartCanvas::paste(bool clone, bool toTrack)
QCString subtype = 0;
QString txt = cb->text(subtype);
- if (!txt.isEmpty())
+ int endPos=0;
+ int startPos=song->vcpos();
+ if (!txt.isEmpty())
{
- Pos p(pasteAt(txt, track, song->vcpos(), clone, toTrack), true);
+ song->startUndo();
+ endPos=pasteAt(txt, track, startPos, clone, toTrack);
+ Pos p(endPos, true);
song->setPos(0, p);
+ if (!doInsert)
+ song->endUndo(SC_PART_INSERTED);
+
+ }
+
+ if (doInsert) {
+ int offset = endPos-startPos;
+ movePartsTotheRight(startPos, offset);
+ song->endUndo(SC_PART_INSERTED);
}
}
//---------------------------------------------------------
+// movePartsToTheRight
+//---------------------------------------------------------
+void PartCanvas::movePartsTotheRight(int startTicks, int length)
+{
+ // all parts that start after the pasted parts will be moved the entire length of the pasted parts
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected()) {
+ Part* part = i->second->part();
+ if (part->tick() >= startTicks) {
+ //void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag, bool doCtrls, bool doClones)
+ Part *newPart = part->clone();
+ newPart->setTick(newPart->tick()+length);
+ if (part->track()->type() == Track::WAVE) {
+ audio->msgChangePart((WavePart*)part,(WavePart*)newPart,false,false,false);
+ } else {
+ audio->msgChangePart(part,newPart,false,false,false);
+ }
+
+ }
+ }
+ }
+ // perhaps ask if markers should be moved?
+ MarkerList *markerlist = song->marker();
+ for(iMarker i = markerlist->begin(); i != markerlist->end(); ++i)
+ {
+ Marker* m = &i->second;
+ if (m->tick() >= startTicks) {
+ Marker *oldMarker = new Marker();
+ *oldMarker = *m;
+ m->setTick(m->tick()+length);
+ song->undoOp(UndoOp::ModifyMarker,oldMarker, m);
+ }
+ }
+}
+//---------------------------------------------------------
// startDrag
//---------------------------------------------------------
@@ -2491,8 +2557,11 @@ void PartCanvas::viewDropEvent(QDropEvent* event)
Track* track = 0;
if (trackNo < tracks->size())
track = tracks->index(trackNo);
- if (track)
+ if (track) {
+ song->startUndo();
pasteAt(text, track, x);
+ song->endUndo(SC_PART_INSERTED);
+ }
}
else if (type == 2) {
text = text.stripWhiteSpace();
diff --git a/muse/muse/arranger/pcanvas.h b/muse/muse/arranger/pcanvas.h
index 72d4563f..6e37bf00 100644
--- a/muse/muse/arranger/pcanvas.h
+++ b/muse/muse/arranger/pcanvas.h
@@ -86,8 +86,9 @@ class PartCanvas : public Canvas {
void splitItem(CItem* item, const QPoint&);
void copy(PartList*);
- void paste(bool clone = false, bool toTrack = true);
+ void paste(bool clone = false, bool toTrack = true, bool doInsert=false);
int pasteAt(const QString&, Track*, int, bool clone = false, bool toTrack = true);
+ void movePartsTotheRight(int startTick, int length);
//Part* readClone(Xml&, Track*, bool toTrack = true);
void drawWavePart(QPainter&, const QRect&, WavePart*, const QRect&);
Track* y2Track(int) const;
@@ -116,7 +117,8 @@ class PartCanvas : public Canvas {
void returnPressed();
public:
- enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK };
+ enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK,
+ CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS };
PartCanvas(int* raster, QWidget* parent, int, int);
void partsChanged();
diff --git a/muse/muse/shortcuts.cpp b/muse/muse/shortcuts.cpp
index 63b6eef6..6a1ffc7c 100644
--- a/muse/muse/shortcuts.cpp
+++ b/muse/muse/shortcuts.cpp
@@ -128,6 +128,9 @@ void initShortCuts()
defShrt(SHRT_SEL_BELOW, Qt::Key_Down, "Edit: Select nearest part on track below", ARRANG_SHRT, "sel_part_below");
defShrt(SHRT_SEL_BELOW_ADD, Qt::SHIFT + Qt::Key_Down, "Edit: Add nearest part on track below", ARRANG_SHRT, "sel_part_below_add");
+ defShrt(SHRT_INSERT, Qt::CTRL+Qt::SHIFT+ Qt::Key_I, "Edit: Insert parts, moving time", ARRANG_SHRT, "insert parts");
+ defShrt(SHRT_INSERTMEAS, Qt::CTRL+Qt::SHIFT+ Qt::Key_M, "Edit: Insert empty measure", ARRANG_SHRT, "insert measure");
+
defShrt(SHRT_SEL_TRACK_ABOVE, Qt::CTRL + Qt::Key_Up, "Select track above", ARRANG_SHRT, "sel_track_above");
defShrt(SHRT_SEL_TRACK_BELOW, Qt::CTRL + Qt::Key_Down, "Select track below", ARRANG_SHRT, "sel_track_below");
diff --git a/muse/muse/shortcuts.h b/muse/muse/shortcuts.h
index 81bf865e..6e7e661a 100644
--- a/muse/muse/shortcuts.h
+++ b/muse/muse/shortcuts.h
@@ -163,6 +163,9 @@ enum {
SHRT_SEL_BELOW, //Down
SHRT_SEL_BELOW_ADD, //move down and add to selection
+ SHRT_INSERT, //Ctrl+Shift+I - insert parts instead of pasting
+ SHRT_INSERTMEAS, //Ctrl+Shift+M - insert measures
+
//Arranger tracks
SHRT_SEL_TRACK_BELOW,
SHRT_SEL_TRACK_ABOVE,
diff --git a/muse/muse/song.h b/muse/muse/song.h
index 6c76362b..369042b4 100644
--- a/muse/muse/song.h
+++ b/muse/muse/song.h
@@ -324,6 +324,7 @@ class Song : public QObject {
//void undoOp(UndoOp::UndoType, Part* oPart, Part* nPart);
void undoOp(UndoOp::UndoType, Part* oPart, Part* nPart, bool doCtrls, bool doClones);
void undoOp(UndoOp::UndoType type, const char* changedFile, const char* changeData, int startframe, int endframe);
+ void undoOp(UndoOp::UndoType type, Marker* copyMarker, Marker* realMarker);
bool doUndo1();
void doUndo2();
void doUndo3();
diff --git a/muse/muse/undo.cpp b/muse/muse/undo.cpp
index 021069f3..ba020d2f 100644
--- a/muse/muse/undo.cpp
+++ b/muse/muse/undo.cpp
@@ -68,6 +68,7 @@ void UndoOp::dump()
case SwapTrack:
case DeleteSig:
case ModifyClip:
+ case ModifyMarker:
break;
}
}
@@ -157,6 +158,9 @@ void UndoList::clearDelete()
// break;
//case UndoOp::DeleteSig:
// break;
+ case UndoOp::ModifyMarker:
+ if (i->copyMarker)
+ delete i->copyMarker;
default:
break;
}
@@ -424,6 +428,7 @@ void Song::doUndo2()
updateFlags |= SC_SIG;
break;
case UndoOp::ModifyClip:
+ case UndoOp::ModifyMarker:
break;
}
}
@@ -649,6 +654,7 @@ void Song::doRedo2()
updateFlags |= SC_SIG;
break;
case UndoOp::ModifyClip:
+ case UndoOp::ModifyMarker:
break;
}
}
@@ -767,6 +773,16 @@ void Song::undoOp(UndoOp::UndoType type, const char* changedFile, const char* ch
//printf("Adding ModifyClip undo-operation: origfile=%s tmpfile=%s sf=%d ef=%d\n", changedFile, changeData, startframe, endframe);
}
+void Song::undoOp(UndoOp::UndoType type, Marker* copyMarker, Marker* realMarker)
+ {
+ UndoOp i;
+ i.type = type;
+ i.realMarker = realMarker;
+ i.copyMarker = copyMarker;
+
+ addUndo(i);
+ }
+
//---------------------------------------------------------
// addUndo
//---------------------------------------------------------
@@ -823,6 +839,7 @@ bool Song::doUndo1()
case UndoOp::ModifyClip:
SndFile::applyUndoFile(i->filename, i->tmpwavfile, i->startframe, i->endframe);
break;
+
default:
break;
}
@@ -850,6 +867,14 @@ void Song::doUndo3()
// Not much choice but to do this - Tim.
//clearClipboardAndCloneList();
break;
+ case UndoOp::ModifyMarker:
+ {
+ //printf("performing undo for one marker at %d\n", i->realMarker->tick());
+ Marker tmpMarker = *i->realMarker;
+ *i->realMarker = *i->copyMarker; // swap them
+ *i->copyMarker = tmpMarker;
+ }
+ break;
default:
break;
}
@@ -924,7 +949,15 @@ void Song::doRedo3()
// Not much choice but to do this - Tim.
//clearClipboardAndCloneList();
break;
- default:
+ case UndoOp::ModifyMarker:
+ {
+ //printf("performing redo for one marker at %d\n", i->realMarker->tick());
+ Marker tmpMarker = *i->realMarker;
+ *i->realMarker = *i->copyMarker; // swap them
+ *i->copyMarker = tmpMarker;
+ }
+ break;
+ default:
break;
}
}
diff --git a/muse/muse/undo.h b/muse/muse/undo.h
index 999c02bd..c20fe3f5 100644
--- a/muse/muse/undo.h
+++ b/muse/muse/undo.h
@@ -12,6 +12,7 @@
#include <list>
#include <qstring.h>
#include "event.h"
+#include "marker/marker.h"
class Track;
class TEvent;
@@ -31,7 +32,8 @@ struct UndoOp {
AddTempo, DeleteTempo,
AddSig, DeleteSig,
SwapTrack,
- ModifyClip
+ ModifyClip,
+ ModifyMarker
};
UndoType type;
@@ -69,6 +71,10 @@ struct UndoOp {
const char* filename; //!< The file that is changed
const char* tmpwavfile; //!< The file with the changed data
};
+ struct {
+ Marker* realMarker;
+ Marker* copyMarker;
+ };
};
Event oEvent;
Event nEvent;