summaryrefslogtreecommitdiff
path: root/muse2/muse/midiedit
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2012-03-19 15:13:58 +0000
committerFlorian Jung <flo@windfisch.org>2012-03-19 15:13:58 +0000
commit7200b77f549aef6e92170f110aeda8f5433a3dfc (patch)
tree4643738bbfdc59aa34ba3e1f682fac9c348d9bc2 /muse2/muse/midiedit
parent2800c0e742bdc9d141f6e8c77dbfba1831e8efb2 (diff)
merged with release_2_0
Diffstat (limited to 'muse2/muse/midiedit')
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp65
-rw-r--r--muse2/muse/midiedit/dcanvas.h2
-rw-r--r--muse2/muse/midiedit/drumedit.cpp206
-rw-r--r--muse2/muse/midiedit/drumedit.h20
-rw-r--r--muse2/muse/midiedit/ecanvas.cpp16
-rw-r--r--muse2/muse/midiedit/ecanvas.h6
-rw-r--r--muse2/muse/midiedit/pianoroll.cpp280
-rw-r--r--muse2/muse/midiedit/pianoroll.h14
-rw-r--r--muse2/muse/midiedit/prcanvas.cpp28
-rw-r--r--muse2/muse/midiedit/prcanvas.h2
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp1
11 files changed, 432 insertions, 208 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index ab967fa9..6c3f865f 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -31,6 +31,8 @@
#include <QDragMoveEvent>
#include <QDropEvent>
#include <QResizeEvent>
+#include <QList>
+#include <QPair>
#include <stdio.h>
#include <values.h>
@@ -404,6 +406,9 @@ CItem* DrumCanvas::newItem(int tick, int instrument, int velocity)
// else or if we found an alternative part (which has now been set as curPart)
tick -= curPart->tick();
+ if (tick < 0)
+ //tick=0;
+ return 0;
MusECore::Event e(MusECore::Note);
e.setTick(tick);
e.setPitch(instrument_map[instrument].pitch);
@@ -439,6 +444,8 @@ void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace)
DEvent* nevent = (DEvent*) item;
MusECore::Event event = nevent->event();
int x = item->x();
+ if (x<0)
+ x=0;
if (!noSnap)
x = editor->rasterVal(x);
event.setTick(x - nevent->part()->tick());
@@ -1101,8 +1108,9 @@ void DrumCanvas::resizeEvent(QResizeEvent* ev)
// modifySelected
//---------------------------------------------------------
-void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta)
+void DrumCanvas::modifySelected(NoteInfo::ValType type, int val, bool delta_mode)
{
+ QList< QPair<MusECore::EventList*,MusECore::Event> > already_done;
MusEGlobal::audio->msgIdle(true);
MusEGlobal::song->startUndo();
for (iCItem i = items.begin(); i != items.end(); ++i) {
@@ -1114,30 +1122,65 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta)
continue;
MusECore::MidiPart* part = (MusECore::MidiPart*)(e->part());
+
+ if (already_done.contains(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event)))
+ continue;
+
MusECore::Event newEvent = event.clone();
switch (type) {
- case NoteInfo::VAL_TIME:
+ case MusEGui::NoteInfo::VAL_TIME:
{
- int newTime = event.tick() + delta;
+ int newTime = val;
+ if(delta_mode)
+ newTime += event.tick();
+ else
+ newTime -= part->tick();
if (newTime < 0)
newTime = 0;
newEvent.setTick(newTime);
}
break;
- case NoteInfo::VAL_LEN:
- printf("DrumCanvas::modifySelected - NoteInfo::VAL_LEN not implemented\n");
+ case MusEGui::NoteInfo::VAL_LEN:
+ {
+ int len = val;
+ if(delta_mode)
+ len += event.lenTick();
+ if (len < 1)
+ len = 1;
+ newEvent.setLenTick(len);
+ }
break;
- case NoteInfo::VAL_VELON:
- printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELON not implemented\n");
+ case MusEGui::NoteInfo::VAL_VELON:
+ {
+ int velo = val;
+ if(delta_mode)
+ velo += event.velo();
+ if (velo > 127)
+ velo = 127;
+ else if (velo < 0)
+ velo = 0;
+ newEvent.setVelo(velo);
+ }
break;
- case NoteInfo::VAL_VELOFF:
- printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELOFF not implemented\n");
+ case MusEGui::NoteInfo::VAL_VELOFF:
+ {
+ int velo = val;
+ if(delta_mode)
+ velo += event.veloOff();
+ if (velo > 127)
+ velo = 127;
+ else if (velo < 0)
+ velo = 0;
+ newEvent.setVeloOff(velo);
+ }
break;
case NoteInfo::VAL_PITCH:
if (old_style_drummap_mode)
{
- int pitch = event.pitch() - delta; // Reversing order since the drumlist is displayed in increasing order
+ int pitch = val;
+ if(delta_mode)
+ pitch += event.pitch();
if (pitch > 127)
pitch = 127;
else if (pitch < 0)
@@ -1151,6 +1194,8 @@ void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta)
MusEGlobal::song->changeEvent(event, newEvent, part);
// Indicate do not do port controller values and clone parts.
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
+
+ already_done.append(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event));
}
MusEGlobal::song->endUndo(SC_EVENT_MODIFIED);
MusEGlobal::audio->msgIdle(false);
diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h
index ae647709..1cd8074a 100644
--- a/muse2/muse/midiedit/dcanvas.h
+++ b/muse2/muse/midiedit/dcanvas.h
@@ -158,7 +158,7 @@ class DrumCanvas : public EventCanvas {
const char* name = 0);
virtual ~DrumCanvas();
void cmd(int);
- virtual void modifySelected(NoteInfo::ValType type, int delta);
+ virtual void modifySelected(NoteInfo::ValType type, int val, bool delta_mode = true);
virtual void keyPress(QKeyEvent* event);
MusECore::Event *getEventAtCursorPos();
void selectCursorEvent(MusECore::Event *ev);
diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp
index e5b965f1..34a5bce5 100644
--- a/muse2/muse/midiedit/drumedit.cpp
+++ b/muse2/muse/midiedit/drumedit.cpp
@@ -149,8 +149,21 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
{
setFocusPolicy(Qt::NoFocus);
+ deltaMode = false;
+ tickValue = 0;
+ lenValue = 0;
+ pitchValue = 0;
+ veloOnValue = 0;
+ veloOffValue = 0;
+ firstValueSet = false;
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
+ lastSelections = 0;
split1w1 = 0;
- selPart = 0;
+ //selPart = 0;
QSignalMapper *signalMapper = new QSignalMapper(this);
_group_mode = GROUP_SAME_CHANNEL;
@@ -534,7 +547,6 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
header->hideSection(COL_HIDE);
dlist = new DList(header, split1w1, yscale, (DrumCanvas*)canvas, old_style_drummap_mode());
- // p3.3.44
setCurDrumInstrument(dlist->getSelectedInstrument());
connect(dlist, SIGNAL(keyPressed(int, int)), canvas, SLOT(keyPressed(int, int)));
@@ -567,8 +579,8 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int))); // in Canvas
connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool2(int))); // in DrumCanvas
- connect(canvas, SIGNAL(selectionChanged(int, MusECore::Event&, MusECore::Part*)), this,
- SLOT(setSelection(int, MusECore::Event&, MusECore::Part*)));
+ connect(canvas, SIGNAL(selectionChanged(int, MusECore::Event&, MusECore::Part*, bool)), this,
+ SLOT(setSelection(int, MusECore::Event&, MusECore::Part*, bool)));
connect(canvas, SIGNAL(followEvent(int)), SLOT(follow(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
@@ -582,6 +594,7 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
connect(toolbar, SIGNAL(rasterChanged(int)), SLOT(setRaster(int)));
connect(toolbar, SIGNAL(soloChanged(bool)), SLOT(soloChanged(bool)));
connect(info, SIGNAL(valueChanged(MusEGui::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEGui::NoteInfo::ValType, int)));
+ connect(info, SIGNAL(deltaModeChanged(bool)), SLOT(deltaModeChanged(bool)));
if(MusEGlobal::config.smartFocus)
{
connect(info, SIGNAL(returnPressed()), SLOT(focusCanvas()));
@@ -698,19 +711,79 @@ DrumEdit::~DrumEdit()
// update Info Line
//---------------------------------------------------------
-void DrumEdit::setSelection(int tick, MusECore::Event& e, MusECore::Part* p)
+void DrumEdit::setSelection(int tick, MusECore::Event& e, MusECore::Part*, bool update)
{
- selEvent = e;
- selPart = (MusECore::MidiPart*)p;
- selTick = tick;
- info->setEnabled(!e.empty());
- if (!e.empty()) {
- info->setValues(tick,
- selEvent.lenTick(),
- selEvent.pitch(),
- selEvent.velo(),
- selEvent.veloOff());
+ int selections = canvas->selectionSize();
+
+ // Diagnostics:
+ //printf("DrumEdit::setSelection selections:%d event empty:%d firstValueSet:%d\n", selections, e.empty(), firstValueSet);
+ //if(!e.empty())
+ // e.dump();
+
+ if(update)
+ {
+ // Selections have changed. Reset these.
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
+
+ // Force 'suggested' modes:
+ if (selections == 1)
+ {
+ deltaMode = false;
+ info->setDeltaMode(deltaMode);
+ }
+ else
+ if (selections > 1)
+ {
+ // A feeble attempt to hold on to the user's setting. Should try to bring back
+ // selEvent (removed), but there were problems using it (it's a reference).
+ //if(lastSelections <= 1)
+ {
+ deltaMode = true;
+ info->setDeltaMode(deltaMode);
+ }
+ }
+ }
+
+ lastSelections = selections;
+
+ if ((selections == 1) || (selections > 1 && !firstValueSet))
+ {
+ tickValue = tick;
+ lenValue = e.lenTick();
+ pitchValue = e.pitch();
+ veloOnValue = e.velo();
+ veloOffValue = e.veloOff();
+ firstValueSet = true;
+ }
+
+ if (selections > 0) {
+ info->setEnabled(true);
+ if (deltaMode)
+ info->setValues(tickOffset, lenOffset, pitchOffset, veloOnOffset, veloOffOffset);
+ else
+ info->setValues(tickValue, lenValue, pitchValue, veloOnValue, veloOffValue);
+ }
+ else {
+ info->setEnabled(false);
+ info->setValues(0, 0, 0, 0, 0);
+ firstValueSet = false;
+ tickValue = 0;
+ lenValue = 0;
+ pitchValue = 0;
+ veloOnValue = 0;
+ veloOffValue = 0;
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
}
+
+ info->setReturnMode(selections >= 2);
selectionChanged();
}
@@ -725,6 +798,30 @@ void DrumEdit::focusCanvas()
}
//---------------------------------------------------------
+// deltaModeChanged
+//---------------------------------------------------------
+
+void DrumEdit::deltaModeChanged(bool delta_on)
+{
+ if(deltaMode == delta_on)
+ return;
+ deltaMode = delta_on;
+
+ int selections = canvas->selectionSize();
+
+ if(deltaMode)
+ {
+ if(selections > 0)
+ info->setValues(tickOffset, lenOffset, pitchOffset, veloOnOffset, veloOffOffset);
+ }
+ else
+ {
+ if(selections > 0)
+ info->setValues(tickValue, lenValue, pitchValue, veloOnValue, veloOffValue);
+ }
+}
+
+//---------------------------------------------------------
// soloChanged
//---------------------------------------------------------
@@ -753,30 +850,62 @@ void DrumEdit::setRaster(int val)
void DrumEdit::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val)
{
- if (selEvent.empty()) {
- printf("noteinfoChanged while note is zero %d\n", type);
- return;
+ int selections = canvas->selectionSize();
+
+ if (selections == 0) {
+ printf("noteinfoChanged while nothing selected\n");
}
- MusECore::Event event = selEvent.clone();
- switch (type) {
- case MusEGui::NoteInfo::VAL_TIME:
- event.setTick(val - selPart->tick());
- break;
- case MusEGui::NoteInfo::VAL_LEN:
- event.setLenTick(val);
- break;
- case MusEGui::NoteInfo::VAL_VELON:
- event.setVelo(val);
- break;
- case MusEGui::NoteInfo::VAL_VELOFF:
- event.setVeloOff(val);
- break;
- case MusEGui::NoteInfo::VAL_PITCH:
- event.setPitch(val);
- break;
+ else if (selections > 0) {
+ if(deltaMode) {
+ // treat noteinfo values as offsets to event values
+ int delta = 0;
+ switch (type) {
+ case MusEGui::NoteInfo::VAL_TIME:
+ delta = val - tickOffset;
+ tickOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_LEN:
+ delta = val - lenOffset;
+ lenOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELON:
+ delta = val - veloOnOffset;
+ veloOnOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELOFF:
+ delta = val - veloOffOffset;
+ veloOffOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_PITCH:
+ delta = val - pitchOffset;
+ pitchOffset = val;
+ break;
+ }
+ if (delta)
+ canvas->modifySelected(type, delta);
+ }
+ else {
+ switch (type) {
+ case MusEGui::NoteInfo::VAL_TIME:
+ tickValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_LEN:
+ lenValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELON:
+ veloOnValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELOFF:
+ veloOffValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_PITCH:
+ pitchValue = val;
+ break;
+ }
+ canvas->modifySelected(type, val, false); // No delta mode.
+ }
}
- // Indicate do undo, and do not do port controller values and clone parts.
- MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart, true, false, false);
+
}
//---------------------------------------------------------
@@ -928,7 +1057,6 @@ void DrumEdit::writeConfiguration(int level, MusECore::Xml& xml)
void DrumEdit::load()
{
- //QString fn = MusEGui::getOpenFileName("drummaps", map_file_pattern,
QString fn = MusEGui::getOpenFileName("drummaps", MusEGlobal::drum_map_file_pattern,
this, tr("Muse: Load Drum Map"), 0);
if (fn.isEmpty())
@@ -1111,9 +1239,7 @@ CtrlEdit* DrumEdit::addCtrl()
setCurDrumInstrument(dlist->getSelectedInstrument());
- // p3.3.44
ctrlEdit->setTool(tools2->curTool());
-
ctrlEdit->setXPos(hscroll->pos());
ctrlEdit->setXMag(hscroll->getScaleValue());
diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h
index 907b8b84..7f2d26ce 100644
--- a/muse2/muse/midiedit/drumedit.h
+++ b/muse2/muse/midiedit/drumedit.h
@@ -80,11 +80,22 @@ class DrumEdit : public MidiEditor {
bool _ignore_hide;
bool _old_style_drummap_mode;
- MusECore::Event selEvent;
- MusECore::MidiPart* selPart;
- int selTick;
QMenu* menuEdit, *menuFunctions, *menuSelect;
+ int tickValue;
+ int lenValue;
+ int pitchValue;
+ int veloOnValue;
+ int veloOffValue;
+ bool firstValueSet;
+ int tickOffset;
+ int lenOffset;
+ int pitchOffset;
+ int veloOnOffset;
+ int veloOffOffset;
+ bool deltaMode;
+ int lastSelections;
+
MusEGui::NoteInfo* info;
QToolButton* srec;
QToolButton* midiin;
@@ -144,9 +155,10 @@ class DrumEdit : public MidiEditor {
void display_old_new_conflict_message();
void focusCanvas();
+ void deltaModeChanged(bool);
public slots:
- void setSelection(int, MusECore::Event&, MusECore::Part*);
+ void setSelection(int /*tick*/, MusECore::Event&, MusECore::Part*, bool /*update*/);
void soloChanged(bool); // called by Solo button
void execDeliveredScript(int);
void execUserScript(int);
diff --git a/muse2/muse/midiedit/ecanvas.cpp b/muse2/muse/midiedit/ecanvas.cpp
index 984ec41c..75757bf9 100644
--- a/muse2/muse/midiedit/ecanvas.cpp
+++ b/muse2/muse/midiedit/ecanvas.cpp
@@ -222,18 +222,26 @@ void EventCanvas::songChanged(int flags)
start_tick = MusEGlobal::song->roundDownBar(start_tick);
end_tick = MusEGlobal::song->roundUpBar(end_tick);
- if (n == 1 && _setCurPartIfOnlyOneEventIsSelected) {
+ if (n >= 1)
+ {
x = nevent->x();
event = nevent->event();
part = (MusECore::MidiPart*)nevent->part();
- if (curPart != part) {
+ if (_setCurPartIfOnlyOneEventIsSelected && n == 1 && curPart != part) {
curPart = part;
curPartId = curPart->sn();
curPartChanged();
}
- }
+ }
+
+ bool f1 = flags & (SC_EVENT_INSERTED | SC_EVENT_MODIFIED | SC_EVENT_REMOVED |
+ SC_PART_INSERTED | SC_PART_MODIFIED | SC_PART_REMOVED |
+ SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED |
+ SC_SIG | SC_TEMPO | SC_KEY | SC_MASTER | SC_CONFIG | SC_DRUMMAP);
+ bool f2 = flags & SC_SELECTION;
+ if(f1 || f2) // Try to avoid all unnecessary emissions.
+ emit selectionChanged(x, event, part, !f1);
- emit selectionChanged(x, event, part);
if (curPart == 0)
curPart = (MusECore::MidiPart*)(editor->parts()->begin()->second);
redraw();
diff --git a/muse2/muse/midiedit/ecanvas.h b/muse2/muse/midiedit/ecanvas.h
index 349bb92b..454ae3fa 100644
--- a/muse2/muse/midiedit/ecanvas.h
+++ b/muse2/muse/midiedit/ecanvas.h
@@ -57,9 +57,9 @@ class MidiEditor;
class EventCanvas : public Canvas {
Q_OBJECT
+
virtual void leaveEvent(QEvent*e);
virtual void enterEvent(QEvent*e);
-
virtual void mouseMove(QMouseEvent* event);
protected:
@@ -86,7 +86,7 @@ class EventCanvas : public Canvas {
signals:
void pitchChanged(int); // current cursor position
void timeChanged(unsigned);
- void selectionChanged(int, MusECore::Event&, MusECore::Part*);
+ void selectionChanged(int /*tick*/ , MusECore::Event&, MusECore::Part*, bool /*update*/);
void enterCanvas();
public:
@@ -102,7 +102,7 @@ class EventCanvas : public Canvas {
void playEvents(bool flag) { _playEvents = flag; }
void selectAtTick(unsigned int tick);
void viewDropEvent(QDropEvent* event);
- virtual void modifySelected(NoteInfo::ValType, int) {}
+ virtual void modifySelected(NoteInfo::ValType, int /*val*/, bool /*delta_mode*/ = true) {}
virtual void keyPress(QKeyEvent*);
};
diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp
index 71b2abf8..d8608c70 100644
--- a/muse2/muse/midiedit/pianoroll.cpp
+++ b/muse2/muse/midiedit/pianoroll.cpp
@@ -87,8 +87,19 @@ static int pianorollTools = MusEGui::PointerTool | MusEGui::PencilTool | MusEGui
PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name, unsigned initPos)
: MidiEditor(TopWin::PIANO_ROLL, _rasterInit, pl, parent, name)
{
- deltaMode = false;
- selPart = 0;
+ deltaMode = false;
+ tickValue = 0;
+ lenValue = 0;
+ pitchValue = 0;
+ veloOnValue = 0;
+ veloOffValue = 0;
+ firstValueSet = false;
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
+ lastSelections = 0;
_playEvents = false;
colorMode = colorModeInit;
@@ -339,36 +350,12 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
mainGrid->setColumnStretch(1, 100);
mainGrid->addWidget(hsplitter, 0, 1, 1, 3);
- // Original. DELETETHIS 21
- /*
- mainGrid->setColumnStretch(1, 100);
- mainGrid->addWidget(splitter, 0, 0, 1, 3);
- mainGrid->addWidget(ctrl, 1, 0);
- mainGrid->addWidget(hscroll, 1, 1);
- mainGrid->addWidget(corner, 1, 2, Qt::AlignBottom|Qt::AlignRight);
- */
-
-
- // Tim.
- /*
- mainGrid->setColumnStretch(2, 100);
- mainGrid->addWidget(splitter, 0, 0, 1, 4);
- mainGrid->addWidget(trackInfoButton, 1, 0);
- mainGrid->addWidget(ctrl, 1, 1);
- mainGrid->addWidget(hscroll, 1, 2);
- mainGrid->addWidget(corner, 1, 3, Qt::AlignBottom|Qt::AlignRight);
- */
-
- //mainGrid->addRowSpacing(1, hscroll->sizeHint().height());
- //mainGrid->addItem(new QSpacerItem(0, hscroll->sizeHint().height()), 1, 0); // Orig + Tim.
-
QWidget* split1 = new QWidget(splitter);
split1->setObjectName("split1");
QGridLayout* gridS1 = new QGridLayout(split1);
gridS1->setContentsMargins(0, 0, 0, 0);
gridS1->setSpacing(0);
- //Defined and configure your program change bar here.
- //This may well be a copy of MTScale extended for our needs
+
time = new MusEGui::MTScale(&_raster, split1, xscale);
Piano* piano = new Piano(split1, yscale);
canvas = new PianoCanvas(this, split1, xscale, yscale);
@@ -385,7 +372,6 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
gridS1->setRowStretch(2, 100);
gridS1->setColumnStretch(1, 100);
- //gridS1->setColumnStretch(2, 100); // Tim. DELETETHIS
gridS1->addWidget(time, 0, 1, 1, 2);
gridS1->addWidget(MusECore::hLine(split1), 1, 0, 1, 3);
@@ -393,17 +379,6 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
gridS1->addWidget(canvas, 2, 1);
gridS1->addWidget(vscroll, 2, 2);
- // Tim. DELETETHIS
- /*
- gridS1->addWidget(time, 0, 2, 1, 3);
- gridS1->addWidget(MusECore::hLine(split1), 1, 1, 1, 4);
- //gridS1->addWidget(infoScroll, 2, 0);
- gridS1->addWidget(infoScroll, 0, 0, 3, 1);
- gridS1->addWidget(piano, 2, 1);
- gridS1->addWidget(canvas, 2, 2);
- gridS1->addWidget(vscroll, 2, 3);
- */
-
ctrlLane = new MusEGui::Splitter(Qt::Vertical, splitter, "ctrllane");
QWidget* split2 = new QWidget(splitter);
split2->setMaximumHeight(hscroll->sizeHint().height());
@@ -416,7 +391,6 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
gridS2->addWidget(ctrl, 0, 0);
gridS2->addWidget(hscroll, 0, 1);
gridS2->addWidget(corner, 0, 2, Qt::AlignBottom|Qt::AlignRight);
- //splitter->setCollapsible(0, true); DELETETHIS
piano->setFixedWidth(pianoWidth);
@@ -428,8 +402,8 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl()));
- //connect(trackInfoButton, SIGNAL(clicked()), SLOT(toggleTrackInfo())); Tim. DELETETHIS
connect(info, SIGNAL(valueChanged(MusEGui::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEGui::NoteInfo::ValType, int)));
+ connect(info, SIGNAL(deltaModeChanged(bool)), SLOT(deltaModeChanged(bool)));
connect(vscroll, SIGNAL(scrollChanged(int)), piano, SLOT(setYPos(int)));
connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
@@ -447,8 +421,8 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
connect(canvas, SIGNAL(verticalScroll(unsigned)), vscroll, SLOT(setPos(unsigned)));
connect(canvas, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned)));
connect(canvas, SIGNAL(horizontalScrollNoLimit(unsigned)),hscroll, SLOT(setPosNoLimit(unsigned)));
- connect(canvas, SIGNAL(selectionChanged(int, MusECore::Event&, MusECore::Part*)), this,
- SLOT(setSelection(int, MusECore::Event&, MusECore::Part*)));
+ connect(canvas, SIGNAL(selectionChanged(int, MusECore::Event&, MusECore::Part*, bool)), this,
+ SLOT(setSelection(int, MusECore::Event&, MusECore::Part*, bool)));
connect(piano, SIGNAL(keyPressed(int, int, bool)), canvas, SLOT(pianoPressed(int, int, bool)));
connect(piano, SIGNAL(keyReleased(int, bool)), canvas, SLOT(pianoReleased(int, bool)));
@@ -570,7 +544,6 @@ void PianoRoll::updateTrackInfo()
selected = curCanvasPart()->track();
if (selected->isMidiTrack()) {
midiTrackInfo->setTrack(selected);
- ///midiTrackInfo->updateTrackInfo(-1);
}
}
@@ -651,41 +624,79 @@ void PianoRoll::cmd(int cmd)
// update Info Line
//---------------------------------------------------------
-void PianoRoll::setSelection(int tick, MusECore::Event& e, MusECore::Part* p)
+void PianoRoll::setSelection(int tick, MusECore::Event& e, MusECore::Part* /*part*/, bool update)
{
int selections = canvas->selectionSize();
- selEvent = e;
- selPart = (MusECore::MidiPart*)p;
- selTick = tick;
+ // Diagnostics:
+ //printf("PianoRoll::setSelection selections:%d event empty:%d firstValueSet:%d\n", selections, e.empty(), firstValueSet);
+ //if(!e.empty())
+ // e.dump();
+
+ if(update)
+ {
+ // Selections have changed. Reset these.
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
+
+ // Force 'suggested' modes:
+ if (selections == 1)
+ {
+ deltaMode = false;
+ info->setDeltaMode(deltaMode);
+ }
+ else
+ if (selections > 1)
+ {
+ // A feeble attempt to hold on to the user's setting. Should try to bring back
+ // selEvent (removed), but there were problems using it (it's a reference).
+ //if(lastSelections <= 1)
+ {
+ deltaMode = true;
+ info->setDeltaMode(deltaMode);
+ }
+ }
+ }
- if (selections > 1) {
- info->setEnabled(true);
- info->setDeltaMode(true);
- if (!deltaMode) {
- deltaMode = true;
- info->setValues(0, 0, 0, 0, 0);
- tickOffset = 0;
- lenOffset = 0;
- pitchOffset = 0;
- veloOnOffset = 0;
- veloOffOffset = 0;
- }
- }
- else if (selections == 1) {
- deltaMode = false;
+ lastSelections = selections;
+
+ if ((selections == 1) || (selections > 1 && !firstValueSet))
+ {
+ tickValue = tick;
+ lenValue = e.lenTick();
+ pitchValue = e.pitch();
+ veloOnValue = e.velo();
+ veloOffValue = e.veloOff();
+ firstValueSet = true;
+ }
+
+ if (selections > 0) {
info->setEnabled(true);
- info->setDeltaMode(false);
- info->setValues(tick,
- selEvent.lenTick(),
- selEvent.pitch(),
- selEvent.velo(),
- selEvent.veloOff());
+ if (deltaMode)
+ info->setValues(tickOffset, lenOffset, pitchOffset, veloOnOffset, veloOffOffset);
+ else
+ info->setValues(tickValue, lenValue, pitchValue, veloOnValue, veloOffValue);
}
else {
- deltaMode = false;
info->setEnabled(false);
+ info->setValues(0, 0, 0, 0, 0);
+ firstValueSet = false;
+ tickValue = 0;
+ lenValue = 0;
+ pitchValue = 0;
+ veloOnValue = 0;
+ veloOffValue = 0;
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
}
+
+ info->setReturnMode(selections >= 2);
selectionChanged();
}
@@ -700,6 +711,25 @@ void PianoRoll::focusCanvas()
}
//---------------------------------------------------------
+// deltaModeChanged
+//---------------------------------------------------------
+
+void PianoRoll::deltaModeChanged(bool delta_on)
+{
+ if(deltaMode == delta_on)
+ return;
+ deltaMode = delta_on;
+
+ if(canvas->selectionSize() > 0)
+ {
+ if(deltaMode)
+ info->setValues(tickOffset, lenOffset, pitchOffset, veloOnOffset, veloOffOffset);
+ else
+ info->setValues(tickValue, lenValue, pitchValue, veloOnValue, veloOffValue);
+ }
+}
+
+//---------------------------------------------------------
// edit currently selected Event
//---------------------------------------------------------
@@ -710,57 +740,55 @@ void PianoRoll::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val)
if (selections == 0) {
printf("noteinfoChanged while nothing selected\n");
}
- else if (selections == 1) {
- MusECore::Event event = selEvent.clone();
- switch(type) {
- case MusEGui::NoteInfo::VAL_TIME:
- event.setTick(val - selPart->tick());
- break;
- case MusEGui::NoteInfo::VAL_LEN:
- event.setLenTick(val);
- break;
- case MusEGui::NoteInfo::VAL_VELON:
- event.setVelo(val);
- break;
- case MusEGui::NoteInfo::VAL_VELOFF:
- event.setVeloOff(val);
- break;
- case MusEGui::NoteInfo::VAL_PITCH:
- event.setPitch(val);
- break;
+ else if (selections > 0) {
+ if(deltaMode) {
+ // treat noteinfo values as offsets to event values
+ int delta = 0;
+ switch (type) {
+ case MusEGui::NoteInfo::VAL_TIME:
+ delta = val - tickOffset;
+ tickOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_LEN:
+ delta = val - lenOffset;
+ lenOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELON:
+ delta = val - veloOnOffset;
+ veloOnOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELOFF:
+ delta = val - veloOffOffset;
+ veloOffOffset = val;
+ break;
+ case MusEGui::NoteInfo::VAL_PITCH:
+ delta = val - pitchOffset;
+ pitchOffset = val;
+ break;
+ }
+ if (delta)
+ canvas->modifySelected(type, delta);
}
- // Indicate do undo, and do not do port controller values and clone parts.
- MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart, true, false, false);
- }
- else {
- // multiple events are selected; treat noteinfo values
- // as offsets to event values
-
- int delta = 0;
- switch (type) {
- case MusEGui::NoteInfo::VAL_TIME:
- delta = val - tickOffset;
- tickOffset = val;
- break;
- case MusEGui::NoteInfo::VAL_LEN:
- delta = val - lenOffset;
- lenOffset = val;
- break;
- case MusEGui::NoteInfo::VAL_VELON:
- delta = val - veloOnOffset;
- veloOnOffset = val;
- break;
- case MusEGui::NoteInfo::VAL_VELOFF:
- delta = val - veloOffOffset;
- veloOffOffset = val;
- break;
- case MusEGui::NoteInfo::VAL_PITCH:
- delta = val - pitchOffset;
- pitchOffset = val;
- break;
+ else {
+ switch (type) {
+ case MusEGui::NoteInfo::VAL_TIME:
+ tickValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_LEN:
+ lenValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELON:
+ veloOnValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_VELOFF:
+ veloOffValue = val;
+ break;
+ case MusEGui::NoteInfo::VAL_PITCH:
+ pitchValue = val;
+ break;
+ }
+ canvas->modifySelected(type, val, false); // No delta mode.
}
- if (delta)
- canvas->modifySelected(type, delta);
}
}
@@ -1226,20 +1254,6 @@ void PianoRoll::setSpeaker(bool val)
canvas->playEvents(_playEvents);
}
-
-
-/* DELETETHIS
-//---------------------------------------------------------
-// trackInfoScroll
-//---------------------------------------------------------
-
-void PianoRoll::trackInfoScroll(int y)
- {
- if (trackInfo->visibleWidget())
- trackInfo->visibleWidget()->move(0, -y);
- }
-*/
-
//---------------------------------------------------------
// initShortcuts
//---------------------------------------------------------
diff --git a/muse2/muse/midiedit/pianoroll.h b/muse2/muse/midiedit/pianoroll.h
index 20ae093e..ad77b973 100644
--- a/muse2/muse/midiedit/pianoroll.h
+++ b/muse2/muse/midiedit/pianoroll.h
@@ -72,10 +72,6 @@ class Toolbar1;
class PianoRoll : public MidiEditor {
Q_OBJECT
- MusECore::Event selEvent;
- MusECore::MidiPart* selPart;
- int selTick;
-
QMenu *menuEdit, *menuFunctions, *menuSelect, *menuConfig, *eventColor, *menuPlugins;
MusEGui::MidiTrackInfo *midiTrackInfo;
MusECore::Track* selected;
@@ -110,12 +106,19 @@ class PianoRoll : public MidiEditor {
QAction* funcDelOverlapsAction;
+ int tickValue;
+ int lenValue;
+ int pitchValue;
+ int veloOnValue;
+ int veloOffValue;
+ bool firstValueSet;
int tickOffset;
int lenOffset;
int pitchOffset;
int veloOnOffset;
int veloOffOffset;
bool deltaMode;
+ int lastSelections;
MusEGui::NoteInfo* info;
QToolButton* srec;
@@ -148,7 +151,7 @@ class PianoRoll : public MidiEditor {
virtual void keyPressEvent(QKeyEvent*);
private slots:
- void setSelection(int, MusECore::Event&, MusECore::Part*);
+ void setSelection(int /*tick*/, MusECore::Event&, MusECore::Part*, bool /*update*/);
void noteinfoChanged(MusEGui::NoteInfo::ValType, int);
void removeCtrl(CtrlEdit* ctrl);
void soloChanged(bool flag);
@@ -167,6 +170,7 @@ class PianoRoll : public MidiEditor {
void toggleTrackInfo();
void updateTrackInfo();
void focusCanvas();
+ void deltaModeChanged(bool);
signals:
void isDeleting(MusEGui::TopWin*);
diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp
index 794e04ad..0ccabbe0 100644
--- a/muse2/muse/midiedit/prcanvas.cpp
+++ b/muse2/muse/midiedit/prcanvas.cpp
@@ -492,7 +492,8 @@ MusEGui::CItem* PianoCanvas::newItem(const QPoint& p, int)
int len = p.x() - tick;
tick -= curPart->tick();
if (tick < 0)
- tick=0;
+ //tick=0;
+ return 0;
MusECore::Event e = MusECore::Event(MusECore::Note);
e.setTick(tick);
e.setPitch(pitch);
@@ -1064,7 +1065,7 @@ void PianoCanvas::curPartChanged()
// modifySelected
//---------------------------------------------------------
-void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
+void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int val, bool delta_mode)
{
QList< QPair<MusECore::EventList*,MusECore::Event> > already_done;
MusEGlobal::audio->msgIdle(true);
@@ -1087,7 +1088,11 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
switch (type) {
case MusEGui::NoteInfo::VAL_TIME:
{
- int newTime = event.tick() + delta;
+ int newTime = val;
+ if(delta_mode)
+ newTime += event.tick();
+ else
+ newTime -= part->tick();
if (newTime < 0)
newTime = 0;
newEvent.setTick(newTime);
@@ -1095,7 +1100,9 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
break;
case MusEGui::NoteInfo::VAL_LEN:
{
- int len = event.lenTick() + delta;
+ int len = val;
+ if(delta_mode)
+ len += event.lenTick();
if (len < 1)
len = 1;
newEvent.setLenTick(len);
@@ -1103,7 +1110,9 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
break;
case MusEGui::NoteInfo::VAL_VELON:
{
- int velo = event.velo() + delta;
+ int velo = val;
+ if(delta_mode)
+ velo += event.velo();
if (velo > 127)
velo = 127;
else if (velo < 0)
@@ -1113,7 +1122,9 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
break;
case MusEGui::NoteInfo::VAL_VELOFF:
{
- int velo = event.veloOff() + delta;
+ int velo = val;
+ if(delta_mode)
+ velo += event.veloOff();
if (velo > 127)
velo = 127;
else if (velo < 0)
@@ -1123,7 +1134,9 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
break;
case MusEGui::NoteInfo::VAL_PITCH:
{
- int pitch = event.pitch() + delta;
+ int pitch = val;
+ if(delta_mode)
+ pitch += event.pitch();
if (pitch > 127)
pitch = 127;
else if (pitch < 0)
@@ -1132,6 +1145,7 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
}
break;
}
+
MusEGlobal::song->changeEvent(event, newEvent, part);
// Indicate do not do port controller values and clone parts.
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
diff --git a/muse2/muse/midiedit/prcanvas.h b/muse2/muse/midiedit/prcanvas.h
index 35e4975f..ee83c88e 100644
--- a/muse2/muse/midiedit/prcanvas.h
+++ b/muse2/muse/midiedit/prcanvas.h
@@ -126,7 +126,7 @@ class PianoCanvas : public EventCanvas {
colorMode = mode;
redraw();
}
- virtual void modifySelected(NoteInfo::ValType type, int delta);
+ virtual void modifySelected(NoteInfo::ValType type, int val, bool delta_mode = true);
};
} // namespace MusEGui
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index d8529794..44629eef 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4702,6 +4702,7 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
* from clipboard failed. ignoring this one... ) [ not reproducible ]
* o test drum controllers
* o test old- and new drumtrack recording, steprecording
+ * o velo-controller doesn't work in new-style drum tracks
*
* CURRENT TODO
* o column's widths aren't stored into configuration. fix that.