diff options
Diffstat (limited to 'muse2/muse/midiedit')
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 400 | ||||
-rw-r--r-- | muse2/muse/midiedit/dcanvas.h | 57 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.cpp | 139 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.h | 25 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.cpp | 174 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.h | 57 | ||||
-rw-r--r-- | muse2/muse/midiedit/drummap.cpp | 82 | ||||
-rw-r--r-- | muse2/muse/midiedit/drummap.h | 15 | ||||
-rw-r--r-- | muse2/muse/midiedit/ecanvas.cpp | 84 | ||||
-rw-r--r-- | muse2/muse/midiedit/ecanvas.h | 30 | ||||
-rw-r--r-- | muse2/muse/midiedit/piano.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/piano.h | 2 | ||||
-rw-r--r-- | muse2/muse/midiedit/pianoroll.cpp | 154 | ||||
-rw-r--r-- | muse2/muse/midiedit/pianoroll.h | 78 | ||||
-rw-r--r-- | muse2/muse/midiedit/prcanvas.cpp | 307 | ||||
-rw-r--r-- | muse2/muse/midiedit/prcanvas.h | 42 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 305 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.h | 106 |
18 files changed, 1071 insertions, 988 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index c6b39e76..22db70d0 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -58,11 +58,13 @@ using MusEGlobal::debugMsg; using MusEGlobal::heavyDebugMsg; +namespace MusEGui { + //--------------------------------------------------------- // DEvent //--------------------------------------------------------- -DEvent::DEvent(Event e, Part* p, int instr) +DEvent::DEvent(MusECore::Event e, MusECore::Part* p, int instr) : CItem(e, p) { int y = instr * TH + TH/2; @@ -75,7 +77,7 @@ DEvent::DEvent(Event e, Part* p, int instr) // addItem //--------------------------------------------------------- -void DrumCanvas::addItem(Part* part, Event& event) +void DrumCanvas::addItem(MusECore::Part* part, MusECore::Event& event) { if (signed(event.tick())<0) { printf("ERROR: trying to add event before current part!\n"); @@ -95,9 +97,9 @@ void DrumCanvas::addItem(Part* part, Event& event) int diff = event.endTick()-part->lenTick(); if (diff > 0) {// too short part? extend it //printf("addItem - this code should not be run!\n"); - //Part* newPart = part->clone(); + //MusECore::Part* newPart = part->clone(); //newPart->setLenTick(newPart->lenTick()+diff); - //audio->msgChangePart(part, newPart,false); + //MusEGlobal::audio->msgChangePart(part, newPart,false); //part = newPart; part->setLenTick(part->lenTick()+diff); } @@ -118,11 +120,11 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, if (old_style_drummap_mode) { if (debugMsg) printf("DrumCanvas in old style drummap mode\n"); - ourDrumMap = drumMap; + ourDrumMap = MusEGlobal::drumMap; must_delete_our_drum_map=false; instrument_number_mapping_t temp; - for (ciPart it=drumEditor->parts()->begin(); it!=drumEditor->parts()->end(); it++) + for (MusECore::ciPart it=drumEditor->parts()->begin(); it!=drumEditor->parts()->end(); it++) temp.tracks.insert(it->second->track()); for (int i=0;i<DRUM_MAPSIZE;i++) @@ -144,10 +146,10 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, cursorPos= QPoint(0,0); _stepSize=1; - steprec=new StepRec(NULL); + steprec=new MusECore::StepRec(NULL); songChanged(SC_TRACK_INSERTED); - connect(song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int))); + connect(MusEGlobal::song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int))); } DrumCanvas::~DrumCanvas() @@ -163,24 +165,24 @@ DrumCanvas::~DrumCanvas() // moveCanvasItems //--------------------------------------------------------- -Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, DragType dtype) +MusECore::Undo DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype) { if(editor->parts()->empty()) - return Undo(); //return empty list + return MusECore::Undo(); //return empty list - PartsToChangeMap parts2change; - Undo operations; + MusECore::PartsToChangeMap parts2change; + MusECore::Undo operations; - for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) + for(MusECore::iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) { - Part* part = ip->second; + MusECore::Part* part = ip->second; if(!part) continue; int npartoffset = 0; - for(MusEWidget::iCItem ici = items.begin(); ici != items.end(); ++ici) + for(iCItem ici = items.begin(); ici != items.end(); ++ici) { - MusEWidget::CItem* ci = ici->second; + CItem* ci = ici->second; if(ci->part() != part) continue; @@ -190,7 +192,7 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D // Test moving the item... DEvent* nevent = (DEvent*) ci; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); x = newpos.x(); if(x < 0) x = 0; @@ -206,11 +208,11 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D if(npartoffset > 0) { - iPartToChange ip2c = parts2change.find(part); + MusECore::iPartToChange ip2c = parts2change.find(part); if(ip2c == parts2change.end()) { - PartToChange p2c = {0, npartoffset}; - parts2change.insert(std::pair<Part*, PartToChange> (part, p2c)); + MusECore::PartToChange p2c = {0, npartoffset}; + parts2change.insert(std::pair<MusECore::Part*, MusECore::PartToChange> (part, p2c)); } else ip2c->second.xdiff = npartoffset; @@ -218,9 +220,9 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D } bool forbidden=false; - for(iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) + for(MusECore::iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) { - Part* opart = ip2c->first; + MusECore::Part* opart = ip2c->first; if (opart->hasHiddenEvents()) { forbidden=true; @@ -231,12 +233,12 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D if (!forbidden) { - std::vector< MusEWidget::CItem* > doneList; - typedef std::vector< MusEWidget::CItem* >::iterator iDoneList; + std::vector< CItem* > doneList; + typedef std::vector< CItem* >::iterator iDoneList; - for(MusEWidget::iCItem ici = items.begin(); ici != items.end(); ++ici) + for(iCItem ici = items.begin(); ici != items.end(); ++ici) { - MusEWidget::CItem* ci = ici->second; + CItem* ci = ici->second; int x = ci->pos().x(); int y = ci->pos().y(); @@ -266,9 +268,9 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D selectItem(ci, false); } - for(iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) + for(MusECore::iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) { - Part* opart = ip2c->first; + MusECore::Part* opart = ip2c->first; int diff = ip2c->second.xdiff; schedule_resize_all_same_len_clone_parts(opart, opart->lenTick() + diff, operations); @@ -278,7 +280,7 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D } else { - return Undo(); //return empty list + return MusECore::Undo(); //return empty list } } @@ -286,13 +288,13 @@ Undo DrumCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, D // moveItem //--------------------------------------------------------- -UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype) +MusECore::UndoOp DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype) { DEvent* nevent = (DEvent*) item; - MidiPart* part = (MidiPart*)nevent->part(); + MusECore::MidiPart* part = (MusECore::MidiPart*)nevent->part(); - Event event = nevent->event(); + MusECore::Event event = nevent->event(); int x = pos.x(); if (x < 0) x = 0; @@ -300,14 +302,14 @@ UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType if (ntick < 0) ntick = 0; int nheight = y2pitch(pos.y()); - Event newEvent = event.clone(); + MusECore::Event newEvent = event.clone(); - Track* dest_track = part->track(); + MusECore::Track* dest_track = part->track(); if (!instrument_map[nheight].tracks.contains(dest_track)) { printf ("TODO FIXME: tried to move an event into a different track. this is not supported yet, but will be soon. ignoring this one...\n"); //FINDMICH - return UndoOp(); + return MusECore::UndoOp(); } int ev_pitch = instrument_map[nheight].pitch; @@ -321,18 +323,18 @@ UndoOp DrumCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType // printf("DrumCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData()); if (dtype == MOVE_COPY || dtype == MOVE_CLONE) - return UndoOp(UndoOp::AddEvent, newEvent, part, false, false); + return MusECore::UndoOp(MusECore::UndoOp::AddEvent, newEvent, part, false, false); else - return UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false); + return MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false); } //--------------------------------------------------------- // newItem //--------------------------------------------------------- -MusEWidget::CItem* DrumCanvas::newItem(const QPoint& p, int state) +CItem* DrumCanvas::newItem(const QPoint& p, int state) { - int instr = y2pitch(p.y()); //drumInmap[y2pitch(p.y())]; + int instr = y2pitch(p.y()); //MusEGlobal::drumInmap[y2pitch(p.y())]; int velo = ourDrumMap[instr].lv4; if (state == Qt::ShiftModifier) velo = ourDrumMap[instr].lv3; @@ -348,7 +350,7 @@ MusEWidget::CItem* DrumCanvas::newItem(const QPoint& p, int state) // newItem //--------------------------------------------------------- -MusEWidget::CItem* DrumCanvas::newItem(int tick, int instrument, int velocity) +CItem* DrumCanvas::newItem(int tick, int instrument, int velocity) { if (!old_style_drummap_mode && !instrument_map[instrument].tracks.contains(curPart->track())) { @@ -358,7 +360,7 @@ MusEWidget::CItem* DrumCanvas::newItem(int tick, int instrument, int velocity) else { tick -= curPart->tick(); - Event e(Note); + MusECore::Event e(MusECore::Note); e.setTick(tick); e.setPitch(instrument_map[instrument].pitch); e.setVelo(velocity); @@ -372,27 +374,27 @@ MusEWidget::CItem* DrumCanvas::newItem(int tick, int instrument, int velocity) // resizeItem //--------------------------------------------------------- -void DrumCanvas::resizeItem(MusEWidget::CItem* item, bool, bool) +void DrumCanvas::resizeItem(CItem* item, bool, bool) { DEvent* nevent = (DEvent*) item; - Event ev = nevent->event(); + MusECore::Event ev = nevent->event(); // Indicate do undo, and do not do port controller values and clone parts. - audio->msgDeleteEvent(ev, nevent->part(), true, false, false); + MusEGlobal::audio->msgDeleteEvent(ev, nevent->part(), true, false, false); } //--------------------------------------------------------- // newItem //--------------------------------------------------------- -void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap) { +void DrumCanvas::newItem(CItem* item, bool noSnap) { newItem(item, noSnap,false); } -void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) +void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace) { if (item) { DEvent* nevent = (DEvent*) item; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); int x = item->x(); if (!noSnap) x = editor->rasterVal(x); @@ -404,19 +406,19 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) // check for existing event // if found change command semantic from insert to delete // - EventList* el = nevent->part()->events(); - iEvent lower = el->lower_bound(event.tick()); - iEvent upper = el->upper_bound(event.tick()); + MusECore::EventList* el = nevent->part()->events(); + MusECore::iEvent lower = el->lower_bound(event.tick()); + MusECore::iEvent upper = el->upper_bound(event.tick()); - for (iEvent i = lower; i != upper; ++i) { - Event ev = i->second; + for (MusECore::iEvent i = lower; i != upper; ++i) { + MusECore::Event ev = i->second; // Added by T356. Only do notes. if(!ev.isNote()) continue; if (ev.pitch() == npitch) { // Indicate do undo, and do not do port controller values and clone parts. - audio->msgDeleteEvent(ev, nevent->part(), true, false, false); + MusEGlobal::audio->msgDeleteEvent(ev, nevent->part(), true, false, false); if (replace) break; else @@ -426,13 +428,13 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) } // Added by T356. - Part* part = nevent->part(); - Undo operations; + MusECore::Part* part = nevent->part(); + MusECore::Undo operations; int diff = event.endTick()-part->lenTick(); if (! ((diff > 0) && part->hasHiddenEvents()) ) //operation is allowed { - operations.push_back(UndoOp(UndoOp::AddEvent,event, part, false, false)); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddEvent,event, part, false, false)); if (diff > 0) // part must be extended? { @@ -441,7 +443,7 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) } } //else forbid action by not applying it - song->applyOperationGroup(operations); + MusEGlobal::song->applyOperationGroup(operations); songChanged(SC_EVENT_INSERTED); //this forces an update of the itemlist, which is neccessary //to remove "forbidden" events from the list again } @@ -453,11 +455,11 @@ void DrumCanvas::newItem(MusEWidget::CItem* item, bool noSnap, bool replace) // deleteItem //--------------------------------------------------------- -bool DrumCanvas::deleteItem(MusEWidget::CItem* item) +bool DrumCanvas::deleteItem(CItem* item) { - Event ev = ((DEvent*)item)->event(); + MusECore::Event ev = ((DEvent*)item)->event(); // Indicate do undo, and do not do port controller values and clone parts. - audio->msgDeleteEvent(ev, ((DEvent*)item)->part(), true, false, false); + MusEGlobal::audio->msgDeleteEvent(ev, ((DEvent*)item)->part(), true, false, false); return false; } @@ -465,7 +467,7 @@ bool DrumCanvas::deleteItem(MusEWidget::CItem* item) // drawItem //--------------------------------------------------------- -void DrumCanvas::drawItem(QPainter&p, const MusEWidget::CItem*item, const QRect& rect) +void DrumCanvas::drawItem(QPainter&p, const CItem*item, const QRect& rect) { DEvent* e = (DEvent*) item; int x = 0, y = 0; @@ -502,7 +504,7 @@ void DrumCanvas::drawItem(QPainter&p, const MusEWidget::CItem*item, const QRect& else { int velo = e->event().velo(); - DrumMap* dm = &ourDrumMap[y2pitch(y)]; //Get the drum item + MusECore::DrumMap* dm = &ourDrumMap[y2pitch(y)]; //Get the drum item QColor color; if (velo < dm->lv1) color.setRgb(240, 240, 255); @@ -523,7 +525,7 @@ void DrumCanvas::drawItem(QPainter&p, const MusEWidget::CItem*item, const QRect& // draws moving items //--------------------------------------------------------- -void DrumCanvas::drawMoving(QPainter& p, const MusEWidget::CItem* item, const QRect& rect) +void DrumCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect) { QPolygon pa(4); QPoint pt = map(item->mp()); @@ -576,7 +578,7 @@ void DrumCanvas::drawCanvas(QPainter& p, const QRect& rect) void DrumCanvas::drawTopItem(QPainter& p, const QRect&) { // draw cursor - if (_tool == MusEWidget::CursorTool) { + if (_tool == CursorTool) { p.setPen(Qt::black); int y = mapy(TH * cursorPos.y()); @@ -615,7 +617,7 @@ void DrumCanvas::cmd(int cmd) { switch (cmd) { case CMD_SELECT_ALL: // select all - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (iCItem k = items.begin(); k != items.end(); ++k) { if (!k->second->isSelected()) selectItem(k->second, true); } @@ -624,29 +626,29 @@ void DrumCanvas::cmd(int cmd) deselectAll(); break; case CMD_SELECT_INVERT: // invert selection - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (iCItem k = items.begin(); k != items.end(); ++k) { selectItem(k->second, !k->second->isSelected()); } break; case CMD_SELECT_ILOOP: // select inside loop - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (iCItem k = items.begin(); k != items.end(); ++k) { DEvent* nevent =(DEvent*)(k->second); - Part* part = nevent->part(); - Event event = nevent->event(); + MusECore::Part* part = nevent->part(); + MusECore::Event event = nevent->event(); unsigned tick = event.tick() + part->tick(); - if (tick < song->lpos() || tick >= song->rpos()) + if (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()) selectItem(k->second, false); else selectItem(k->second, true); } break; case CMD_SELECT_OLOOP: // select outside loop - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (iCItem k = items.begin(); k != items.end(); ++k) { DEvent* nevent = (DEvent*)(k->second); - Part* part = nevent->part(); - Event event = nevent->event(); + MusECore::Part* part = nevent->part(); + MusECore::Event event = nevent->event(); unsigned tick = event.tick() + part->tick(); - if (tick < song->lpos() || tick >= song->rpos()) + if (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()) selectItem(k->second, true); else selectItem(k->second, false); @@ -654,10 +656,10 @@ void DrumCanvas::cmd(int cmd) break; case CMD_SELECT_PREV_PART: // select previous part { - Part* pt = editor->curCanvasPart(); - Part* newpt = pt; - PartList* pl = editor->parts(); - for(iPart ip = pl->begin(); ip != pl->end(); ++ip) + MusECore::Part* pt = editor->curCanvasPart(); + MusECore::Part* newpt = pt; + MusECore::PartList* pl = editor->parts(); + for(MusECore::iPart ip = pl->begin(); ip != pl->end(); ++ip) if(ip->second == pt) { if(ip == pl->begin()) @@ -672,10 +674,10 @@ void DrumCanvas::cmd(int cmd) break; case CMD_SELECT_NEXT_PART: // select next part { - Part* pt = editor->curCanvasPart(); - Part* newpt = pt; - PartList* pl = editor->parts(); - for(iPart ip = pl->begin(); ip != pl->end(); ++ip) + MusECore::Part* pt = editor->curCanvasPart(); + MusECore::Part* newpt = pt; + MusECore::PartList* pl = editor->parts(); + for(MusECore::iPart ip = pl->begin(); ip != pl->end(); ++ip) if(ip->second == pt) { ++ip; @@ -697,19 +699,19 @@ void DrumCanvas::cmd(int cmd) case CMD_FIXED_LEN: //Set notes to the length specified in the drummap if (!selectionSize()) break; - song->startUndo(); - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + MusEGlobal::song->startUndo(); + for (iCItem k = items.begin(); k != items.end(); ++k) { if (k->second->isSelected()) { DEvent* devent = (DEvent*)(k->second); - Event event = devent->event(); - Event newEvent = event.clone(); + MusECore::Event event = devent->event(); + MusECore::Event newEvent = event.clone(); // newEvent.setLenTick(drumMap[event.pitch()].len); newEvent.setLenTick(ourDrumMap[y2pitch(devent->y())].len); // Indicate no undo, and do not do port controller values and clone parts. - audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false); + MusEGlobal::audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false); } } - song->endUndo(SC_EVENT_MODIFIED); + MusEGlobal::song->endUndo(SC_EVENT_MODIFIED); break; case CMD_LEFT: { @@ -721,15 +723,15 @@ void DrumCanvas::cmd(int cmd) } if(spos < 0) spos = 0; - Pos p(spos,true); - song->setPos(0, p, true, true, true); + MusECore::Pos p(spos,true); + MusEGlobal::song->setPos(0, p, true, true, true); } break; case CMD_RIGHT: { int spos = AL::sigmap.raster2(pos[0] + 1, editor->rasterStep(pos[0])); // Nudge by +1, then snap up with raster2. - Pos p(spos,true); - song->setPos(0, p, true, true, true); + MusECore::Pos p(spos,true); + MusEGlobal::song->setPos(0, p, true, true, true); } break; case CMD_LEFT_NOSNAP: @@ -738,14 +740,14 @@ void DrumCanvas::cmd(int cmd) int spos = pos[0] - editor->rasterStep(pos[0]); if (spos < 0) spos = 0; - Pos p(spos,true); - song->setPos(0, p, true, true, true); //CDW + MusECore::Pos p(spos,true); + MusEGlobal::song->setPos(0, p, true, true, true); //CDW } break; case CMD_RIGHT_NOSNAP: { - Pos p(pos[0] + editor->rasterStep(pos[0]), true); - song->setPos(0, p, true, true, true); //CDW + MusECore::Pos p(pos[0] + editor->rasterStep(pos[0]), true); + MusEGlobal::song->setPos(0, p, true, true, true); //CDW } break; } @@ -758,7 +760,7 @@ void DrumCanvas::cmd(int cmd) // startDrag //--------------------------------------------------------- -void DrumCanvas::startDrag(MusEWidget::CItem* /* item*/, bool copymode) +void DrumCanvas::startDrag(CItem* /* item*/, bool copymode) { QMimeData* md = selected_events_to_mime(partlist_to_set(editor->parts()), 1); @@ -814,8 +816,8 @@ void DrumCanvas::keyPressed(int index, int velocity) //FINDMICH later int pitch = ourDrumMap[index].anote; // play note: - MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); - audio->msgPlayMidiEvent(&e); + MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); + MusEGlobal::audio->msgPlayMidiEvent(&e); if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && curPart) steprec->record(curPart,index,ourDrumMap[index].len,editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); @@ -834,8 +836,8 @@ void DrumCanvas::keyReleased(int index, bool) //FINDMICH later int pitch = ourDrumMap[index].anote; // release note: - MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); - audio->msgPlayMidiEvent(&e); + MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); + MusEGlobal::audio->msgPlayMidiEvent(&e); } //--------------------------------------------------------- @@ -849,89 +851,92 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) if (old_style_drummap_mode) { - Undo operations; - std::vector< std::pair<Part*, Event*> > delete_events; - std::vector< std::pair<Part*, Event> > add_events; + MusECore::Undo operations; + std::vector< std::pair<MusECore::Part*, MusECore::Event*> > delete_events; + std::vector< std::pair<MusECore::Part*, MusECore::Event> > add_events; - typedef std::vector< std::pair<Part*, Event*> >::iterator idel_ev; - typedef std::vector< std::pair<Part*, Event> >::iterator iadd_ev; + typedef std::vector< std::pair<MusECore::Part*, MusECore::Event*> >::iterator idel_ev; + typedef std::vector< std::pair<MusECore::Part*, MusECore::Event> >::iterator iadd_ev; - MidiTrackList* tracks = song->midis(); - for (ciMidiTrack t = tracks->begin(); t != tracks->end(); t++) { - MidiTrack* curTrack = *t; - if (curTrack->type() != Track::DRUM) + MusECore::MidiTrackList* tracks = MusEGlobal::song->midis(); + for (MusECore::ciMidiTrack t = tracks->begin(); t != tracks->end(); t++) { + MusECore::MidiTrack* curTrack = *t; + if (curTrack->type() != MusECore::Track::DRUM) continue; - MidiPort* mp = &midiPorts[curTrack->outPort()]; - PartList* parts= curTrack->parts(); - for (iPart part = parts->begin(); part != parts->end(); ++part) { - EventList* events = part->second->events(); - Part* thePart = part->second; - for (iEvent i = events->begin(); i != events->end(); ++i) { - Event event = i->second; - if(event.type() != Controller && event.type() != Note) + MusECore::MidiPort* mp = &MusEGlobal::midiPorts[curTrack->outPort()]; + MusECore::PartList* parts= curTrack->parts(); + for (MusECore::iPart part = parts->begin(); part != parts->end(); ++part) { + MusECore::EventList* events = part->second->events(); + MusECore::Part* thePart = part->second; + for (MusECore::iEvent i = events->begin(); i != events->end(); ++i) { + MusECore::Event event = i->second; + if(event.type() != MusECore::Controller && event.type() != MusECore::Note) continue; int pitch = event.pitch(); bool drc = false; // Is it a drum controller event, according to the track port's instrument? - if(event.type() == Controller && mp->drumController(event.dataA())) + if(event.type() == MusECore::Controller && mp->drumController(event.dataA())) { drc = true; pitch = event.dataA() & 0x7f; } if (pitch == spitch) { - Event* spitch_event = &(i->second); - delete_events.push_back(std::pair<Part*, Event*>(thePart, spitch_event)); - Event newEvent = spitch_event->clone(); + MusECore::Event* spitch_event = &(i->second); + delete_events.push_back(std::pair<MusECore::Part*, MusECore::Event*>(thePart, spitch_event)); + MusECore::Event newEvent = spitch_event->clone(); if(drc) newEvent.setA((newEvent.dataA() & ~0xff) | dpitch); else newEvent.setPitch(dpitch); - add_events.push_back(std::pair<Part*, Event>(thePart, newEvent)); + add_events.push_back(std::pair<MusECore::Part*, MusECore::Event>(thePart, newEvent)); } else if (pitch == dpitch) { - Event* dpitch_event = &(i->second); - delete_events.push_back(std::pair<Part*, Event*>(thePart, dpitch_event)); - Event newEvent = dpitch_event->clone(); + MusECore::Event* dpitch_event = &(i->second); + delete_events.push_back(std::pair<MusECore::Part*, MusECore::Event*>(thePart, dpitch_event)); + MusECore::Event newEvent = dpitch_event->clone(); if(drc) newEvent.setA((newEvent.dataA() & ~0xff) | spitch); else newEvent.setPitch(spitch); - add_events.push_back(std::pair<Part*, Event>(thePart, newEvent)); + add_events.push_back(std::pair<MusECore::Part*, MusECore::Event>(thePart, newEvent)); } } } } for (idel_ev i = delete_events.begin(); i != delete_events.end(); i++) { - Part* thePart = (*i).first; - Event* theEvent = (*i).second; - operations.push_back(UndoOp(UndoOp::DeleteEvent, *theEvent, thePart, true, false)); + MusECore::Part* thePart = (*i).first; + MusECore::Event* theEvent = (*i).second; + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent, *theEvent, thePart, true, false)); } - DrumMap dm = drumMap[spitch]; - drumMap[spitch] = drumMap[dpitch]; - drumMap[dpitch] = dm; - drumInmap[int(drumMap[spitch].enote)] = spitch; - drumOutmap[int(drumMap[int(spitch)].anote)] = spitch; - drumInmap[int(drumMap[int(dpitch)].enote)] = dpitch; - drumOutmap[int(drumMap[int(dpitch)].anote)] = dpitch; + MusECore::DrumMap dm = MusEGlobal::drumMap[spitch]; + MusEGlobal::drumMap[spitch] = MusEGlobal::drumMap[dpitch]; + MusEGlobal::drumMap[dpitch] = dm; + MusEGlobal::drumInmap[int(MusEGlobal::drumMap[spitch].enote)] = spitch; + MusEGlobal::drumOutmap[int(MusEGlobal::drumMap[int(spitch)].anote)] = spitch; + MusEGlobal::drumInmap[int(MusEGlobal::drumMap[int(dpitch)].enote)] = dpitch; + MusEGlobal::drumOutmap[int(MusEGlobal::drumMap[int(dpitch)].anote)] = dpitch; for (iadd_ev i = add_events.begin(); i != add_events.end(); i++) { - Part* thePart = (*i).first; - Event& theEvent = (*i).second; - operations.push_back(UndoOp(UndoOp::AddEvent, theEvent, thePart, true, false)); + MusECore::Part* thePart = (*i).first; + MusECore::Event& theEvent = (*i).second; + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddEvent, theEvent, thePart, true, false)); } - song->applyOperationGroup(operations, false); // do not indicate undo - song->update(SC_DRUMMAP); //this update is neccessary, as it's not handled by applyOperationGroup() + MusEGlobal::song->applyOperationGroup(operations, false); // do not indicate undo + MusEGlobal::song->update(SC_DRUMMAP); //this update is neccessary, as it's not handled by applyOperationGroup() } else // if (!old_style_drummap_mode) { if (dpitch!=spitch) { - DrumMap dm_temp = ourDrumMap[spitch]; + using MusEGlobal::global_drum_ordering_t; + using MusEGlobal::global_drum_ordering; + + MusECore::DrumMap dm_temp = ourDrumMap[spitch]; instrument_number_mapping_t im_temp = instrument_map[spitch]; global_drum_ordering_t order_temp; @@ -986,9 +991,9 @@ void DrumCanvas::mapChanged(int spitch, int dpitch) } - song->update(SC_DRUMMAP); // this causes a complete rebuild of ourDrumMap - // which also handles the changed order in all - // other drum editors + MusEGlobal::song->update(SC_DRUMMAP); // this causes a complete rebuild of ourDrumMap + // which also handles the changed order in all + // other drum editors } } @@ -1008,23 +1013,23 @@ void DrumCanvas::resizeEvent(QResizeEvent* ev) // modifySelected //--------------------------------------------------------- -void DrumCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) +void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta) { - audio->msgIdle(true); - song->startUndo(); - for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { + MusEGlobal::audio->msgIdle(true); + MusEGlobal::song->startUndo(); + for (iCItem i = items.begin(); i != items.end(); ++i) { if (!(i->second->isSelected())) continue; DEvent* e = (DEvent*)(i->second); - Event event = e->event(); - if (event.type() != Note) + MusECore::Event event = e->event(); + if (event.type() != MusECore::Note) continue; - MidiPart* part = (MidiPart*)(e->part()); - Event newEvent = event.clone(); + MusECore::MidiPart* part = (MusECore::MidiPart*)(e->part()); + MusECore::Event newEvent = event.clone(); switch (type) { - case MusEWidget::NoteInfo::VAL_TIME: + case NoteInfo::VAL_TIME: { int newTime = event.tick() + delta; if (newTime < 0) @@ -1032,16 +1037,16 @@ void DrumCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) newEvent.setTick(newTime); } break; - case MusEWidget::NoteInfo::VAL_LEN: - printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_LEN not implemented\n"); + case NoteInfo::VAL_LEN: + printf("DrumCanvas::modifySelected - NoteInfo::VAL_LEN not implemented\n"); break; - case MusEWidget::NoteInfo::VAL_VELON: - printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_VELON not implemented\n"); + case NoteInfo::VAL_VELON: + printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELON not implemented\n"); break; - case MusEWidget::NoteInfo::VAL_VELOFF: - printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_VELOFF not implemented\n"); + case NoteInfo::VAL_VELOFF: + printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELOFF not implemented\n"); break; - case MusEWidget::NoteInfo::VAL_PITCH: + case NoteInfo::VAL_PITCH: if (old_style_drummap_mode) { int pitch = event.pitch() - delta; // Reversing order since the drumlist is displayed in increasing order @@ -1055,12 +1060,12 @@ void DrumCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) printf("DrumCanvas::modifySelected - MusEWidget::NoteInfo::VAL_PITCH not implemented for new style drum editors\n"); break; } - song->changeEvent(event, newEvent, part); + MusEGlobal::song->changeEvent(event, newEvent, part); // Indicate do not do port controller values and clone parts. - song->addUndo(UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false)); + MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false)); } - song->endUndo(SC_EVENT_MODIFIED); - audio->msgIdle(false); + MusEGlobal::song->endUndo(SC_EVENT_MODIFIED); + MusEGlobal::audio->msgIdle(false); } //--------------------------------------------------------- @@ -1100,7 +1105,7 @@ int DrumCanvas::getNextStep(unsigned int pos, int basicStep, int stepSize) //--------------------------------------------------------- void DrumCanvas::keyPress(QKeyEvent* event) { - if (_tool == MusEWidget::CursorTool) { + if (_tool == CursorTool) { int key = event->key(); if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier) @@ -1179,7 +1184,7 @@ void DrumCanvas::keyPress(QKeyEvent* event) //--------------------------------------------------------- void DrumCanvas::setTool2(int) { - if (_tool == MusEWidget::CursorTool) + if (_tool == CursorTool) deselectAll(); if (unsigned(cursorPos.x()) < curPart->tick()) cursorPos.setX(curPart->tick()); @@ -1205,18 +1210,18 @@ void DrumCanvas::setStep(int v) //--------------------------------------------------------- // getEventAtCursorPos //--------------------------------------------------------- -Event *DrumCanvas::getEventAtCursorPos() +MusECore::Event *DrumCanvas::getEventAtCursorPos() { - if (_tool != MusEWidget::CursorTool) + if (_tool != CursorTool) return 0; if (instrument_map[cursorPos.y()].tracks.contains(curPart->track())) { - EventList* el = curPart->events(); - iEvent lower = el->lower_bound(cursorPos.x()-curPart->tick()); - iEvent upper = el->upper_bound(cursorPos.x()-curPart->tick()); + MusECore::EventList* el = curPart->events(); + MusECore::iEvent lower = el->lower_bound(cursorPos.x()-curPart->tick()); + MusECore::iEvent upper = el->upper_bound(cursorPos.x()-curPart->tick()); int curPitch = instrument_map[cursorPos.y()].pitch; - for (iEvent i = lower; i != upper; ++i) { - Event &ev = i->second; + for (MusECore::iEvent i = lower; i != upper; ++i) { + MusECore::Event &ev = i->second; if (ev.isNote() && ev.pitch() == curPitch) return &ev; } @@ -1227,11 +1232,11 @@ Event *DrumCanvas::getEventAtCursorPos() //--------------------------------------------------------- // selectCursorEvent //--------------------------------------------------------- -void DrumCanvas::selectCursorEvent(Event *ev) +void DrumCanvas::selectCursorEvent(MusECore::Event *ev) { - for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) + for (iCItem i = items.begin(); i != items.end(); ++i) { - Event e = i->second->event(); + MusECore::Event e = i->second->event(); if (ev && ev->tick() == e.tick() && ev->pitch() == e.pitch() && e.isNote()) i->second->setSelected(true); @@ -1252,11 +1257,11 @@ void DrumCanvas::moveAwayUnused() } QSet<int> used; - for (MusEWidget::iCItem it=items.begin(); it!=items.end(); it++) + for (iCItem it=items.begin(); it!=items.end(); it++) { - const Event& ev=it->second->event(); + const MusECore::Event& ev=it->second->event(); - if (ev.type()==Note) + if (ev.type()==MusECore::Note) used.insert(ev.pitch()); } @@ -1283,15 +1288,15 @@ void DrumCanvas::midiNote(int pitch, int velo) //FINDMICH later. if (debugMsg) printf("DrumCanvas::midiNote: pitch=%i, velo=%i\n", pitch, velo); if (_midiin && _steprec && curPart - && !audio->isPlaying() && velo && pos[0] >= start_tick + && !MusEGlobal::audio->isPlaying() && velo && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record()] */ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) { - steprec->record(curPart,drumInmap[pitch],ourDrumMap[(int)drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); + steprec->record(curPart,MusEGlobal::drumInmap[pitch],ourDrumMap[(int)MusEGlobal::drumInmap[pitch]].len,editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); } } -int DrumCanvas::pitch_and_track_to_instrument(int pitch, Track* track) +int DrumCanvas::pitch_and_track_to_instrument(int pitch, MusECore::Track* track) { for (int i=0; i<instrument_map.size(); i++) if (instrument_map[i].tracks.contains(track) && instrument_map[i].pitch==pitch) @@ -1303,23 +1308,32 @@ int DrumCanvas::pitch_and_track_to_instrument(int pitch, Track* track) void DrumCanvas::propagate_drummap_change(int instr) { - const QSet<Track*>& tracks=instrument_map[instr].tracks; + const QSet<MusECore::Track*>& tracks=instrument_map[instr].tracks; int index=instrument_map[instr].pitch; - for (QSet<Track*>::const_iterator it = tracks.begin(); it != tracks.end(); it++) - dynamic_cast<MidiTrack*>(*it)->drummap()[index] = ourDrumMap[instr]; + for (QSet<MusECore::Track*>::const_iterator it = tracks.begin(); it != tracks.end(); it++) + dynamic_cast<MusECore::MidiTrack*>(*it)->drummap()[index] = ourDrumMap[instr]; } void DrumCanvas::rebuildOurDrumMap() { - using MusEUtil::drummaps_almost_equal; + using MusECore::drummaps_almost_equal; + using MusECore::Track; + using MusECore::MidiTrack; + using MusECore::TrackList; + using MusECore::ciTrack; + using MusECore::ciPart; + using MusECore::DrumMap; + using MusEGlobal::global_drum_ordering_t; + using MusEGlobal::global_drum_ordering; + if (!old_style_drummap_mode) { bool need_update = false; - TrackList* tl=song->tracks(); + TrackList* tl=MusEGlobal::song->tracks(); QList< QSet<Track*> > track_groups; QVector<instrument_number_mapping_t> old_instrument_map = instrument_map; @@ -1459,8 +1473,10 @@ void DrumCanvas::rebuildOurDrumMap() emit ourDrumMapChanged(false); if (need_update) - song->update(SC_DRUMMAP, true); // i know, this causes a recursion, which possibly - // isn't the most elegant solution here. but it will - // never be an infinite recursion + MusEGlobal::song->update(SC_DRUMMAP, true); // i know, this causes a recursion, which possibly + // isn't the most elegant solution here. but it will + // never be an infinite recursion } } + +} // namespace MusEGui diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index 8ecbdac9..581de9d7 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -40,6 +40,8 @@ class QDragMoveEvent; class QDragLeaveEvent; class DrumMap; +namespace MusEGui { + class MidiEditor; class DrumEdit; @@ -48,18 +50,15 @@ class DrumEdit; // ''visual'' Drum Event //--------------------------------------------------------- -class DEvent : public MusEWidget::CItem { +class DEvent : public CItem { public: - DEvent(Event e, Part* p, int instr); + DEvent(MusECore::Event e, MusECore::Part* p, int instr); }; -class ScrollScale; -class PianoRoll; - -struct instrument_number_mapping_t +struct instrument_number_mapping_t //FINDMICH TODO move into a suitable namespace! { - QSet<Track*> tracks; + QSet<MusECore::Track*> tracks; int pitch; instrument_number_mapping_t() @@ -68,7 +67,7 @@ struct instrument_number_mapping_t tracks.clear(); } - instrument_number_mapping_t(const QSet<Track*>& tr, int p) + instrument_number_mapping_t(const QSet<MusECore::Track*>& tr, int p) { tracks=tr; pitch=p; @@ -83,7 +82,6 @@ struct instrument_number_mapping_t { return !operator==(that); } - }; //--------------------------------------------------------- @@ -94,13 +92,13 @@ class DrumCanvas : public EventCanvas { Q_OBJECT bool old_style_drummap_mode; - DrumMap* ourDrumMap; + MusECore::DrumMap* ourDrumMap; bool must_delete_our_drum_map; //FINDMICH really delete it! QVector<instrument_number_mapping_t> instrument_map; DrumEdit* drumEditor; - StepRec* steprec; + MusECore::StepRec* steprec; // Cursor tool position QPoint cursorPos; @@ -108,25 +106,25 @@ class DrumCanvas : public EventCanvas { virtual void drawCanvas(QPainter&, const QRect&); - virtual void drawItem(QPainter&, const MusEWidget::CItem*, const QRect&); + virtual void drawItem(QPainter&, const CItem*, const QRect&); void drawTopItem(QPainter& p, const QRect& rect); - virtual void drawMoving(QPainter&, const MusEWidget::CItem*, const QRect&); - virtual Undo moveCanvasItems(MusEWidget::CItemList&, int, int, DragType); - virtual UndoOp moveItem(MusEWidget::CItem*, const QPoint&, DragType); - virtual MusEWidget::CItem* newItem(const QPoint&, int); - virtual void resizeItem(MusEWidget::CItem*, bool, bool); - virtual void newItem(MusEWidget::CItem*, bool); - virtual void newItem(MusEWidget::CItem*, bool, bool replace ); - virtual bool deleteItem(MusEWidget::CItem*); - MusEWidget::CItem* newItem(int tick, int instrument, int velocity); + virtual void drawMoving(QPainter&, const CItem*, const QRect&); + virtual MusECore::Undo moveCanvasItems(CItemList&, int, int, DragType); + virtual MusECore::UndoOp moveItem(CItem*, const QPoint&, DragType); + virtual CItem* newItem(const QPoint&, int); + virtual void resizeItem(CItem*, bool, bool); + virtual void newItem(CItem*, bool); + virtual void newItem(CItem*, bool, bool replace ); + virtual bool deleteItem(CItem*); + CItem* newItem(int tick, int instrument, int velocity); int y2pitch(int y) const; int pitch2y(int pitch) const; - void startDrag(MusEWidget::CItem*, bool copymode); + void startDrag(CItem*, bool copymode); void dragEnterEvent(QDragEnterEvent* event); void dragMoveEvent(QDragMoveEvent*); void dragLeaveEvent(QDragLeaveEvent*); - virtual void addItem(Part*, Event&); + virtual void addItem(MusECore::Part*, MusECore::Event&); virtual void resizeEvent(QResizeEvent*); virtual void curPartChanged(); int getNextStep(unsigned int pos, int basicStep, int stepSize=1); @@ -160,16 +158,19 @@ class DrumCanvas : public EventCanvas { const char* name = 0); virtual ~DrumCanvas(); void cmd(int); - virtual void modifySelected(MusEWidget::NoteInfo::ValType type, int delta); + virtual void modifySelected(NoteInfo::ValType type, int delta); virtual void keyPress(QKeyEvent* event); - Event *getEventAtCursorPos(); - void selectCursorEvent(Event *ev); - int pitch_and_track_to_instrument(int pitch, Track* track); - DrumMap* getOurDrumMap() { return ourDrumMap; } //FINDMICH UGLY + MusECore::Event *getEventAtCursorPos(); + void selectCursorEvent(MusECore::Event *ev); + int pitch_and_track_to_instrument(int pitch, MusECore::Track* track); + MusECore::DrumMap* getOurDrumMap() { return ourDrumMap; } //FINDMICH UGLY int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY QVector<instrument_number_mapping_t>& get_instrument_map() { return instrument_map; } //FINDMICH UGLY void propagate_drummap_change(int instrument); //FINDMICH move to drumedit void rebuildOurDrumMap(); }; + +} // namespace MusEGui + #endif diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index c5379a15..1ffae02e 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -40,6 +40,8 @@ #include "song.h" #include "dcanvas.h" +namespace MusEGui { + //--------------------------------------------------------- // draw //--------------------------------------------------------- @@ -63,7 +65,7 @@ void DList::draw(QPainter& p, const QRect& rect) continue; if (yy > y + h) break; - DrumMap* dm = &ourDrumMap[instrument]; + MusECore::DrumMap* dm = &ourDrumMap[instrument]; if (dm == currentlySelected) p.fillRect(x, yy, w, TH, Qt::yellow); // else @@ -96,10 +98,10 @@ void DList::draw(QPainter& p, const QRect& rect) s.setNum(dm->len); break; case COL_NOTE: - s = MusEUtil::pitch2string(dm->anote); + s = MusECore::pitch2string(dm->anote); break; case COL_INPUTTRIGGER: - s = MusEUtil::pitch2string(dm->enote); + s = MusECore::pitch2string(dm->enote); break; case COL_LEVEL1: s.setNum(dm->lv1); @@ -117,11 +119,11 @@ void DList::draw(QPainter& p, const QRect& rect) { bool hidden=false; bool shown=false; - QSet<Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; + QSet<MusECore::Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; int pitch = dcanvas->get_instrument_map()[instrument].pitch; - for (QSet<Track*>::iterator track=group->begin(); track!=group->end() && !(hidden&&shown); track++) - if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch]) + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end() && !(hidden&&shown); track++) + if (dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch]) hidden=true; else shown=true; @@ -171,7 +173,7 @@ void DList::draw(QPainter& p, const QRect& rect) s.setNum(dm->channel+1); break; case COL_OUTPORT: - s.sprintf("%d:%s", dm->port+1, midiPorts[dm->port].portname().toLatin1().constData()); + s.sprintf("%d:%s", dm->port+1, MusEGlobal::midiPorts[dm->port].portname().toLatin1().constData()); align = Qt::AlignVCenter | Qt::AlignLeft; break; } @@ -220,7 +222,7 @@ void DList::draw(QPainter& p, const QRect& rect) // devicesPopupMenu //--------------------------------------------------------- -void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) +void DList::devicesPopupMenu(MusECore::DrumMap* t, int x, int y, bool changeAll) { if (!old_style_drummap_mode) { @@ -228,7 +230,7 @@ void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) return; } - QMenu* p = midiPortsPopup(); + QMenu* p = MusECore::midiPortsPopup(); QAction* act = p->exec(mapToGlobal(QPoint(x, y)), 0); bool doemit = false; if (act) { @@ -237,24 +239,24 @@ void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) { if(n != t->port) { - audio->msgIdle(true); - song->remapPortDrumCtrlEvents(getSelectedInstrument(), -1, -1, n); - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(true); + MusEGlobal::song->remapPortDrumCtrlEvents(getSelectedInstrument(), -1, -1, n); + MusEGlobal::audio->msgIdle(false); t->port = n; doemit = true; } } else { - audio->msgIdle(true); + MusEGlobal::audio->msgIdle(true); // Delete all port controller events. - song->changeAllPortDrumCtrlEvents(false); + MusEGlobal::song->changeAllPortDrumCtrlEvents(false); for (int i = 0; i < ourDrumMapSize; i++) ourDrumMap[i].port = n; // Add all port controller events. - song->changeAllPortDrumCtrlEvents(true); + MusEGlobal::song->changeAllPortDrumCtrlEvents(true); - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(false); doemit = true; } } @@ -264,7 +266,7 @@ void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll) int instr = getSelectedInstrument(); if(instr != -1) //emit curDrumInstrumentChanged(instr); - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); } } @@ -278,8 +280,8 @@ void DList::viewMousePressEvent(QMouseEvent* ev) int y = ev->y(); int button = ev->button(); unsigned instrument = y / TH; - DrumMap* dm = &ourDrumMap[instrument]; - DrumMap dm_old = *dm; + MusECore::DrumMap* dm = &ourDrumMap[instrument]; + MusECore::DrumMap dm_old = *dm; setCurDrumInstrument(instrument); @@ -313,18 +315,18 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if (button == Qt::LeftButton) { bool hidden=true; - QSet<Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; + QSet<MusECore::Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; int pitch = dcanvas->get_instrument_map()[instrument].pitch; - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] == false) + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end(); track++) + if (dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch] == false) { hidden=false; break; } - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] = !hidden; + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch] = !hidden; } break; case COL_MUTE: @@ -362,13 +364,13 @@ void DList::viewMousePressEvent(QMouseEvent* ev) //If so, switch the inmap between the instruments for (int i=0; i<ourDrumMapSize; i++) { if (ourDrumMap[i].enote == val && &ourDrumMap[i] != dm) { - drumInmap[int(dm->enote)] = i; + MusEGlobal::drumInmap[int(dm->enote)] = i; ourDrumMap[i].enote = dm->enote; break; } } //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val - drumInmap[val] = instrument; + MusEGlobal::drumInmap[val] = instrument; } dm->enote = val; break; @@ -388,11 +390,11 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 127; if(val != dm->anote) { - audio->msgIdle(true); - song->remapPortDrumCtrlEvents(instrument, val, -1, -1); - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(true); + MusEGlobal::song->remapPortDrumCtrlEvents(instrument, val, -1, -1); + MusEGlobal::audio->msgIdle(false); dm->anote = val; - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); } } @@ -409,26 +411,26 @@ void DList::viewMousePressEvent(QMouseEvent* ev) val = 127; if (ev->modifiers() & Qt::ControlModifier) { - audio->msgIdle(true); + MusEGlobal::audio->msgIdle(true); // Delete all port controller events. - song->changeAllPortDrumCtrlEvents(false, true); + MusEGlobal::song->changeAllPortDrumCtrlEvents(false, true); for (int i = 0; i < ourDrumMapSize; i++) ourDrumMap[i].channel = val; // Add all port controller events. - song->changeAllPortDrumCtrlEvents(true, true); - audio->msgIdle(false); - song->update(SC_DRUMMAP); + MusEGlobal::song->changeAllPortDrumCtrlEvents(true, true); + MusEGlobal::audio->msgIdle(false); + MusEGlobal::song->update(SC_DRUMMAP); } else { if(val != dm->channel) { - audio->msgIdle(true); - song->remapPortDrumCtrlEvents(instrument, -1, val, -1); - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(true); + MusEGlobal::song->remapPortDrumCtrlEvents(instrument, -1, val, -1); + MusEGlobal::audio->msgIdle(false); dm->channel = val; - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); } } break; @@ -469,20 +471,20 @@ void DList::viewMousePressEvent(QMouseEvent* ev) emit keyPressed(instrument, 100); //Mapping done on other side, send index else if (button == Qt::MidButton) // hide that instrument { - QSet<Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; + QSet<MusECore::Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; int pitch = dcanvas->get_instrument_map()[instrument].pitch; - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] = true; + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch] = true; } else if (button == Qt::RightButton) { bool hidden=false; bool shown=false; - QSet<Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; + QSet<MusECore::Track*>* group = &dcanvas->get_instrument_map()[instrument].tracks; int pitch = dcanvas->get_instrument_map()[instrument].pitch; - for (QSet<Track*>::iterator track=group->begin(); track!=group->end() && !(hidden&&shown); track++) - if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch]) + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end() && !(hidden&&shown); track++) + if (dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch]) hidden=true; else shown=true; @@ -499,11 +501,11 @@ void DList::viewMousePressEvent(QMouseEvent* ev) QAction* result = popup->exec(ev->globalPos()); if (result==hideAction) - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] = true; + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch] = true; else if (result==showAction) - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] = false; + for (QSet<MusECore::Track*>::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast<MusECore::MidiTrack*>(*track)->drummap_hidden()[pitch] = false; delete popup; } @@ -516,7 +518,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev) if (!old_style_drummap_mode && dm_old != *dm) //something changed and we're in new style mode? dcanvas->propagate_drummap_change(dm-ourDrumMap); - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); //redraw(); //this is done by the songChanged slot } @@ -551,7 +553,7 @@ void DList::viewMouseDoubleClickEvent(QMouseEvent* ev) //--------------------------------------------------------- void DList::lineEdit(int line, int section) { - DrumMap* dm = &ourDrumMap[line]; + MusECore::DrumMap* dm = &ourDrumMap[line]; editEntry = dm; if (editor == 0) { editor = new DLineEdit(this); @@ -619,7 +621,7 @@ void DList::lineEdit(int line, int section) //--------------------------------------------------------- void DList::pitchEdit(int line, int section) { - DrumMap* dm = &ourDrumMap[line]; + MusECore::DrumMap* dm = &ourDrumMap[line]; editEntry = dm; if (pitch_editor == 0) { pitch_editor = new DPitchEdit(this); @@ -675,11 +677,11 @@ void DList::setCurDrumInstrument(int instr) { if (instr < 0 || instr >= ourDrumMapSize -1) return; // illegal instrument - DrumMap* dm = &ourDrumMap[instr]; + MusECore::DrumMap* dm = &ourDrumMap[instr]; if (currentlySelected != dm) { currentlySelected = dm; emit curDrumInstrumentChanged(instr); - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); } } @@ -740,7 +742,7 @@ void DList::returnPressed() } } - DrumMap editEntryOld = *editEntry; + MusECore::DrumMap editEntryOld = *editEntry; switch(selectedColumn) { case COL_NAME: editEntry->name = editor->text(); @@ -790,7 +792,7 @@ void DList::returnPressed() editor->hide(); editEntry = 0; setFocus(); - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); //redraw(); //this is done by the songChanged slot } @@ -809,18 +811,18 @@ void DList::pitchEdited() int val=pitch_editor->value(); int instrument=(editEntry-ourDrumMap); - DrumMap editEntryOld=*editEntry; + MusECore::DrumMap editEntryOld=*editEntry; switch(selectedColumn) { case COL_NOTE: if (old_style_drummap_mode) //should actually be always true, but to be sure... { if(val != editEntry->anote) { - audio->msgIdle(true); - song->remapPortDrumCtrlEvents(instrument, val, -1, -1); - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(true); + MusEGlobal::song->remapPortDrumCtrlEvents(instrument, val, -1, -1); + MusEGlobal::audio->msgIdle(false); editEntry->anote = val; - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); } } else @@ -830,20 +832,21 @@ void DList::pitchEdited() case COL_INPUTTRIGGER: if (old_style_drummap_mode) { - //Check if there is any other drumMap with the same inmap value (there should be one (and only one):-) + //Check if there is any other MusEGlobal::drumMap with the same inmap value (there should be one (and only one):-) //If so, switch the inmap between the instruments for (int i=0; i<ourDrumMapSize; i++) { if (ourDrumMap[i].enote == val && &ourDrumMap[i] != editEntry) { - drumInmap[int(editEntry->enote)] = i; + MusEGlobal::drumInmap[int(editEntry->enote)] = i; ourDrumMap[i].enote = editEntry->enote; break; } } //TODO: Set all the notes on the track with instrument=dm->enote to instrument=val - drumInmap[val] = instrument; + MusEGlobal::drumInmap[val] = instrument; } editEntry->enote = val; break; + default: printf("ERROR: THIS SHOULD NEVER HAPPEN: Value changed in unknown column\n"); break; @@ -856,7 +859,7 @@ void DList::pitchEdited() pitch_editor->hide(); editEntry = 0; setFocus(); - song->update(SC_DRUMMAP); + MusEGlobal::song->update(SC_DRUMMAP); //redraw(); //this is done by the songChanged slot } @@ -893,7 +896,7 @@ void DList::songChanged(int flags) //--------------------------------------------------------- DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bool oldstyle) - : MusEWidget::View(parent, 1, ymag) + : MusEGui::View(parent, 1, ymag) { setBg(Qt::white); @@ -1009,7 +1012,7 @@ int DList::getSelectedInstrument() { if (currentlySelected == 0) return -1; - return drumInmap[int(currentlySelected->enote)]; + return MusEGlobal::drumInmap[int(currentlySelected->enote)]; } @@ -1028,3 +1031,5 @@ void DList::ourDrumMapChanged(bool instrMapChanged) redraw(); } + +} // namespace MusEGui diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h index cc3f3edc..35a67023 100644 --- a/muse2/muse/midiedit/dlist.h +++ b/muse2/muse/midiedit/dlist.h @@ -32,12 +32,19 @@ #define TH 18 // normal Track-hight class QHeaderView; +class QLineEdit; class QMouseEvent; class QPainter; - class Device; class QLineEdit; + +namespace MusECore { class DrumMap; +} + +namespace MusEGui { + +class ScrollScale; class DrumCanvas; //--------------------------------------------------------- @@ -83,19 +90,19 @@ class DPitchEdit: public Awl::PitchEdit // DList //--------------------------------------------------------- -class DList : public MusEWidget::View { +class DList : public View { Q_OBJECT - DrumCanvas* dcanvas; - DrumMap* ourDrumMap; + MusEGui::DrumCanvas* dcanvas; + MusECore::DrumMap* ourDrumMap; int ourDrumMapSize; bool old_style_drummap_mode; QHeaderView* header; QLineEdit* editor; DPitchEdit* pitch_editor; - DrumMap* editEntry; - DrumMap* currentlySelected; + MusECore::DrumMap* editEntry; + MusECore::DrumMap* currentlySelected; int selectedColumn; @@ -111,7 +118,7 @@ class DList : public MusEWidget::View { virtual void viewMouseMoveEvent(QMouseEvent*); int x2col(int x) const; - void devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll); + void devicesPopupMenu(MusECore::DrumMap* t, int x, int y, bool changeAll); //void setCurDrumInstrument(int n); @@ -137,11 +144,13 @@ class DList : public MusEWidget::View { void lineEdit(int line, int section); void pitchEdit(int line, int section); void setCurDrumInstrument(int n); - DList(QHeaderView*, QWidget* parent, int ymag, DrumCanvas* dcanvas, bool oldstyle); + DList(QHeaderView*, QWidget* parent, int ymag, MusEGui::DrumCanvas* dcanvas, bool oldstyle); ~DList(); int getSelectedInstrument(); }; +} // namespace MusEGui + #endif // __DLIST_H_ diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index c98d0632..3a75e32d 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -62,6 +62,8 @@ #include "helper.h" #include "widgets/function_dialogs/quantize.h" +namespace MusEGui { + /* static const char* map_file_pattern[] = { "Presets (*.map *.map.gz *.map.bz2)", @@ -84,7 +86,7 @@ bool DrumEdit::_ignore_hide_init = false; static const int xscale = -10; static const int yscale = 1; -static const int drumeditTools = MusEWidget::PointerTool | MusEWidget::PencilTool | MusEWidget::RubberTool | MusEWidget::CursorTool | MusEWidget::DrawTool; +static const int drumeditTools = MusEGui::PointerTool | MusEGui::PencilTool | MusEGui::RubberTool | MusEGui::CursorTool | MusEGui::DrawTool; //--------------------------------------------------------- @@ -155,7 +157,7 @@ void DrumEdit::closeEvent(QCloseEvent* e) // DrumEdit //--------------------------------------------------------- -DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned initPos) +DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, unsigned initPos) : MidiEditor(TopWin::DRUM, _rasterInit, pl, parent, name) { setFocusPolicy(Qt::StrongFocus); @@ -278,7 +280,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini QMenu* menuScriptPlugins = menuBar()->addMenu(tr("&Plugins")); - song->populateScriptMenu(menuScriptPlugins, this); + MusEGlobal::song->populateScriptMenu(menuScriptPlugins, this); QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config")); if (!old_style_drummap_mode()) @@ -357,7 +359,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini tools->addWidget(midiin); - tools2 = new MusEWidget::EditToolBar(this, drumeditTools); + tools2 = new MusEGui::EditToolBar(this, drumeditTools); addToolBar(tools2); QToolBar* cursorToolbar = addToolBar(tr("cursor tools")); @@ -389,24 +391,24 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini addToolBarBreak(); // don't show pitch value in toolbar - toolbar = new MusEWidget::Toolbar1(this, _rasterInit, false); + toolbar = new MusEGui::Toolbar1(this, _rasterInit, false); addToolBar(toolbar); addToolBarBreak(); - info = new MusEWidget::NoteInfo(this); + info = new MusEGui::NoteInfo(this); addToolBar(info); //--------------------------------------------------- // split //--------------------------------------------------- - split1 = new MusEWidget::Splitter(Qt::Vertical, mainw, "split1"); + split1 = new MusEGui::Splitter(Qt::Vertical, mainw, "split1"); QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw); ctrl->setObjectName("Ctrl"); - ctrl->setFont(MusEConfig::config.fonts[3]); - //hscroll = new MusEWidget::ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw); + ctrl->setFont(MusEGlobal::config.fonts[3]); + //hscroll = new MusEGui::ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw); // Increased scale to -1. To resolve/select/edit 1-tick-wide (controller graph) events. p4.0.18 Tim. - hscroll = new MusEWidget::ScrollScale(-25, -1, xscale, 20000, Qt::Horizontal, mainw); + hscroll = new MusEGui::ScrollScale(-25, -1, xscale, 20000, Qt::Horizontal, mainw); ctrl->setFixedSize(40, hscroll->sizeHint().height()); ctrl->setToolTip(tr("Add Controller View")); @@ -423,7 +425,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini // mainGrid->addRowSpacing(1, hscroll->sizeHint().height()); // mainGrid->addItem(new QSpacerItem(0, hscroll->sizeHint().height()), 1, 0); - split2 = new MusEWidget::Splitter(Qt::Horizontal, split1, "split2"); + split2 = new MusEGui::Splitter(Qt::Horizontal, split1, "split2"); split1w1 = new QWidget(split2); QWidget* split1w2 = new QWidget(split2); QGridLayout* gridS1 = new QGridLayout(split1w1); @@ -432,10 +434,10 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini gridS1->setSpacing(0); gridS2->setContentsMargins(0, 0, 0, 0); gridS2->setSpacing(0); - time = new MusEWidget::MTScale(&_raster, split1w2, xscale); + time = new MusEGui::MTScale(&_raster, split1w2, xscale); canvas = new DrumCanvas(this, split1w2, xscale, yscale); - vscroll = new MusEWidget::ScrollScale(-4, 1, yscale, dynamic_cast<DrumCanvas*>(canvas)->getOurDrumMapSize()*TH, Qt::Vertical, split1w2); - int offset = -(MusEConfig::config.division/4); + vscroll = new MusEGui::ScrollScale(-4, 1, yscale, dynamic_cast<DrumCanvas*>(canvas)->getOurDrumMapSize()*TH, Qt::Vertical, split1w2); + int offset = -(MusEGlobal::config.division/4); canvas->setOrigin(offset, 0); canvas->setCanvasTools(drumeditTools); canvas->setFocus(); @@ -457,14 +459,14 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini gridS2->setColumnStretch(0, 100); gridS2->addWidget(time, 0, 0, 1, 2); - gridS2->addWidget(MusEUtil::hLine(split1w2), 1, 0, 1, 2); + gridS2->addWidget(MusECore::hLine(split1w2), 1, 0, 1, 2); gridS2->addWidget(canvas, 2, 0); gridS2->addWidget(vscroll, 2, 1); // // Reihenfolge in dlist.c festgeschrieben ("Dcols") // - header = new MusEWidget::Header(split1w1, "header"); + header = new MusEGui::Header(split1w1, "header"); header->setFixedHeight(31); header->setColumnLabel(tr("H"), COL_HIDE, 20); header->setColumnLabel(tr("M"), COL_MUTE, 20); @@ -512,8 +514,8 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini 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(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int))); - connect(song, SIGNAL(songChanged(int)), dlist, SLOT(songChanged(int))); + connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged1(int))); + connect(MusEGlobal::song, SIGNAL(songChanged(int)), dlist, SLOT(songChanged(int))); connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int))); connect(vscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setYMag(int))); connect(vscroll, SIGNAL(scaleChanged(int)), dlist, SLOT(setYMag(int))); @@ -529,8 +531,8 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini 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, Event&, Part*)), this, - SLOT(setSelection(int, Event&, Part*))); + connect(canvas, SIGNAL(selectionChanged(int, MusECore::Event&, MusECore::Part*)), this, + SLOT(setSelection(int, MusECore::Event&, MusECore::Part*))); connect(canvas, SIGNAL(followEvent(int)), SLOT(follow(int))); connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange())); @@ -543,7 +545,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned))); connect(toolbar, SIGNAL(rasterChanged(int)), SLOT(setRaster(int))); connect(toolbar, SIGNAL(soloChanged(bool)), SLOT(soloChanged(bool))); - connect(info, SIGNAL(valueChanged(MusEWidget::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEWidget::NoteInfo::ValType, int))); + connect(info, SIGNAL(valueChanged(MusEGui::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEGui::NoteInfo::ValType, int))); connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl())); @@ -554,14 +556,14 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini selectionChanged(); // enable/disable "Copy" & "Paste" initShortcuts(); - const Pos cpos=song->cPos(); + const MusECore::Pos cpos=MusEGlobal::song->cPos(); canvas->setPos(0, cpos.tick(), true); canvas->selectAtTick(cpos.tick()); //canvas->selectFirst(); unsigned pos=0; if(initPos >= MAXINT) - pos = song->cpos(); + pos = MusEGlobal::song->cpos(); if(pos > MAXINT) pos = MAXINT; if (pos) @@ -652,10 +654,10 @@ DrumEdit::~DrumEdit() // update Info Line //--------------------------------------------------------- -void DrumEdit::setSelection(int tick, Event& e, Part* p) +void DrumEdit::setSelection(int tick, MusECore::Event& e, MusECore::Part* p) { selEvent = e; - selPart = (MidiPart*)p; + selPart = (MusECore::MidiPart*)p; selTick = tick; info->setEnabled(!e.empty()); if (!e.empty()) { @@ -674,8 +676,8 @@ void DrumEdit::setSelection(int tick, Event& e, Part* p) void DrumEdit::soloChanged(bool flag) { - audio->msgSetSolo(canvas->track(), flag); - song->update(SC_SOLO); + MusEGlobal::audio->msgSetSolo(canvas->track(), flag); + MusEGlobal::song->update(SC_SOLO); } //--------------------------------------------------------- @@ -693,40 +695,40 @@ void DrumEdit::setRaster(int val) // edit currently selected Event //--------------------------------------------------------- -void DrumEdit::noteinfoChanged(MusEWidget::NoteInfo::ValType type, int val) +void DrumEdit::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val) { if (selEvent.empty()) { printf("noteinfoChanged while note is zero %d\n", type); return; } - Event event = selEvent.clone(); + MusECore::Event event = selEvent.clone(); switch (type) { - case MusEWidget::NoteInfo::VAL_TIME: + case MusEGui::NoteInfo::VAL_TIME: event.setTick(val - selPart->tick()); break; - case MusEWidget::NoteInfo::VAL_LEN: + case MusEGui::NoteInfo::VAL_LEN: event.setLenTick(val); break; - case MusEWidget::NoteInfo::VAL_VELON: + case MusEGui::NoteInfo::VAL_VELON: event.setVelo(val); break; - case MusEWidget::NoteInfo::VAL_VELOFF: + case MusEGui::NoteInfo::VAL_VELOFF: event.setVeloOff(val); break; - case MusEWidget::NoteInfo::VAL_PITCH: + case MusEGui::NoteInfo::VAL_PITCH: event.setPitch(val); break; } // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(selEvent, event, selPart); - audio->msgChangeEvent(selEvent, event, selPart, true, false, false); + //MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart); + MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart, true, false, false); } //--------------------------------------------------------- // writeStatus //--------------------------------------------------------- -void DrumEdit::writeStatus(int level, Xml& xml) const +void DrumEdit::writeStatus(int level, MusECore::Xml& xml) const { writePartList(level, xml); xml.tag(level++, "drumedit"); @@ -755,16 +757,16 @@ void DrumEdit::writeStatus(int level, Xml& xml) const // readStatus //--------------------------------------------------------- -void DrumEdit::readStatus(Xml& xml) +void DrumEdit::readStatus(MusECore::Xml& xml) { for (;;) { - Xml::Token token = xml.parse(); + MusECore::Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { - case Xml::Error: - case Xml::End: + case MusECore::Xml::Error: + case MusECore::Xml::End: return; - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "steprec") { int val = xml.parseInt(); canvas->setSteprec(val); @@ -800,7 +802,7 @@ void DrumEdit::readStatus(Xml& xml) else xml.unknown("DrumEdit"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "drumedit") { _rasterInit = _raster; toolbar->setRaster(_raster); @@ -817,16 +819,16 @@ void DrumEdit::readStatus(Xml& xml) // readConfiguration //--------------------------------------------------------- -void DrumEdit::readConfiguration(Xml& xml) +void DrumEdit::readConfiguration(MusECore::Xml& xml) { for (;;) { - Xml::Token token = xml.parse(); + MusECore::Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { - case Xml::Error: - case Xml::End: + case MusECore::Xml::Error: + case MusECore::Xml::End: return; - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "raster") _rasterInit = xml.parseInt(); else if (tag == "dcanvaswidth") @@ -840,7 +842,7 @@ void DrumEdit::readConfiguration(Xml& xml) else xml.unknown("DrumEdit"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "drumedit") { return; } @@ -854,7 +856,7 @@ void DrumEdit::readConfiguration(Xml& xml) // writeConfiguration //--------------------------------------------------------- -void DrumEdit::writeConfiguration(int level, Xml& xml) +void DrumEdit::writeConfiguration(int level, MusECore::Xml& xml) { xml.tag(level++, "drumedit"); xml.intTag(level, "raster", _rasterInit); @@ -871,26 +873,26 @@ void DrumEdit::writeConfiguration(int level, Xml& xml) void DrumEdit::load() { - //QString fn = MusEWidget::getOpenFileName("drummaps", map_file_pattern, - QString fn = MusEWidget::getOpenFileName("drummaps", MusEGlobal::drum_map_file_pattern, + //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()) return; bool popenFlag; - FILE* f = MusEWidget::fileOpen(this, fn, QString(".map"), "r", popenFlag, true); + FILE* f = MusEGui::fileOpen(this, fn, QString(".map"), "r", popenFlag, true); if (f == 0) return; - Xml xml(f); + MusECore::Xml xml(f); int mode = 0; for (;;) { - Xml::Token token = xml.parse(); + MusECore::Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { - case Xml::Error: - case Xml::End: + case MusECore::Xml::Error: + case MusECore::Xml::End: return; - case Xml::TagStart: + case MusECore::Xml::TagStart: if (mode == 0 && tag == "muse") mode = 1; else if (mode == 1 && tag == "drummap") { @@ -900,9 +902,9 @@ void DrumEdit::load() else xml.unknown("DrumEdit"); break; - case Xml::Attribut: + case MusECore::Xml::Attribut: break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (!mode && tag == "muse") goto ende; default: @@ -924,16 +926,16 @@ ende: void DrumEdit::save() { - //QString fn = MusEWidget::getSaveFileName(QString("drummaps"), map_file_pattern, - QString fn = MusEWidget::getSaveFileName(QString("drummaps"), MusEGlobal::drum_map_file_save_pattern, + //QString fn = MusEGui::getSaveFileName(QString("drummaps"), map_file_pattern, + QString fn = MusEGui::getSaveFileName(QString("drummaps"), MusEGlobal::drum_map_file_save_pattern, this, tr("MusE: Store Drum Map")); if (fn.isEmpty()) return; bool popenFlag; - FILE* f = MusEWidget::fileOpen(this, fn, QString(".map"), "w", popenFlag, false, true); + FILE* f = MusEGui::fileOpen(this, fn, QString(".map"), "w", popenFlag, false, true); if (f == 0) return; - Xml xml(f); + MusECore::Xml xml(f); xml.header(); xml.tag(0, "muse version=\"1.0\""); writeDrumMap(1, xml, true); @@ -955,7 +957,7 @@ void DrumEdit::reset() tr("Reset the drum map with GM defaults?"), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) == QMessageBox::Ok) { - resetGMDrumMap(); + MusECore::resetGMDrumMap(); dlist->redraw(); canvas->redraw(); } @@ -974,14 +976,14 @@ void DrumEdit::cmd(int cmd) erase_notes(partlist_to_set(parts()), 1); break; case DrumCanvas::CMD_COPY: copy_notes(partlist_to_set(parts()), 1); break; - case DrumCanvas::CMD_COPY_RANGE: copy_notes(partlist_to_set(parts()), MusEUtil::any_event_selected(partlist_to_set(parts())) ? 3 : 2); break; + case DrumCanvas::CMD_COPY_RANGE: copy_notes(partlist_to_set(parts()), MusECore::any_event_selected(partlist_to_set(parts())) ? 3 : 2); break; case DrumCanvas::CMD_PASTE: ((DrumCanvas*)canvas)->cmd(DrumCanvas::CMD_SELECT_NONE); - paste_notes(3072); + MusECore::paste_notes(3072); break; case DrumCanvas::CMD_PASTE_DIALOG: ((DrumCanvas*)canvas)->cmd(DrumCanvas::CMD_SELECT_NONE); - paste_notes((canvas->part())); + MusECore::paste_notes((canvas->part())); break; case DrumCanvas::CMD_LOAD: load(); break; case DrumCanvas::CMD_SAVE: save(); break; @@ -991,7 +993,7 @@ void DrumEdit::cmd(int cmd) case DrumCanvas::CMD_QUANTIZE: if (quantize_dialog->exec()) quantize_notes(partlist_to_set(parts()), quantize_dialog->range, - (MusEConfig::config.division*4)/(1<<quantize_dialog->raster_power2), + (MusEGlobal::config.division*4)/(1<<quantize_dialog->raster_power2), /* quant_len= */false, quantize_dialog->strength, quantize_dialog->swing, quantize_dialog->threshold); break; @@ -1216,28 +1218,28 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) } else if (key == shortcuts[SHRT_TOOL_POINTER].key) { - tools2->set(MusEWidget::PointerTool); + tools2->set(MusEGui::PointerTool); return; } else if (key == shortcuts[SHRT_TOOL_PENCIL].key) { - tools2->set(MusEWidget::PencilTool); + tools2->set(MusEGui::PencilTool); return; } else if (key == shortcuts[SHRT_TOOL_RUBBER].key) { - tools2->set(MusEWidget::RubberTool); + tools2->set(MusEGui::RubberTool); return; } else if (key == shortcuts[SHRT_TOOL_CURSOR].key) { - tools2->set(MusEWidget::CursorTool); + tools2->set(MusEGui::CursorTool); return; } else if (key == shortcuts[SHRT_ZOOM_IN].key) { int mag = hscroll->mag(); - int zoomlvl = MusEWidget::ScrollScale::getQuickZoomLevel(mag); + int zoomlvl = MusEGui::ScrollScale::getQuickZoomLevel(mag); if (zoomlvl < 23) zoomlvl++; - int newmag = MusEWidget::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + int newmag = MusEGui::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); hscroll->setMag(newmag); //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag); @@ -1245,24 +1247,24 @@ void DrumEdit::keyPressEvent(QKeyEvent* event) } else if (key == shortcuts[SHRT_ZOOM_OUT].key) { int mag = hscroll->mag(); - int zoomlvl = MusEWidget::ScrollScale::getQuickZoomLevel(mag); + int zoomlvl = MusEGui::ScrollScale::getQuickZoomLevel(mag); if (zoomlvl > 1) zoomlvl--; - int newmag = MusEWidget::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + int newmag = MusEGui::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); hscroll->setMag(newmag); //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag); return; } else if (key == shortcuts[SHRT_SCROLL_LEFT].key) { - int pos = hscroll->pos() - MusEConfig::config.division; + int pos = hscroll->pos() - MusEGlobal::config.division; if (pos < 0) pos = 0; hscroll->setPos(pos); return; } else if (key == shortcuts[SHRT_SCROLL_RIGHT].key) { - int pos = hscroll->pos() + MusEConfig::config.division; + int pos = hscroll->pos() + MusEGlobal::config.division; hscroll->setPos(pos); return; } @@ -1358,8 +1360,8 @@ void DrumEdit::initShortcuts() void DrumEdit::execDeliveredScript(int id) { //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id]; - QString scriptfile = song->getScriptPath(id, true); - song->executeScript(scriptfile.toLatin1().constData(), parts(), raster(), true); + QString scriptfile = MusEGlobal::song->getScriptPath(id, true); + MusEGlobal::song->executeScript(scriptfile.toLatin1().constData(), parts(), raster(), true); } //--------------------------------------------------------- @@ -1367,8 +1369,8 @@ void DrumEdit::execDeliveredScript(int id) //--------------------------------------------------------- void DrumEdit::execUserScript(int id) { - QString scriptfile = song->getScriptPath(id, false); - song->executeScript(scriptfile.toLatin1().constData(), parts(), raster(), true); + QString scriptfile = MusEGlobal::song->getScriptPath(id, false); + MusEGlobal::song->executeScript(scriptfile.toLatin1().constData(), parts(), raster(), true); } void DrumEdit::setStep(QString v) @@ -1380,8 +1382,8 @@ void DrumEdit::setStep(QString v) bool DrumEdit::old_style_drummap_mode() { - for (ciPart p = parts()->begin(); p != parts()->end(); ++p) - if (p->second->track()->type()==Track::DRUM) + for (MusECore::ciPart p = parts()->begin(); p != parts()->end(); ++p) + if (p->second->track()->type()==MusECore::Track::DRUM) return true; return false; @@ -1424,3 +1426,5 @@ void DrumEdit::set_ignore_hide(bool val) ((DrumCanvas*)(canvas))->rebuildOurDrumMap(); } + +} // namespace MusEGui diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index 4b0a39b8..5603e449 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -43,23 +43,26 @@ class QToolButton; class QWidget; class QComboBox; + +namespace MusECore { class MidiPart; -class DrumCanvas; -class ScrollScale; -class ScoreConfig; -class PartList; -class CtrlCanvas; -class Xml; -class DList; -class CtrlEdit; class Part; +class PartList; class SNode; +class Xml; +} + +namespace MusEGui { -namespace MusEWidget { +class CtrlCanvas; +class CtrlEdit; +class DList; +class DrumCanvas; class Header; +class ScoreConfig; +class ScrollScale; class Splitter; class Toolbar1; -} enum DrumColumn { COL_HIDE = 0, @@ -93,22 +96,22 @@ class DrumEdit : public MidiEditor { group_mode_t _group_mode; bool _ignore_hide; - Event selEvent; - MidiPart* selPart; + MusECore::Event selEvent; + MusECore::MidiPart* selPart; int selTick; QMenu* menuEdit, *menuFunctions, *menuFile, *menuSelect; - MusEWidget::NoteInfo* info; + MusEGui::NoteInfo* info; QToolButton* srec; QToolButton* midiin; - MusEWidget::EditToolBar* tools2; + MusEGui::EditToolBar* tools2; - MusEWidget::Toolbar1* toolbar; - MusEWidget::Splitter* split1; - MusEWidget::Splitter* split2; + MusEGui::Toolbar1* toolbar; + MusEGui::Splitter* split1; + MusEGui::Splitter* split2; QWidget* split1w1; DList* dlist; - MusEWidget::Header* header; + MusEGui::Header* header; QToolBar* tools; QComboBox *stepLenWidget; @@ -134,7 +137,7 @@ class DrumEdit : public MidiEditor { private slots: void setRaster(int); - void noteinfoChanged(MusEWidget::NoteInfo::ValType type, int val); + void noteinfoChanged(MusEGui::NoteInfo::ValType type, int val); //CtrlEdit* addCtrl(); void removeCtrl(CtrlEdit* ctrl); void cmd(int); @@ -153,7 +156,7 @@ class DrumEdit : public MidiEditor { void set_ignore_hide(bool); public slots: - void setSelection(int, Event&, Part*); + void setSelection(int, MusECore::Event&, MusECore::Part*); void soloChanged(bool); // called by Solo button void execDeliveredScript(int); void execUserScript(int); @@ -162,19 +165,21 @@ class DrumEdit : public MidiEditor { virtual void updateHScrollRange(); signals: - void deleted(TopWin*); + void deleted(MusEGui::TopWin*); public: - DrumEdit(PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT); + DrumEdit(MusECore::PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT); virtual ~DrumEdit(); - virtual void readStatus(Xml&); - virtual void writeStatus(int, Xml&) const; - static void readConfiguration(Xml& xml); - static void writeConfiguration(int, Xml&); + virtual void readStatus(MusECore::Xml&); + virtual void writeStatus(int, MusECore::Xml&) const; + static void readConfiguration(MusECore::Xml& xml); + static void writeConfiguration(int, MusECore::Xml&); bool old_style_drummap_mode(); group_mode_t group_mode() { return _group_mode; } bool ignore_hide() { return _ignore_hide; } }; +} // namespace MusEGui + #endif diff --git a/muse2/muse/midiedit/drummap.cpp b/muse2/muse/midiedit/drummap.cpp index 8f49afc0..9d4b23c2 100644 --- a/muse2/muse/midiedit/drummap.cpp +++ b/muse2/muse/midiedit/drummap.cpp @@ -26,12 +26,15 @@ #include "xml.h" #include "song.h" -global_drum_ordering_t global_drum_ordering; +namespace MusEGlobal { char drumOutmap[DRUM_MAPSIZE]; char drumInmap[128]; +MusECore::DrumMap drumMap[DRUM_MAPSIZE]; +global_drum_ordering_t global_drum_ordering; +} -DrumMap drumMap[DRUM_MAPSIZE]; +namespace MusECore { //--------------------------------------------------------- // GM default drum map @@ -257,18 +260,18 @@ const DrumMap idrumMap[DRUM_MAPSIZE] = { void initDrumMap() { for (int i = 0; i < DRUM_MAPSIZE; ++i) { - DrumMap d = drumMap[i]; + DrumMap d = MusEGlobal::drumMap[i]; //Make sure we're not overwriting any values loaded //On init, all these values are zero. If so, just set the drummap entry to the initial drummap entry. if (!(d.vol || d.len || d.channel || d.port || d.lv1 || d.lv2 || d.lv3 || d.lv4 || d.enote || d.anote || d.mute)) - drumMap[i] = idrumMap[i]; + MusEGlobal::drumMap[i] = idrumMap[i]; } //Finally, setup the inMap, outMap-values - memset(drumInmap, 0, sizeof(drumInmap)); - memset(drumOutmap, 0, sizeof(drumOutmap)); + memset(MusEGlobal::drumInmap, 0, sizeof(MusEGlobal::drumInmap)); + memset(MusEGlobal::drumOutmap, 0, sizeof(MusEGlobal::drumOutmap)); for (int i = 0; i < DRUM_MAPSIZE; ++i) { - drumInmap[(unsigned int)(drumMap[i].enote)] = i; - drumOutmap[(unsigned int)(drumMap[i].anote)] = i; + MusEGlobal::drumInmap[(unsigned int)(MusEGlobal::drumMap[i].enote)] = i; + MusEGlobal::drumOutmap[(unsigned int)(MusEGlobal::drumMap[i].anote)] = i; } } @@ -278,23 +281,23 @@ void initDrumMap() void resetGMDrumMap() { - audio->msgIdle(true); + MusEGlobal::audio->msgIdle(true); // Delete all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(false); - song->changeAllPortDrumCtrlEvents(false); + //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false); + MusEGlobal::song->changeAllPortDrumCtrlEvents(false); for(int i = 0; i < DRUM_MAPSIZE; ++i) - drumMap[i] = idrumMap[i]; - memset(drumInmap, 0, sizeof(drumInmap)); - memset(drumOutmap, 0, sizeof(drumOutmap)); + MusEGlobal::drumMap[i] = idrumMap[i]; + memset(MusEGlobal::drumInmap, 0, sizeof(MusEGlobal::drumInmap)); + memset(MusEGlobal::drumOutmap, 0, sizeof(MusEGlobal::drumOutmap)); for (int i = 0; i < DRUM_MAPSIZE; ++i) { - drumInmap[(unsigned int)(drumMap[i].enote)] = i; - drumOutmap[(unsigned int)(drumMap[i].anote)] = i; + MusEGlobal::drumInmap[(unsigned int)(MusEGlobal::drumMap[i].enote)] = i; + MusEGlobal::drumOutmap[(unsigned int)(MusEGlobal::drumMap[i].anote)] = i; } // Add all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(true); - song->changeAllPortDrumCtrlEvents(true); - audio->msgIdle(false); + //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true); + MusEGlobal::song->changeAllPortDrumCtrlEvents(true); + MusEGlobal::audio->msgIdle(false); } //--------------------------------------------------------- @@ -328,7 +331,7 @@ void writeDrumMap(int level, Xml& xml, bool external) { xml.tag(level++, "drummap"); for (int i = 0; i < DRUM_MAPSIZE; ++i) { - DrumMap* dm = &drumMap[i]; + DrumMap* dm = &MusEGlobal::drumMap[i]; const DrumMap* idm = &idrumMap[i]; if (external) { @@ -433,7 +436,7 @@ static void readDrummapEntry(Xml& xml, DrumMap* dm) case Xml::Attribut: if (tag == "idx") { int idx = xml.s2().toInt() & 0x7f; - dm = &drumMap[idx]; + dm = &MusEGlobal::drumMap[idx]; } break; @@ -454,18 +457,18 @@ static void readDrummapEntry(Xml& xml, DrumMap* dm) void readDrumMap(Xml& xml, bool external) { - audio->msgIdle(true); + MusEGlobal::audio->msgIdle(true); // Delete all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(false); - song->changeAllPortDrumCtrlEvents(false); + //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false); + MusEGlobal::song->changeAllPortDrumCtrlEvents(false); if (external) { for (int i = 0; i < DRUM_MAPSIZE; ++i) - drumMap[i] = blankdm; + MusEGlobal::drumMap[i] = blankdm; } else { for (int i = 0; i < DRUM_MAPSIZE; ++i) - drumMap[i] = idrumMap[i]; + MusEGlobal::drumMap[i] = idrumMap[i]; } int i = 0; for (;;) { @@ -474,16 +477,16 @@ void readDrumMap(Xml& xml, bool external) switch (token) { case Xml::Error: case Xml::End: - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(false); return; case Xml::TagStart: if (tag == "entry") { if(i >= DRUM_MAPSIZE) { - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(false); return; } - readDrummapEntry(xml, external ? &drumMap[i] : 0); + readDrummapEntry(xml, external ? &MusEGlobal::drumMap[i] : 0); ++i; } else if (tag == "comment") @@ -495,17 +498,17 @@ void readDrumMap(Xml& xml, bool external) break; case Xml::TagEnd: if (tag == "drummap") { - memset(drumInmap, 0, sizeof(drumInmap)); - memset(drumOutmap, 0, sizeof(drumOutmap)); + memset(MusEGlobal::drumInmap, 0, sizeof(MusEGlobal::drumInmap)); + memset(MusEGlobal::drumOutmap, 0, sizeof(MusEGlobal::drumOutmap)); for (int i = 0; i < DRUM_MAPSIZE; ++i) { - drumInmap[(unsigned int)(drumMap[i].enote)] = i; - drumOutmap[(unsigned int)(drumMap[i].anote)] = i; + MusEGlobal::drumInmap[(unsigned int)(MusEGlobal::drumMap[i].enote)] = i; + MusEGlobal::drumOutmap[(unsigned int)(MusEGlobal::drumMap[i].anote)] = i; } // Add all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(true); - song->changeAllPortDrumCtrlEvents(true); + //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true); + MusEGlobal::song->changeAllPortDrumCtrlEvents(true); - audio->msgIdle(false); + MusEGlobal::audio->msgIdle(false); return; } default: @@ -513,8 +516,9 @@ void readDrumMap(Xml& xml, bool external) } } // Add all port controller events. - //audio->msgChangeAllPortDrumCtrlEvents(true); - song->changeAllPortDrumCtrlEvents(true); - audio->msgIdle(false); + //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true); + MusEGlobal::song->changeAllPortDrumCtrlEvents(true); + MusEGlobal::audio->msgIdle(false); } +} // namespace MusECore diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h index db512103..2dbaae42 100644 --- a/muse2/muse/midiedit/drummap.h +++ b/muse2/muse/midiedit/drummap.h @@ -27,6 +27,8 @@ #include <QString> #include <QList> +namespace MusECore { + class Xml; //--------------------------------------------------------- @@ -51,9 +53,6 @@ struct DrumMap { #define DRUM_MAPSIZE 128 -extern char drumOutmap[DRUM_MAPSIZE]; -extern char drumInmap[DRUM_MAPSIZE]; -extern DrumMap drumMap[DRUM_MAPSIZE]; extern const DrumMap idrumMap[DRUM_MAPSIZE]; //FINDMICH dummy! extern void initDrumMap(); extern void writeDrumMap(int level, Xml& xml, bool external); @@ -61,8 +60,16 @@ extern void readDrumMap(Xml& xml, bool external); extern void resetGMDrumMap(); class MidiTrack; -typedef QList< std::pair<MidiTrack*,int> > global_drum_ordering_t; +} // namespace MusECore + +namespace MusEGlobal { +extern char drumOutmap[DRUM_MAPSIZE]; +extern char drumInmap[DRUM_MAPSIZE]; +extern MusECore::DrumMap drumMap[DRUM_MAPSIZE]; +typedef QList< std::pair<MusECore::MidiTrack*,int> > global_drum_ordering_t; extern global_drum_ordering_t global_drum_ordering; +} + #endif diff --git a/muse2/muse/midiedit/ecanvas.cpp b/muse2/muse/midiedit/ecanvas.cpp index b30574f1..61891b2e 100644 --- a/muse2/muse/midiedit/ecanvas.cpp +++ b/muse2/muse/midiedit/ecanvas.cpp @@ -42,6 +42,8 @@ #include "audio.h" #include "functions.h" +namespace MusEGui { + //--------------------------------------------------------- // EventCanvas //--------------------------------------------------------- @@ -61,7 +63,7 @@ EventCanvas::EventCanvas(MidiEditor* pr, QWidget* parent, int sx, setFocusPolicy(Qt::StrongFocus); setMouseTracking(true); - curPart = (MidiPart*)(editor->parts()->begin()->second); + curPart = (MusECore::MidiPart*)(editor->parts()->begin()->second); curPartId = curPart->sn(); } @@ -133,7 +135,7 @@ void EventCanvas::mouseMove(QMouseEvent* event) void EventCanvas::updateSelection() { - song->update(SC_SELECTION); + MusEGlobal::song->update(SC_SELECTION); } //--------------------------------------------------------- @@ -152,8 +154,8 @@ void EventCanvas::songChanged(int flags) start_tick = MAXINT; end_tick = 0; curPart = 0; - for (iPart p = editor->parts()->begin(); p != editor->parts()->end(); ++p) { - MidiPart* part = (MidiPart*)(p->second); + for (MusECore::iPart p = editor->parts()->begin(); p != editor->parts()->end(); ++p) { + MusECore::MidiPart* part = (MusECore::MidiPart*)(p->second); if (part->sn() == curPartId) curPart = part; unsigned stick = part->tick(); @@ -164,9 +166,9 @@ void EventCanvas::songChanged(int flags) if (etick > end_tick) end_tick = etick; - EventList* el = part->events(); - for (iEvent i = el->begin(); i != el->end(); ++i) { - Event e = i->second; + MusECore::EventList* el = part->events(); + for (MusECore::iEvent i = el->begin(); i != el->end(); ++i) { + MusECore::Event e = i->second; // Added by T356. Do not add events which are either past, or extend past the end of the part. // Reverted to just events which are past. p4.0.24 if(e.tick() > len) @@ -180,32 +182,32 @@ void EventCanvas::songChanged(int flags) } } - Event event; - MidiPart* part = 0; + MusECore::Event event; + MusECore::MidiPart* part = 0; int x = 0; - MusEWidget::CItem* nevent = 0; + CItem* nevent = 0; int n = 0; // count selections - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { - Event ev = k->second->event(); + for (iCItem k = items.begin(); k != items.end(); ++k) { + MusECore::Event ev = k->second->event(); bool selected = ev.selected(); if (selected) { k->second->setSelected(true); ++n; if (!nevent) { nevent = k->second; - Event mi = nevent->event(); + MusECore::Event mi = nevent->event(); curVelo = mi.velo(); } } } - start_tick = song->roundDownBar(start_tick); - end_tick = song->roundUpBar(end_tick); + start_tick = MusEGlobal::song->roundDownBar(start_tick); + end_tick = MusEGlobal::song->roundUpBar(end_tick); if (n == 1) { x = nevent->x(); event = nevent->event(); - part = (MidiPart*)nevent->part(); + part = (MusECore::MidiPart*)nevent->part(); if (curPart != part) { curPart = part; curPartId = curPart->sn(); @@ -214,7 +216,7 @@ void EventCanvas::songChanged(int flags) } emit selectionChanged(x, event, part); if (curPart == 0) - curPart = (MidiPart*)(editor->parts()->begin()->second); + curPart = (MusECore::MidiPart*)(editor->parts()->begin()->second); redraw(); } @@ -225,11 +227,11 @@ void EventCanvas::selectAtTick(unsigned int tick) { //Select note nearest tick, if none selected and there are any if (!items.empty() && selectionSize() == 0) { - MusEWidget::iCItem i = items.begin(); - MusEWidget::CItem* nearest = i->second; + iCItem i = items.begin(); + CItem* nearest = i->second; while (i != items.end()) { - MusEWidget::CItem* cur=i->second; + CItem* cur=i->second; unsigned int curtk=abs(cur->x() + cur->part()->tick() - tick); unsigned int neartk=abs(nearest->x() + nearest->part()->tick() - tick); @@ -251,9 +253,9 @@ void EventCanvas::selectAtTick(unsigned int tick) // track //--------------------------------------------------------- -MidiTrack* EventCanvas::track() const +MusECore::MidiTrack* EventCanvas::track() const { - return ((MidiPart*)curPart)->track(); + return ((MusECore::MidiPart*)curPart)->track(); } @@ -283,7 +285,7 @@ void EventCanvas::keyPress(QKeyEvent* event) int tick_min = INT_MAX; bool found = false; - for (MusEWidget::iCItem i= items.begin(); i != items.end(); i++) { + for (iCItem i= items.begin(); i != items.end(); i++) { if (!i->second->isSelected()) continue; @@ -296,16 +298,16 @@ void EventCanvas::keyPress(QKeyEvent* event) tick_min = tick; } if (found) { - Pos p1(tick_min, true); - Pos p2(tick_max, true); - song->setPos(1, p1); - song->setPos(2, p2); + MusECore::Pos p1(tick_min, true); + MusECore::Pos p2(tick_max, true); + MusEGlobal::song->setPos(1, p1); + MusEGlobal::song->setPos(2, p2); } } // Select items by key (PianoRoll & DrumEditor) else if (key == shortcuts[SHRT_SEL_RIGHT].key || key == shortcuts[SHRT_SEL_RIGHT_ADD].key) { - MusEWidget::iCItem i, iRightmost; - MusEWidget::CItem* rightmost = NULL; + iCItem i, iRightmost; + CItem* rightmost = NULL; //Get the rightmost selected note (if any) for (i = items.begin(); i != items.end(); ++i) { if (i->second->isSelected()) { @@ -313,7 +315,7 @@ void EventCanvas::keyPress(QKeyEvent* event) } } if (rightmost) { - MusEWidget::iCItem temp = iRightmost; temp++; + iCItem temp = iRightmost; temp++; //If so, deselect current note and select the one to the right if (temp != items.end()) { if (key != shortcuts[SHRT_SEL_RIGHT_ADD].key) @@ -330,8 +332,8 @@ void EventCanvas::keyPress(QKeyEvent* event) } //Select items by key: (PianoRoll & DrumEditor) else if (key == shortcuts[SHRT_SEL_LEFT].key || key == shortcuts[SHRT_SEL_LEFT_ADD].key) { - MusEWidget::iCItem i, iLeftmost; - MusEWidget::CItem* leftmost = NULL; + iCItem i, iLeftmost; + CItem* leftmost = NULL; if (items.size() > 0 ) { for (i = items.end(), i--; i != items.begin(); i--) { if (i->second->isSelected()) { @@ -354,27 +356,27 @@ void EventCanvas::keyPress(QKeyEvent* event) } } else if (key == shortcuts[SHRT_INC_PITCH].key) { - modifySelected(MusEWidget::NoteInfo::VAL_PITCH, 1); + modifySelected(NoteInfo::VAL_PITCH, 1); } else if (key == shortcuts[SHRT_DEC_PITCH].key) { - modifySelected(MusEWidget::NoteInfo::VAL_PITCH, -1); + modifySelected(NoteInfo::VAL_PITCH, -1); } else if (key == shortcuts[SHRT_INC_POS].key) { // TODO: Check boundaries - modifySelected(MusEWidget::NoteInfo::VAL_TIME, editor->raster()); + modifySelected(NoteInfo::VAL_TIME, editor->raster()); } else if (key == shortcuts[SHRT_DEC_POS].key) { // TODO: Check boundaries - modifySelected(MusEWidget::NoteInfo::VAL_TIME, 0 - editor->raster()); + modifySelected(NoteInfo::VAL_TIME, 0 - editor->raster()); } else if (key == shortcuts[SHRT_INCREASE_LEN].key) { // TODO: Check boundaries - modifySelected(MusEWidget::NoteInfo::VAL_LEN, editor->raster()); + modifySelected(NoteInfo::VAL_LEN, editor->raster()); } else if (key == shortcuts[SHRT_DECREASE_LEN].key) { // TODO: Check boundaries - modifySelected(MusEWidget::NoteInfo::VAL_LEN, 0 - editor->raster()); + modifySelected(NoteInfo::VAL_LEN, 0 - editor->raster()); } else @@ -431,15 +433,17 @@ void EventCanvas::endMoveItems(const QPoint& pos, DragType dragtype, int dir) - Undo operations = moveCanvasItems(moving, dp, dx, dragtype); + MusECore::Undo operations = moveCanvasItems(moving, dp, dx, dragtype); if (operations.empty()) songChanged(SC_EVENT_MODIFIED); //this is a hack to force the canvas to repopulate //itself. otherwise, if a moving operation was forbidden, //the canvas would still show the movement else - song->applyOperationGroup(operations); + MusEGlobal::song->applyOperationGroup(operations); moving.clear(); updateSelection(); redraw(); } + +} // namespace MusEGui diff --git a/muse2/muse/midiedit/ecanvas.h b/muse2/muse/midiedit/ecanvas.h index f31b5f6b..1c66e9b4 100644 --- a/muse2/muse/midiedit/ecanvas.h +++ b/muse2/muse/midiedit/ecanvas.h @@ -28,15 +28,16 @@ #include <QEvent> #include <QKeyEvent> -class MidiPart; -class MidiTrack; -class MidiEditor; -class Part; class QMimeData; class QDrag; class QString; class QDropEvent; +namespace MusECore { +class MidiPart; +class MidiTrack; +class Part; + struct PartToChange { Part* npart; @@ -45,11 +46,16 @@ struct PartToChange typedef std::map<Part*, PartToChange> PartsToChangeMap; typedef std::map<Part*, PartToChange>::iterator iPartToChange; +} + +namespace MusEGui { + +class MidiEditor; //--------------------------------------------------------- // EventCanvas //--------------------------------------------------------- -class EventCanvas : public MusEWidget::Canvas { +class EventCanvas : public Canvas { Q_OBJECT virtual void leaveEvent(QEvent*e); virtual void enterEvent(QEvent*e); @@ -65,11 +71,11 @@ class EventCanvas : public MusEWidget::Canvas { bool _midiin; void updateSelection(); - virtual void addItem(Part*, Event&) = 0; + virtual void addItem(MusECore::Part*, MusECore::Event&) = 0; // Added by T356. virtual QPoint raster(const QPoint&) const; - virtual Undo moveCanvasItems(MusEWidget::CItemList&, int, int, DragType) = 0; - virtual UndoOp moveItem(MusEWidget::CItem*, const QPoint&, DragType) = 0; + virtual MusECore::Undo moveCanvasItems(CItemList&, int, int, DragType) = 0; + virtual MusECore::UndoOp moveItem(CItem*, const QPoint&, DragType) = 0; virtual void endMoveItems(const QPoint&, DragType, int dir); public slots: @@ -80,12 +86,12 @@ class EventCanvas : public MusEWidget::Canvas { signals: void pitchChanged(int); // current cursor position void timeChanged(unsigned); - void selectionChanged(int, Event&, Part*); + void selectionChanged(int, MusECore::Event&, MusECore::Part*); void enterCanvas(); public: EventCanvas(MidiEditor*, QWidget*, int, int, const char* name = 0); - MidiTrack* track() const; + MusECore::MidiTrack* track() const; unsigned start() const { return start_tick; } unsigned end() const { return end_tick; } bool midiin() const { return _midiin; } @@ -96,9 +102,11 @@ class EventCanvas : public MusEWidget::Canvas { void playEvents(bool flag) { _playEvents = flag; } void selectAtTick(unsigned int tick); void viewDropEvent(QDropEvent* event); - virtual void modifySelected(MusEWidget::NoteInfo::ValType, int) {} + virtual void modifySelected(NoteInfo::ValType, int) {} virtual void keyPress(QKeyEvent*); }; +} // namespace MusEGui + #endif diff --git a/muse2/muse/midiedit/piano.cpp b/muse2/muse/midiedit/piano.cpp index d347b10a..abd360df 100644 --- a/muse2/muse/midiedit/piano.cpp +++ b/muse2/muse/midiedit/piano.cpp @@ -367,7 +367,7 @@ static const char *mk4_xpm[] = { //--------------------------------------------------------- Piano::Piano(QWidget* parent, int ymag) - : MusEWidget::View(parent, 1, ymag) + : MusEGui::View(parent, 1, ymag) { setMouseTracking(true); curPitch = -1; diff --git a/muse2/muse/midiedit/piano.h b/muse2/muse/midiedit/piano.h index 133295ab..ea032189 100644 --- a/muse2/muse/midiedit/piano.h +++ b/muse2/muse/midiedit/piano.h @@ -36,7 +36,7 @@ class QPixmap; // Piano //--------------------------------------------------------- -class Piano : public MusEWidget::View +class Piano : public MusEGui::View { Q_OBJECT diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp index 178b5c46..82a75f7f 100644 --- a/muse2/muse/midiedit/pianoroll.cpp +++ b/muse2/muse/midiedit/pianoroll.cpp @@ -68,20 +68,22 @@ #include "mtrackinfo.h" +namespace MusEGui { + int PianoRoll::_rasterInit = 96; int PianoRoll::colorModeInit = 0; static const int xscale = -10; static const int yscale = 1; static const int pianoWidth = 40; -static int pianorollTools = MusEWidget::PointerTool | MusEWidget::PencilTool | MusEWidget::RubberTool | MusEWidget::DrawTool; +static int pianorollTools = MusEGui::PointerTool | MusEGui::PencilTool | MusEGui::RubberTool | MusEGui::DrawTool; //--------------------------------------------------------- // PianoRoll //--------------------------------------------------------- -PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned initPos) +PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name, unsigned initPos) : MidiEditor(TopWin::PIANO_ROLL, _rasterInit, pl, parent, name) { deltaMode = false; @@ -214,7 +216,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i menuPlugins = menuBar()->addMenu(tr("&Plugins")); - song->populateScriptMenu(menuPlugins, this); + MusEGlobal::song->populateScriptMenu(menuPlugins, this); connect(mapper, SIGNAL(mapped(int)), this, SLOT(cmd(int))); @@ -282,7 +284,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i speaker->setCheckable(true); tools->addWidget(speaker); - tools2 = new MusEWidget::EditToolBar(this, pianorollTools); + tools2 = new MusEGui::EditToolBar(this, pianorollTools); addToolBar(tools2); QToolBar* panicToolbar = addToolBar(tr("panic")); @@ -296,32 +298,32 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i transport->addActions(MusEGlobal::transportAction->actions()); addToolBarBreak(); - toolbar = new MusEWidget::Toolbar1(this, _rasterInit); + toolbar = new MusEGui::Toolbar1(this, _rasterInit); addToolBar(toolbar); addToolBarBreak(); - info = new MusEWidget::NoteInfo(this); + info = new MusEGui::NoteInfo(this); addToolBar(info); //--------------------------------------------------- // split //--------------------------------------------------- - splitter = new MusEWidget::Splitter(Qt::Vertical, mainw, "splitter"); + splitter = new MusEGui::Splitter(Qt::Vertical, mainw, "splitter"); splitter->setHandleWidth(2); - hsplitter = new MusEWidget::Splitter(Qt::Horizontal, mainw, "hsplitter"); + hsplitter = new MusEGui::Splitter(Qt::Horizontal, mainw, "hsplitter"); hsplitter->setChildrenCollapsible(true); hsplitter->setHandleWidth(2); QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw); //QPushButton* ctrl = new QPushButton(tr("C"), mainw); // Tim. ctrl->setObjectName("Ctrl"); - ctrl->setFont(MusEConfig::config.fonts[3]); + ctrl->setFont(MusEGlobal::config.fonts[3]); ctrl->setToolTip(tr("Add Controller View")); - //hscroll = new MusEWidget::ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw); + //hscroll = new MusEGui::ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw); // Increased scale to -1. To resolve/select/edit 1-tick-wide (controller graph) events. p4.0.18 Tim. - hscroll = new MusEWidget::ScrollScale(-25, -1, xscale, 20000, Qt::Horizontal, mainw); + hscroll = new MusEGui::ScrollScale(-25, -1, xscale, 20000, Qt::Horizontal, mainw); ctrl->setFixedSize(pianoWidth, hscroll->sizeHint().height()); //ctrl->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height()); // Tim. @@ -329,14 +331,14 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i /* QPushButton* trackInfoButton = new QPushButton(tr("T"), mainw); trackInfoButton->setObjectName("TrackInfo"); - trackInfoButton->setFont(MusEConfig::config.fonts[3]); + trackInfoButton->setFont(MusEGlobal::config.fonts[3]); trackInfoButton->setToolTip(tr("Show track info")); trackInfoButton->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height()); */ QSizeGrip* corner = new QSizeGrip(mainw); - midiTrackInfo = new MusEWidget::MidiTrackInfo(mainw); + midiTrackInfo = new MusEGui::MidiTrackInfo(mainw); int mtiw = midiTrackInfo->width(); // Save this. midiTrackInfo->setMinimumWidth(100); //midiTrackInfo->setMaximumWidth(150); @@ -389,14 +391,14 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i 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 MusEWidget::MTScale(&_raster, split1, xscale); + time = new MusEGui::MTScale(&_raster, split1, xscale); Piano* piano = new Piano(split1, yscale); canvas = new PianoCanvas(this, split1, xscale, yscale); - vscroll = new MusEWidget::ScrollScale(-3, 7, yscale, KH * 75, Qt::Vertical, split1); + vscroll = new MusEGui::ScrollScale(-3, 7, yscale, KH * 75, Qt::Vertical, split1); //setFocusProxy(canvas); // Tim. - int offset = -(MusEConfig::config.division/4); + int offset = -(MusEGlobal::config.division/4); canvas->setOrigin(offset, 0); canvas->setCanvasTools(pianorollTools); canvas->setFocus(); @@ -410,7 +412,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i //gridS1->setColumnStretch(2, 100); // Tim. gridS1->addWidget(time, 0, 1, 1, 2); - gridS1->addWidget(MusEUtil::hLine(split1), 1, 0, 1, 3); + gridS1->addWidget(MusECore::hLine(split1), 1, 0, 1, 3); gridS1->addWidget(piano, 2, 0); gridS1->addWidget(canvas, 2, 1); gridS1->addWidget(vscroll, 2, 2); @@ -418,7 +420,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i // Tim. /* gridS1->addWidget(time, 0, 2, 1, 3); - gridS1->addWidget(MusEUtil::hLine(split1), 1, 1, 1, 4); + 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); @@ -426,7 +428,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i gridS1->addWidget(vscroll, 2, 3); */ - ctrlLane = new MusEWidget::Splitter(Qt::Vertical, splitter, "ctrllane"); + ctrlLane = new MusEGui::Splitter(Qt::Vertical, splitter, "ctrllane"); QWidget* split2 = new QWidget(splitter); split2->setMaximumHeight(hscroll->sizeHint().height()); split2->setMinimumHeight(hscroll->sizeHint().height()); @@ -452,7 +454,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl())); //connect(trackInfoButton, SIGNAL(clicked()), SLOT(toggleTrackInfo())); Tim. - connect(info, SIGNAL(valueChanged(MusEWidget::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEWidget::NoteInfo::ValType, int))); + connect(info, SIGNAL(valueChanged(MusEGui::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEGui::NoteInfo::ValType, int))); connect(vscroll, SIGNAL(scrollChanged(int)), piano, SLOT(setYPos(int))); connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int))); connect(vscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setYMag(int))); @@ -469,8 +471,8 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i 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, Event&, Part*)), this, - SLOT(setSelection(int, Event&, Part*))); + connect(canvas, SIGNAL(selectionChanged(int, MusECore::Event&, MusECore::Part*)), this, + SLOT(setSelection(int, MusECore::Event&, MusECore::Part*))); connect(piano, SIGNAL(keyPressed(int, int, bool)), canvas, SLOT(pianoPressed(int, int, bool))); connect(piano, SIGNAL(keyReleased(int, bool)), canvas, SLOT(pianoReleased(int, bool))); @@ -486,7 +488,7 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i //setSelection(0, 0, 0); //Really necessary? Causes segfault when only 1 item selected, replaced by the following: info->setEnabled(false); - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int))); + connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged1(int))); setWindowTitle(canvas->getCaption()); @@ -510,14 +512,14 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i selectionChanged(); // enable/disable "Copy" & "Paste" initShortcuts(); // initialize shortcuts - const Pos cpos=song->cPos(); + const MusECore::Pos cpos=MusEGlobal::song->cPos(); canvas->setPos(0, cpos.tick(), true); canvas->selectAtTick(cpos.tick()); //canvas->selectFirst();// unsigned pos=0; if(initPos >= MAXINT) - pos = song->cpos(); + pos = MusEGlobal::song->cpos(); if(pos > MAXINT) pos = MAXINT; if (pos) @@ -638,14 +640,14 @@ void PianoRoll::cmd(int cmd) erase_notes(partlist_to_set(parts()), 1); break; case PianoCanvas::CMD_COPY: copy_notes(partlist_to_set(parts()), 1); break; - case PianoCanvas::CMD_COPY_RANGE: copy_notes(partlist_to_set(parts()), MusEUtil::any_event_selected(partlist_to_set(parts())) ? 3 : 2); break; + case PianoCanvas::CMD_COPY_RANGE: copy_notes(partlist_to_set(parts()), MusECore::any_event_selected(partlist_to_set(parts())) ? 3 : 2); break; case PianoCanvas::CMD_PASTE: ((PianoCanvas*)canvas)->cmd(PianoCanvas::CMD_SELECT_NONE); - paste_notes(3072); + MusECore::paste_notes(3072); break; case PianoCanvas::CMD_PASTE_DIALOG: ((PianoCanvas*)canvas)->cmd(PianoCanvas::CMD_SELECT_NONE); - paste_notes((canvas->part())); + MusECore::paste_notes((canvas->part())); break; case PianoCanvas::CMD_MODIFY_GATE_TIME: modify_notelen(partlist_to_set(parts())); break; case PianoCanvas::CMD_MODIFY_VELOCITY: modify_velocity(partlist_to_set(parts())); break; @@ -668,12 +670,12 @@ void PianoRoll::cmd(int cmd) // update Info Line //--------------------------------------------------------- -void PianoRoll::setSelection(int tick, Event& e, Part* p) +void PianoRoll::setSelection(int tick, MusECore::Event& e, MusECore::Part* p) { int selections = canvas->selectionSize(); selEvent = e; - selPart = (MidiPart*)p; + selPart = (MusECore::MidiPart*)p; selTick = tick; if (selections > 1) { @@ -710,7 +712,7 @@ void PianoRoll::setSelection(int tick, Event& e, Part* p) // edit currently selected Event //--------------------------------------------------------- -void PianoRoll::noteinfoChanged(MusEWidget::NoteInfo::ValType type, int val) +void PianoRoll::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val) { int selections = canvas->selectionSize(); @@ -718,27 +720,27 @@ void PianoRoll::noteinfoChanged(MusEWidget::NoteInfo::ValType type, int val) printf("noteinfoChanged while nothing selected\n"); } else if (selections == 1) { - Event event = selEvent.clone(); + MusECore::Event event = selEvent.clone(); switch(type) { - case MusEWidget::NoteInfo::VAL_TIME: + case MusEGui::NoteInfo::VAL_TIME: event.setTick(val - selPart->tick()); break; - case MusEWidget::NoteInfo::VAL_LEN: + case MusEGui::NoteInfo::VAL_LEN: event.setLenTick(val); break; - case MusEWidget::NoteInfo::VAL_VELON: + case MusEGui::NoteInfo::VAL_VELON: event.setVelo(val); break; - case MusEWidget::NoteInfo::VAL_VELOFF: + case MusEGui::NoteInfo::VAL_VELOFF: event.setVeloOff(val); break; - case MusEWidget::NoteInfo::VAL_PITCH: + case MusEGui::NoteInfo::VAL_PITCH: event.setPitch(val); break; } // Indicate do undo, and do not do port controller values and clone parts. - //audio->msgChangeEvent(selEvent, event, selPart); - audio->msgChangeEvent(selEvent, event, selPart, true, false, false); + //MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart); + MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart, true, false, false); } else { // multiple events are selected; treat noteinfo values @@ -746,23 +748,23 @@ void PianoRoll::noteinfoChanged(MusEWidget::NoteInfo::ValType type, int val) int delta = 0; switch (type) { - case MusEWidget::NoteInfo::VAL_TIME: + case MusEGui::NoteInfo::VAL_TIME: delta = val - tickOffset; tickOffset = val; break; - case MusEWidget::NoteInfo::VAL_LEN: + case MusEGui::NoteInfo::VAL_LEN: delta = val - lenOffset; lenOffset = val; break; - case MusEWidget::NoteInfo::VAL_VELON: + case MusEGui::NoteInfo::VAL_VELON: delta = val - veloOnOffset; veloOnOffset = val; break; - case MusEWidget::NoteInfo::VAL_VELOFF: + case MusEGui::NoteInfo::VAL_VELOFF: delta = val - veloOffOffset; veloOffOffset = val; break; - case MusEWidget::NoteInfo::VAL_PITCH: + case MusEGui::NoteInfo::VAL_PITCH: delta = val - pitchOffset; pitchOffset = val; break; @@ -829,15 +831,15 @@ void PianoRoll::closeEvent(QCloseEvent* e) // readConfiguration //--------------------------------------------------------- -void PianoRoll::readConfiguration(Xml& xml) +void PianoRoll::readConfiguration(MusECore::Xml& xml) { for (;;) { - Xml::Token token = xml.parse(); - if (token == Xml::Error || token == Xml::End) + MusECore::Xml::Token token = xml.parse(); + if (token == MusECore::Xml::Error || token == MusECore::Xml::End) break; const QString& tag = xml.s1(); switch (token) { - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "raster") _rasterInit = xml.parseInt(); else if (tag == "colormode") @@ -847,7 +849,7 @@ void PianoRoll::readConfiguration(Xml& xml) else xml.unknown("PianoRoll"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "pianoroll") return; default: @@ -860,7 +862,7 @@ void PianoRoll::readConfiguration(Xml& xml) // writeConfiguration //--------------------------------------------------------- -void PianoRoll::writeConfiguration(int level, Xml& xml) +void PianoRoll::writeConfiguration(int level, MusECore::Xml& xml) { xml.tag(level++, "pianoroll"); xml.intTag(level, "raster", _rasterInit); @@ -876,8 +878,8 @@ void PianoRoll::writeConfiguration(int level, Xml& xml) void PianoRoll::soloChanged(bool flag) { - audio->msgSetSolo(canvas->track(), flag); - song->update(SC_SOLO); + MusEGlobal::audio->msgSetSolo(canvas->track(), flag); + MusEGlobal::song->update(SC_SOLO); } //--------------------------------------------------------- @@ -896,7 +898,7 @@ void PianoRoll::setRaster(int val) // writeStatus //--------------------------------------------------------- -void PianoRoll::writeStatus(int level, Xml& xml) const +void PianoRoll::writeStatus(int level, MusECore::Xml& xml) const { writePartList(level, xml); xml.tag(level++, "pianoroll"); @@ -924,15 +926,15 @@ void PianoRoll::writeStatus(int level, Xml& xml) const // readStatus //--------------------------------------------------------- -void PianoRoll::readStatus(Xml& xml) +void PianoRoll::readStatus(MusECore::Xml& xml) { for (;;) { - Xml::Token token = xml.parse(); - if (token == Xml::Error || token == Xml::End) + MusECore::Xml::Token token = xml.parse(); + if (token == MusECore::Xml::Error || token == MusECore::Xml::End) break; const QString& tag = xml.s1(); switch (token) { - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "steprec") { int val = xml.parseInt(); canvas->setSteprec(val); @@ -974,7 +976,7 @@ void PianoRoll::readStatus(Xml& xml) else xml.unknown("PianoRoll"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "pianoroll") { _rasterInit = _raster; toolbar->setRaster(_raster); @@ -1034,19 +1036,19 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) return; } else if (key == shortcuts[SHRT_TOOL_POINTER].key) { - tools2->set(MusEWidget::PointerTool); + tools2->set(MusEGui::PointerTool); return; } else if (key == shortcuts[SHRT_TOOL_PENCIL].key) { - tools2->set(MusEWidget::PencilTool); + tools2->set(MusEGui::PencilTool); return; } else if (key == shortcuts[SHRT_TOOL_RUBBER].key) { - tools2->set(MusEWidget::RubberTool); + tools2->set(MusEGui::RubberTool); return; } else if (key == shortcuts[SHRT_TOOL_LINEDRAW].key) { - tools2->set(MusEWidget::DrawTool); + tools2->set(MusEGui::DrawTool); return; } else if (key == shortcuts[SHRT_POS_INC].key) { @@ -1075,41 +1077,41 @@ void PianoRoll::keyPressEvent(QKeyEvent* event) } else if (key == shortcuts[SHRT_ZOOM_IN].key) { int mag = hscroll->mag(); - int zoomlvl = MusEWidget::ScrollScale::getQuickZoomLevel(mag); + int zoomlvl = MusEGui::ScrollScale::getQuickZoomLevel(mag); if (zoomlvl < 23) zoomlvl++; - int newmag = MusEWidget::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + int newmag = MusEGui::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); hscroll->setMag(newmag); //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag); return; } else if (key == shortcuts[SHRT_ZOOM_OUT].key) { int mag = hscroll->mag(); - int zoomlvl = MusEWidget::ScrollScale::getQuickZoomLevel(mag); + int zoomlvl = MusEGui::ScrollScale::getQuickZoomLevel(mag); if (zoomlvl > 1) zoomlvl--; - int newmag = MusEWidget::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); + int newmag = MusEGui::ScrollScale::convertQuickZoomLevelToMag(zoomlvl); hscroll->setMag(newmag); //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag); return; } else if (key == shortcuts[SHRT_GOTO_CPOS].key) { - PartList* p = this->parts(); - Part* first = p->begin()->second; - hscroll->setPos(song->cpos() - first->tick() ); + MusECore::PartList* p = this->parts(); + MusECore::Part* first = p->begin()->second; + hscroll->setPos(MusEGlobal::song->cpos() - first->tick() ); return; } else if (key == shortcuts[SHRT_SCROLL_LEFT].key) { - int pos = hscroll->pos() - MusEConfig::config.division; + int pos = hscroll->pos() - MusEGlobal::config.division; if (pos < 0) pos = 0; hscroll->setPos(pos); return; } else if (key == shortcuts[SHRT_SCROLL_RIGHT].key) { - int pos = hscroll->pos() + MusEConfig::config.division; + int pos = hscroll->pos() + MusEGlobal::config.division; hscroll->setPos(pos); return; } @@ -1292,8 +1294,8 @@ void PianoRoll::initShortcuts() void PianoRoll::execDeliveredScript(int id) { //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id]; - QString scriptfile = song->getScriptPath(id, true); - song->executeScript(scriptfile.toAscii().data(), parts(), raster(), true); + QString scriptfile = MusEGlobal::song->getScriptPath(id, true); + MusEGlobal::song->executeScript(scriptfile.toAscii().data(), parts(), raster(), true); } //--------------------------------------------------------- @@ -1301,8 +1303,8 @@ void PianoRoll::execDeliveredScript(int id) //--------------------------------------------------------- void PianoRoll::execUserScript(int id) { - QString scriptfile = song->getScriptPath(id, false); - song->executeScript(scriptfile.toAscii().data(), parts(), raster(), true); + QString scriptfile = MusEGlobal::song->getScriptPath(id, false); + MusEGlobal::song->executeScript(scriptfile.toAscii().data(), parts(), raster(), true); } //--------------------------------------------------------- @@ -1337,3 +1339,5 @@ void PianoRoll::toggleTrackInfo() infoScroll->setVisible(!vis); infoScroll->setEnabled(!vis); } + +} // namespace MusEGui diff --git a/muse2/muse/midiedit/pianoroll.h b/muse2/muse/midiedit/pianoroll.h index 1a87d407..0b90b1e6 100644 --- a/muse2/muse/midiedit/pianoroll.h +++ b/muse2/muse/midiedit/pianoroll.h @@ -35,33 +35,35 @@ #include "tools.h" #include "event.h" -class MidiPart; -class TimeLabel; -class PitchLabel; +class QAction; class QLabel; -class PianoCanvas; -class MTScale; -class Track; -class QToolButton; -class QToolBar; +class QMenu; class QPushButton; -class CtrlEdit; +class QScrollArea; +class QScrollBar; +class QToolBar; +class QToolButton; +class QWidget; + +namespace MusECore { +class MidiPart; +class Part; class PartList; +class Track; class Xml; -class ScrollScale; -class Part; -class SNode; -class QMenu; -class QAction; -class QWidget; -class QScrollBar; -class QScrollArea; +} -namespace MusEWidget { + +namespace MusEGui { +class CtrlEdit; class MidiTrackInfo; +class PianoCanvas; +class PitchLabel; +class SNode; +class ScrollScale; class Splitter; +class TimeLabel; class Toolbar1; -} //--------------------------------------------------------- // PianoRoll @@ -70,8 +72,8 @@ class Toolbar1; class PianoRoll : public MidiEditor { Q_OBJECT - Event selEvent; - MidiPart* selPart; + MusECore::Event selEvent; + MusECore::MidiPart* selPart; int selTick; //enum { CMD_EVENT_COLOR, CMD_CONFIG_QUANT, CMD_LAST }; @@ -80,8 +82,8 @@ class PianoRoll : public MidiEditor { QMenu *menuEdit, *menuFunctions, *menuSelect, *menuConfig, *eventColor, *menuPlugins; - MusEWidget::MidiTrackInfo *midiTrackInfo; - Track* selected; + MusEGui::MidiTrackInfo *midiTrackInfo; + MusECore::Track* selected; QAction* editCutAction; QAction* editCopyAction; @@ -120,18 +122,18 @@ class PianoRoll : public MidiEditor { int veloOffOffset; bool deltaMode; - MusEWidget::NoteInfo* info; + MusEGui::NoteInfo* info; QToolButton* srec; QToolButton* midiin; - MusEWidget::Toolbar1* toolbar; - MusEWidget::Splitter* splitter; - MusEWidget::Splitter* hsplitter; - MusEWidget::Splitter* ctrlLane; + MusEGui::Toolbar1* toolbar; + MusEGui::Splitter* splitter; + MusEGui::Splitter* hsplitter; + MusEGui::Splitter* ctrlLane; QToolButton* speaker; QToolBar* tools; - MusEWidget::EditToolBar* tools2; + MusEGui::EditToolBar* tools2; int colorMode; @@ -152,8 +154,8 @@ class PianoRoll : public MidiEditor { virtual void keyPressEvent(QKeyEvent*); private slots: - void setSelection(int, Event&, Part*); - void noteinfoChanged(MusEWidget::NoteInfo::ValType, int); + void setSelection(int, MusECore::Event&, MusECore::Part*); + void noteinfoChanged(MusEGui::NoteInfo::ValType, int); //CtrlEdit* addCtrl(); void removeCtrl(CtrlEdit* ctrl); void soloChanged(bool flag); @@ -174,7 +176,7 @@ class PianoRoll : public MidiEditor { void updateTrackInfo(); signals: - void deleted(TopWin*); + void deleted(MusEGui::TopWin*); public slots: virtual void updateHScrollRange(); @@ -183,13 +185,15 @@ class PianoRoll : public MidiEditor { CtrlEdit* addCtrl(); public: - PianoRoll(PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT); + PianoRoll(MusECore::PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT); ~PianoRoll(); - virtual void readStatus(Xml&); - virtual void writeStatus(int, Xml&) const; - static void readConfiguration(Xml&); - static void writeConfiguration(int, Xml&); + virtual void readStatus(MusECore::Xml&); + virtual void writeStatus(int, MusECore::Xml&) const; + static void readConfiguration(MusECore::Xml&); + static void writeConfiguration(int, MusECore::Xml&); }; +} // namespace MusEGui + #endif diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp index b9b4794f..9acaf186 100644 --- a/muse2/muse/midiedit/prcanvas.cpp +++ b/muse2/muse/midiedit/prcanvas.cpp @@ -56,11 +56,13 @@ #define CHORD_TIMEOUT 75 +namespace MusEGui { + //--------------------------------------------------------- // NEvent //--------------------------------------------------------- -NEvent::NEvent(Event& e, Part* p, int y) : MusEWidget::CItem(e, p) +NEvent::NEvent(MusECore::Event& e, MusECore::Part* p, int y) : MusEGui::CItem(e, p) { y = y - KH/4; unsigned tick = e.tick() + p->tick(); @@ -72,7 +74,7 @@ NEvent::NEvent(Event& e, Part* p, int y) : MusEWidget::CItem(e, p) // addItem //--------------------------------------------------------- -void PianoCanvas::addItem(Part* part, Event& event) +void PianoCanvas::addItem(MusECore::Part* part, MusECore::Event& event) { if (signed(event.tick())<0) { printf("ERROR: trying to add event before current part!\n"); @@ -85,9 +87,9 @@ void PianoCanvas::addItem(Part* part, Event& event) int diff = event.tick()-part->lenTick(); if (diff > 0) {// too short part? extend it //printf("addItem - this code should not be run!\n"); - //Part* newPart = part->clone(); + //MusECore::Part* newPart = part->clone(); //newPart->setLenTick(newPart->lenTick()+diff); - //audio->msgChangePart(part, newPart,false); + //MusEGlobal::audio->msgChangePart(part, newPart,false); //part = newPart; part->setLenTick(part->lenTick()+diff); } @@ -104,10 +106,10 @@ PianoCanvas::PianoCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy) playedPitch = -1; for (int i=0;i<128;i++) noteHeldDown[i]=false; - steprec=new StepRec(noteHeldDown); + steprec=new MusECore::StepRec(noteHeldDown); songChanged(SC_TRACK_INSERTED); - connect(song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int))); + connect(MusEGlobal::song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int))); } PianoCanvas::~PianoCanvas() @@ -160,7 +162,7 @@ int PianoCanvas::y2pitch(int y) const // draws a note //--------------------------------------------------------- -void PianoCanvas::drawItem(QPainter& p, const MusEWidget::CItem* item, +void PianoCanvas::drawItem(QPainter& p, const MusEGui::CItem* item, const QRect& rect) { QRect r = item->bbox(); @@ -205,7 +207,7 @@ void PianoCanvas::drawItem(QPainter& p, const MusEWidget::CItem* item, QColor color; NEvent* nevent = (NEvent*) item; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); if (nevent->part() != curPart){ if(item->isMoving()) color = Qt::gray; @@ -265,7 +267,7 @@ void PianoCanvas::drawItem(QPainter& p, const MusEWidget::CItem* item, //int mfh = mh; //if(mfh == meh) mfh -= 1; //if(mfy == mey) mfh -= 1; - color.setAlpha(MusEConfig::config.globalAlphaBlend); + color.setAlpha(MusEGlobal::config.globalAlphaBlend); //QLinearGradient gradient(mex + 1, mey + 1, mex + 1, mey + meh - 2); // Inside the border //gradient.setColorAt(0, color); //gradient.setColorAt(1, color.darker()); @@ -299,7 +301,7 @@ void PianoCanvas::drawTopItem(QPainter& , const QRect&) // draws moving items //--------------------------------------------------------- -void PianoCanvas::drawMoving(QPainter& p, const MusEWidget::CItem* item, const QRect& rect) +void PianoCanvas::drawMoving(QPainter& p, const MusEGui::CItem* item, const QRect& rect) { //if(((NEvent*)item)->part() != curPart) // return; @@ -320,7 +322,7 @@ void PianoCanvas::drawMoving(QPainter& p, const MusEWidget::CItem* item, const Q void PianoCanvas::viewMouseDoubleClickEvent(QMouseEvent* event) { - if ((_tool != MusEWidget::PointerTool) && (event->button() != Qt::LeftButton)) { + if ((_tool != MusEGui::PointerTool) && (event->button() != Qt::LeftButton)) { mousePress(event); return; } @@ -330,24 +332,24 @@ void PianoCanvas::viewMouseDoubleClickEvent(QMouseEvent* event) // moveCanvasItems //--------------------------------------------------------- -Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, DragType dtype) +MusECore::Undo PianoCanvas::moveCanvasItems(MusEGui::CItemList& items, int dp, int dx, DragType dtype) { if(editor->parts()->empty()) - return Undo(); //return empty list + return MusECore::Undo(); //return empty list - PartsToChangeMap parts2change; - Undo operations; + MusECore::PartsToChangeMap parts2change; + MusECore::Undo operations; - for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) + for(MusECore::iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) { - Part* part = ip->second; + MusECore::Part* part = ip->second; if(!part) continue; int npartoffset = 0; - for(MusEWidget::iCItem ici = items.begin(); ici != items.end(); ++ici) + for(MusEGui::iCItem ici = items.begin(); ici != items.end(); ++ici) { - MusEWidget::CItem* ci = ici->second; + MusEGui::CItem* ci = ici->second; if(ci->part() != part) continue; @@ -357,7 +359,7 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, // Test moving the item... NEvent* nevent = (NEvent*) ci; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); x = newpos.x(); if(x < 0) x = 0; @@ -373,11 +375,11 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, if(npartoffset > 0) { - iPartToChange ip2c = parts2change.find(part); + MusECore::iPartToChange ip2c = parts2change.find(part); if(ip2c == parts2change.end()) { - PartToChange p2c = {0, npartoffset}; - parts2change.insert(std::pair<Part*, PartToChange> (part, p2c)); + MusECore::PartToChange p2c = {0, npartoffset}; + parts2change.insert(std::pair<MusECore::Part*, MusECore::PartToChange> (part, p2c)); } else ip2c->second.xdiff = npartoffset; @@ -385,9 +387,9 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, } bool forbidden=false; - for(iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) + for(MusECore::iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) { - Part* opart = ip2c->first; + MusECore::Part* opart = ip2c->first; if (opart->hasHiddenEvents()) { forbidden=true; @@ -398,12 +400,12 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, if (!forbidden) { - std::vector< MusEWidget::CItem* > doneList; - typedef std::vector< MusEWidget::CItem* >::iterator iDoneList; + std::vector< MusEGui::CItem* > doneList; + typedef std::vector< MusEGui::CItem* >::iterator iDoneList; - for(MusEWidget::iCItem ici = items.begin(); ici != items.end(); ++ici) + for(MusEGui::iCItem ici = items.begin(); ici != items.end(); ++ici) { - MusEWidget::CItem* ci = ici->second; + MusEGui::CItem* ci = ici->second; int x = ci->pos().x(); int y = ci->pos().y(); @@ -433,9 +435,9 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, selectItem(ci, false); } - for(iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) + for(MusECore::iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c) { - Part* opart = ip2c->first; + MusECore::Part* opart = ip2c->first; int diff = ip2c->second.xdiff; schedule_resize_all_same_len_clone_parts(opart, opart->lenTick() + diff, operations); @@ -445,7 +447,7 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, } else { - return Undo(); //return empty list + return MusECore::Undo(); //return empty list } } @@ -454,12 +456,12 @@ Undo PianoCanvas::moveCanvasItems(MusEWidget::CItemList& items, int dp, int dx, // called after moving an object //--------------------------------------------------------- -UndoOp PianoCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragType dtype) +MusECore::UndoOp PianoCanvas::moveItem(MusEGui::CItem* item, const QPoint& pos, DragType dtype) { NEvent* nevent = (NEvent*) item; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); int npitch = y2pitch(pos.y()); - Event newEvent = event.clone(); + MusECore::Event newEvent = event.clone(); int x = pos.x(); if (x < 0) x = 0; @@ -467,15 +469,15 @@ UndoOp PianoCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragTyp int port = track()->outPort(); int channel = track()->outChannel(); // release note: - MidiPlayEvent ev1(0, port, channel, 0x90, event.pitch() + track()->transposition, 0); - audio->msgPlayMidiEvent(&ev1); - MidiPlayEvent ev2(0, port, channel, 0x90, npitch + track()->transposition, event.velo()); - audio->msgPlayMidiEvent(&ev2); + MusECore::MidiPlayEvent ev1(0, port, channel, 0x90, event.pitch() + track()->transposition, 0); + MusEGlobal::audio->msgPlayMidiEvent(&ev1); + MusECore::MidiPlayEvent ev2(0, port, channel, 0x90, npitch + track()->transposition, event.velo()); + MusEGlobal::audio->msgPlayMidiEvent(&ev2); } // Changed by T356. - Part* part = nevent->part(); // - //Part* part = Canvas::part(); // part can be dynamically recreated, ask the authority + MusECore::Part* part = nevent->part(); // + //MusECore::Part* part = Canvas::part(); // part can be dynamically recreated, ask the authority newEvent.setPitch(npitch); int ntick = editor->rasterVal(x) - part->tick(); @@ -490,16 +492,16 @@ UndoOp PianoCanvas::moveItem(MusEWidget::CItem* item, const QPoint& pos, DragTyp // printf("PianoCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData()); if (dtype == MOVE_COPY || dtype == MOVE_CLONE) - return UndoOp(UndoOp::AddEvent, newEvent, part, false, false); + return MusECore::UndoOp(MusECore::UndoOp::AddEvent, newEvent, part, false, false); else - return UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false); + return MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false); } //--------------------------------------------------------- // newItem(p, state) //--------------------------------------------------------- -MusEWidget::CItem* PianoCanvas::newItem(const QPoint& p, int) +MusEGui::CItem* PianoCanvas::newItem(const QPoint& p, int) { //printf("newItem point\n"); int pitch = y2pitch(p.y()); @@ -508,7 +510,7 @@ MusEWidget::CItem* PianoCanvas::newItem(const QPoint& p, int) tick -= curPart->tick(); if (tick < 0) tick=0; - Event e = Event(Note); + MusECore::Event e = MusECore::Event(MusECore::Note); e.setTick(tick); e.setPitch(pitch); e.setVelo(curVelo); @@ -516,11 +518,11 @@ MusEWidget::CItem* PianoCanvas::newItem(const QPoint& p, int) return new NEvent(e, curPart, pitch2y(pitch)); } -void PianoCanvas::newItem(MusEWidget::CItem* item, bool noSnap) +void PianoCanvas::newItem(MusEGui::CItem* item, bool noSnap) { //printf("newItem citem\n"); NEvent* nevent = (NEvent*) item; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); int x = item->x(); if (x<0) x=0; @@ -532,17 +534,17 @@ void PianoCanvas::newItem(MusEWidget::CItem* item, bool noSnap) if (w == 0) w = editor->raster(); } - Part* part = nevent->part(); + MusECore::Part* part = nevent->part(); event.setTick(x - part->tick()); event.setLenTick(w); event.setPitch(y2pitch(item->y())); - Undo operations; + MusECore::Undo operations; int diff = event.endTick()-part->lenTick(); if (! ((diff > 0) && part->hasHiddenEvents()) ) //operation is allowed { - operations.push_back(UndoOp(UndoOp::AddEvent,event, part, false, false)); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddEvent,event, part, false, false)); if (diff > 0)// part must be extended? { @@ -550,7 +552,7 @@ void PianoCanvas::newItem(MusEWidget::CItem* item, bool noSnap) printf("newItem: extending\n"); } - song->applyOperationGroup(operations); + MusEGlobal::song->applyOperationGroup(operations); } //else forbid action by not applying it else @@ -562,33 +564,33 @@ void PianoCanvas::newItem(MusEWidget::CItem* item, bool noSnap) // resizeItem //--------------------------------------------------------- -void PianoCanvas::resizeItem(MusEWidget::CItem* item, bool noSnap, bool) // experimental changes to try dynamically extending parts +void PianoCanvas::resizeItem(MusEGui::CItem* item, bool noSnap, bool) // experimental changes to try dynamically extending parts { //printf("resizeItem!\n"); NEvent* nevent = (NEvent*) item; - Event event = nevent->event(); - Event newEvent = event.clone(); + MusECore::Event event = nevent->event(); + MusECore::Event newEvent = event.clone(); int len; - Part* part = nevent->part(); + MusECore::Part* part = nevent->part(); if (noSnap) len = nevent->width(); else { - //Part* part = nevent->part(); + //MusECore::Part* part = nevent->part(); unsigned tick = event.tick() + part->tick(); len = editor->rasterVal(tick + nevent->width()) - tick; if (len <= 0) len = editor->raster(); } - Undo operations; + MusECore::Undo operations; int diff = event.tick()+len-part->lenTick(); if (! ((diff > 0) && part->hasHiddenEvents()) ) //operation is allowed { newEvent.setLenTick(len); - operations.push_back(UndoOp(UndoOp::ModifyEvent,newEvent, event, nevent->part(), false, false)); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent,newEvent, event, nevent->part(), false, false)); if (diff > 0)// part must be extended? { @@ -597,7 +599,7 @@ void PianoCanvas::resizeItem(MusEWidget::CItem* item, bool noSnap, bool) } } //else forbid action by not performing it - song->applyOperationGroup(operations); + MusEGlobal::song->applyOperationGroup(operations); songChanged(SC_EVENT_MODIFIED); //this forces an update of the itemlist, which is neccessary //to remove "forbidden" events from the list again } @@ -606,13 +608,13 @@ void PianoCanvas::resizeItem(MusEWidget::CItem* item, bool noSnap, bool) // deleteItem //--------------------------------------------------------- -bool PianoCanvas::deleteItem(MusEWidget::CItem* item) +bool PianoCanvas::deleteItem(MusEGui::CItem* item) { NEvent* nevent = (NEvent*) item; if (nevent->part() == curPart) { - Event ev = nevent->event(); + MusECore::Event ev = nevent->event(); // Indicate do undo, and do not do port controller values and clone parts. - audio->msgDeleteEvent(ev, curPart, true, false, false); + MusEGlobal::audio->msgDeleteEvent(ev, curPart, true, false, false); return true; } return false; @@ -635,15 +637,15 @@ void PianoCanvas::pianoCmd(int cmd) } if(spos < 0) spos = 0; - Pos p(spos,true); - song->setPos(0, p, true, true, true); + MusECore::Pos p(spos,true); + MusEGlobal::song->setPos(0, p, true, true, true); } break; case CMD_RIGHT: { int spos = AL::sigmap.raster2(pos[0] + 1, editor->rasterStep(pos[0])); // Nudge by +1, then snap up with raster2. - Pos p(spos,true); - song->setPos(0, p, true, true, true); + MusECore::Pos p(spos,true); + MusEGlobal::song->setPos(0, p, true, true, true); } break; case CMD_LEFT_NOSNAP: @@ -651,68 +653,68 @@ void PianoCanvas::pianoCmd(int cmd) int spos = pos[0] - editor->rasterStep(pos[0]); if (spos < 0) spos = 0; - Pos p(spos,true); - song->setPos(0, p, true, true, true); //CDW + MusECore::Pos p(spos,true); + MusEGlobal::song->setPos(0, p, true, true, true); //CDW } break; case CMD_RIGHT_NOSNAP: { - Pos p(pos[0] + editor->rasterStep(pos[0]), true); - song->setPos(0, p, true, true, true); //CDW + MusECore::Pos p(pos[0] + editor->rasterStep(pos[0]), true); + MusEGlobal::song->setPos(0, p, true, true, true); //CDW } break; case CMD_INSERT: { if (pos[0] < start() || pos[0] >= end()) break; - MidiPart* part = (MidiPart*)curPart; + MusECore::MidiPart* part = (MusECore::MidiPart*)curPart; if (part == 0) break; - EventList* el = part->events(); - Undo operations; + MusECore::EventList* el = part->events(); + MusECore::Undo operations; - std::list <Event> elist; - for (iEvent e = el->lower_bound(pos[0] - part->tick()); e != el->end(); ++e) - elist.push_back((Event)e->second); - for (std::list<Event>::iterator i = elist.begin(); i != elist.end(); ++i) { - Event event = *i; - Event newEvent = event.clone(); + std::list <MusECore::Event> elist; + for (MusECore::iEvent e = el->lower_bound(pos[0] - part->tick()); e != el->end(); ++e) + elist.push_back((MusECore::Event)e->second); + for (std::list<MusECore::Event>::iterator i = elist.begin(); i != elist.end(); ++i) { + MusECore::Event event = *i; + MusECore::Event newEvent = event.clone(); newEvent.setTick(event.tick() + editor->raster());// - part->tick()); // Do not do port controller values and clone parts. - operations.push_back(UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false)); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false)); } - song->applyOperationGroup(operations); + MusEGlobal::song->applyOperationGroup(operations); - Pos p(editor->rasterVal(pos[0] + editor->rasterStep(pos[0])), true); - song->setPos(0, p, true, false, true); + MusECore::Pos p(editor->rasterVal(pos[0] + editor->rasterStep(pos[0])), true); + MusEGlobal::song->setPos(0, p, true, false, true); } return; case CMD_BACKSPACE: if (pos[0] < start() || pos[0] >= end()) break; { - MidiPart* part = (MidiPart*)curPart; + MusECore::MidiPart* part = (MusECore::MidiPart*)curPart; if (part == 0) break; - Undo operations; - EventList* el = part->events(); - - std::list<Event> elist; - for (iEvent e = el->lower_bound(pos[0]); e != el->end(); ++e) - elist.push_back((Event)e->second); - for (std::list<Event>::iterator i = elist.begin(); i != elist.end(); ++i) { - Event event = *i; - Event newEvent = event.clone(); + MusECore::Undo operations; + MusECore::EventList* el = part->events(); + + std::list<MusECore::Event> elist; + for (MusECore::iEvent e = el->lower_bound(pos[0]); e != el->end(); ++e) + elist.push_back((MusECore::Event)e->second); + for (std::list<MusECore::Event>::iterator i = elist.begin(); i != elist.end(); ++i) { + MusECore::Event event = *i; + MusECore::Event newEvent = event.clone(); newEvent.setTick(event.tick() - editor->raster() - part->tick()); // Do not do port controller values and clone parts. - operations.push_back(UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false)); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false)); } - song->applyOperationGroup(operations); - Pos p(editor->rasterVal(pos[0] - editor->rasterStep(pos[0])), true); - song->setPos(0, p, true, false, true); + MusEGlobal::song->applyOperationGroup(operations); + MusECore::Pos p(editor->rasterVal(pos[0] - editor->rasterStep(pos[0])), true); + MusEGlobal::song->setPos(0, p, true, false, true); } break; } @@ -729,8 +731,8 @@ void PianoCanvas::pianoPressed(int pitch, int velocity, bool shift) pitch += track()->transposition; // play note: - MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); - audio->msgPlayMidiEvent(&e); + MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity); + MusEGlobal::audio->msgPlayMidiEvent(&e); if (_steprec && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && curPart) steprec->record(curPart,pitch,editor->raster(),editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,shift); @@ -747,8 +749,8 @@ void PianoCanvas::pianoReleased(int pitch, bool) pitch += track()->transposition; // release key: - MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); - audio->msgPlayMidiEvent(&e); + MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, 0); + MusEGlobal::audio->msgPlayMidiEvent(&e); } //--------------------------------------------------------- @@ -830,7 +832,7 @@ void PianoCanvas::cmd(int cmd) { switch (cmd) { case CMD_SELECT_ALL: // select all - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (MusEGui::iCItem k = items.begin(); k != items.end(); ++k) { if (!k->second->isSelected()) selectItem(k->second, true); } @@ -839,29 +841,29 @@ void PianoCanvas::cmd(int cmd) deselectAll(); break; case CMD_SELECT_INVERT: // invert selection - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (MusEGui::iCItem k = items.begin(); k != items.end(); ++k) { selectItem(k->second, !k->second->isSelected()); } break; case CMD_SELECT_ILOOP: // select inside loop - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (MusEGui::iCItem k = items.begin(); k != items.end(); ++k) { NEvent* nevent = (NEvent*)(k->second); - Part* part = nevent->part(); - Event event = nevent->event(); + MusECore::Part* part = nevent->part(); + MusECore::Event event = nevent->event(); unsigned tick = event.tick() + part->tick(); - if (tick < song->lpos() || tick >= song->rpos()) + if (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()) selectItem(k->second, false); else selectItem(k->second, true); } break; case CMD_SELECT_OLOOP: // select outside loop - for (MusEWidget::iCItem k = items.begin(); k != items.end(); ++k) { + for (MusEGui::iCItem k = items.begin(); k != items.end(); ++k) { NEvent* nevent = (NEvent*)(k->second); - Part* part = nevent->part(); - Event event = nevent->event(); + MusECore::Part* part = nevent->part(); + MusECore::Event event = nevent->event(); unsigned tick = event.tick() + part->tick(); - if (tick < song->lpos() || tick >= song->rpos()) + if (tick < MusEGlobal::song->lpos() || tick >= MusEGlobal::song->rpos()) selectItem(k->second, true); else selectItem(k->second, false); @@ -869,10 +871,10 @@ void PianoCanvas::cmd(int cmd) break; case CMD_SELECT_PREV_PART: // select previous part { - Part* pt = editor->curCanvasPart(); - Part* newpt = pt; - PartList* pl = editor->parts(); - for(iPart ip = pl->begin(); ip != pl->end(); ++ip) + MusECore::Part* pt = editor->curCanvasPart(); + MusECore::Part* newpt = pt; + MusECore::PartList* pl = editor->parts(); + for(MusECore::iPart ip = pl->begin(); ip != pl->end(); ++ip) if(ip->second == pt) { if(ip == pl->begin()) @@ -887,10 +889,10 @@ void PianoCanvas::cmd(int cmd) break; case CMD_SELECT_NEXT_PART: // select next part { - Part* pt = editor->curCanvasPart(); - Part* newpt = pt; - PartList* pl = editor->parts(); - for(iPart ip = pl->begin(); ip != pl->end(); ++ip) + MusECore::Part* pt = editor->curCanvasPart(); + MusECore::Part* newpt = pt; + MusECore::PartList* pl = editor->parts(); + for(MusECore::iPart ip = pl->begin(); ip != pl->end(); ++ip) if(ip->second == pt) { ++ip; @@ -946,7 +948,7 @@ void PianoCanvas::midiNote(int pitch, int velo) } if (_midiin && _steprec && curPart - && !audio->isPlaying() && velo && pos[0] >= start_tick + && !MusEGlobal::audio->isPlaying() && velo && pos[0] >= start_tick /* && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */ && !(MusEGlobal::globalKeyState & Qt::AltModifier)) { steprec->record(curPart,pitch,editor->raster(),editor->raster(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); @@ -958,7 +960,7 @@ void PianoCanvas::midiNote(int pitch, int velo) // startDrag //--------------------------------------------------------- -void PianoCanvas::startDrag(MusEWidget::CItem* /* item*/, bool copymode) +void PianoCanvas::startDrag(MusEGui::CItem* /* item*/, bool copymode) { QMimeData* md = selected_events_to_mime(partlist_to_set(editor->parts()), 1); @@ -1010,7 +1012,7 @@ void PianoCanvas::dragLeaveEvent(QDragLeaveEvent*) // itemPressed //--------------------------------------------------------- -void PianoCanvas::itemPressed(const MusEWidget::CItem* item) +void PianoCanvas::itemPressed(const MusEGui::CItem* item) { if (!_playEvents) return; @@ -1018,20 +1020,20 @@ void PianoCanvas::itemPressed(const MusEWidget::CItem* item) int port = track()->outPort(); int channel = track()->outChannel(); NEvent* nevent = (NEvent*) item; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); playedPitch = event.pitch() + track()->transposition; int velo = event.velo(); // play note: - MidiPlayEvent e(0, port, channel, 0x90, playedPitch, velo); - audio->msgPlayMidiEvent(&e); + MusECore::MidiPlayEvent e(0, port, channel, 0x90, playedPitch, velo); + MusEGlobal::audio->msgPlayMidiEvent(&e); } //--------------------------------------------------------- // itemReleased //--------------------------------------------------------- -void PianoCanvas::itemReleased(const MusEWidget::CItem*, const QPoint&) +void PianoCanvas::itemReleased(const MusEGui::CItem*, const QPoint&) { if (!_playEvents) return; @@ -1039,8 +1041,8 @@ void PianoCanvas::itemReleased(const MusEWidget::CItem*, const QPoint&) int channel = track()->outChannel(); // release note: - MidiPlayEvent ev(0, port, channel, 0x90, playedPitch, 0); - audio->msgPlayMidiEvent(&ev); + MusECore::MidiPlayEvent ev(0, port, channel, 0x90, playedPitch, 0); + MusEGlobal::audio->msgPlayMidiEvent(&ev); playedPitch = -1; } @@ -1048,21 +1050,21 @@ void PianoCanvas::itemReleased(const MusEWidget::CItem*, const QPoint&) // itemMoved //--------------------------------------------------------- -void PianoCanvas::itemMoved(const MusEWidget::CItem* item, const QPoint& pos) +void PianoCanvas::itemMoved(const MusEGui::CItem* item, const QPoint& pos) { int npitch = y2pitch(pos.y()); if ((playedPitch != -1) && (playedPitch != npitch)) { int port = track()->outPort(); int channel = track()->outChannel(); NEvent* nevent = (NEvent*) item; - Event event = nevent->event(); + MusECore::Event event = nevent->event(); // release note: - MidiPlayEvent ev1(0, port, channel, 0x90, playedPitch, 0); - audio->msgPlayMidiEvent(&ev1); + MusECore::MidiPlayEvent ev1(0, port, channel, 0x90, playedPitch, 0); + MusEGlobal::audio->msgPlayMidiEvent(&ev1); // play note: - MidiPlayEvent e2(0, port, channel, 0x90, npitch + track()->transposition, event.velo()); - audio->msgPlayMidiEvent(&e2); + MusECore::MidiPlayEvent e2(0, port, channel, 0x90, npitch + track()->transposition, event.velo()); + MusEGlobal::audio->msgPlayMidiEvent(&e2); playedPitch = npitch + track()->transposition; } } @@ -1080,23 +1082,23 @@ void PianoCanvas::curPartChanged() // modifySelected //--------------------------------------------------------- -void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) +void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta) { - audio->msgIdle(true); - song->startUndo(); - for (MusEWidget::iCItem i = items.begin(); i != items.end(); ++i) { + MusEGlobal::audio->msgIdle(true); + MusEGlobal::song->startUndo(); + for (MusEGui::iCItem i = items.begin(); i != items.end(); ++i) { if (!(i->second->isSelected())) continue; NEvent* e = (NEvent*)(i->second); - Event event = e->event(); - if (event.type() != Note) + MusECore::Event event = e->event(); + if (event.type() != MusECore::Note) continue; - MidiPart* part = (MidiPart*)(e->part()); - Event newEvent = event.clone(); + MusECore::MidiPart* part = (MusECore::MidiPart*)(e->part()); + MusECore::Event newEvent = event.clone(); switch (type) { - case MusEWidget::NoteInfo::VAL_TIME: + case MusEGui::NoteInfo::VAL_TIME: { int newTime = event.tick() + delta; if (newTime < 0) @@ -1104,7 +1106,7 @@ void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) newEvent.setTick(newTime); } break; - case MusEWidget::NoteInfo::VAL_LEN: + case MusEGui::NoteInfo::VAL_LEN: { int len = event.lenTick() + delta; if (len < 1) @@ -1112,7 +1114,7 @@ void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) newEvent.setLenTick(len); } break; - case MusEWidget::NoteInfo::VAL_VELON: + case MusEGui::NoteInfo::VAL_VELON: { int velo = event.velo() + delta; if (velo > 127) @@ -1122,7 +1124,7 @@ void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) newEvent.setVelo(velo); } break; - case MusEWidget::NoteInfo::VAL_VELOFF: + case MusEGui::NoteInfo::VAL_VELOFF: { int velo = event.veloOff() + delta; if (velo > 127) @@ -1132,7 +1134,7 @@ void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) newEvent.setVeloOff(velo); } break; - case MusEWidget::NoteInfo::VAL_PITCH: + case MusEGui::NoteInfo::VAL_PITCH: { int pitch = event.pitch() + delta; if (pitch > 127) @@ -1143,13 +1145,13 @@ void PianoCanvas::modifySelected(MusEWidget::NoteInfo::ValType type, int delta) } break; } - song->changeEvent(event, newEvent, part); + MusEGlobal::song->changeEvent(event, newEvent, part); // Indicate do not do port controller values and clone parts. - //song->addUndo(UndoOp(UndoOp::ModifyEvent, newEvent, event, part)); - song->addUndo(UndoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false)); + //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part)); + MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false)); } - song->endUndo(SC_EVENT_MODIFIED); - audio->msgIdle(false); + MusEGlobal::song->endUndo(SC_EVENT_MODIFIED); + MusEGlobal::audio->msgIdle(false); } //--------------------------------------------------------- @@ -1163,3 +1165,4 @@ void PianoCanvas::resizeEvent(QResizeEvent* ev) EventCanvas::resizeEvent(ev); } +} // namespace MusEGui diff --git a/muse2/muse/midiedit/prcanvas.h b/muse2/muse/midiedit/prcanvas.h index b3a8a288..18d4f130 100644 --- a/muse2/muse/midiedit/prcanvas.h +++ b/muse2/muse/midiedit/prcanvas.h @@ -36,19 +36,22 @@ #define KH 13 +class QRect; + +namespace MusEGui { + //--------------------------------------------------------- // NEvent // ''visual'' Note Event //--------------------------------------------------------- -class NEvent : public MusEWidget::CItem { +class NEvent : public CItem { public: - NEvent(Event& e, Part* p, int y); + NEvent(MusECore::Event& e, MusECore::Part* p, int y); }; class ScrollScale; class PianoRoll; -class QRect; //--------------------------------------------------------- // PianoCanvas @@ -62,31 +65,31 @@ class PianoCanvas : public EventCanvas { bool noteHeldDown[128]; - StepRec* steprec; + MusECore::StepRec* steprec; virtual void viewMouseDoubleClickEvent(QMouseEvent*); - virtual void drawItem(QPainter&, const MusEWidget::CItem*, const QRect&); + virtual void drawItem(QPainter&, const CItem*, const QRect&); void drawTopItem(QPainter &p, const QRect &rect); - virtual void drawMoving(QPainter&, const MusEWidget::CItem*, const QRect&); - virtual Undo moveCanvasItems(MusEWidget::CItemList&, int, int, DragType); - virtual UndoOp moveItem(MusEWidget::CItem*, const QPoint&, DragType); - virtual MusEWidget::CItem* newItem(const QPoint&, int); - virtual void resizeItem(MusEWidget::CItem*, bool noSnap, bool); - virtual void newItem(MusEWidget::CItem*, bool noSnap); - virtual bool deleteItem(MusEWidget::CItem*); - virtual void startDrag(MusEWidget::CItem* item, bool copymode); + virtual void drawMoving(QPainter&, const CItem*, const QRect&); + virtual MusECore::Undo moveCanvasItems(CItemList&, int, int, DragType); + virtual MusECore::UndoOp moveItem(CItem*, const QPoint&, DragType); + virtual CItem* newItem(const QPoint&, int); + virtual void resizeItem(CItem*, bool noSnap, bool); + virtual void newItem(CItem*, bool noSnap); + virtual bool deleteItem(CItem*); + virtual void startDrag(CItem* item, bool copymode); virtual void dragEnterEvent(QDragEnterEvent* event); virtual void dragMoveEvent(QDragMoveEvent*); virtual void dragLeaveEvent(QDragLeaveEvent*); - virtual void addItem(Part*, Event&); + virtual void addItem(MusECore::Part*, MusECore::Event&); int y2pitch(int) const; int pitch2y(int) const; virtual void drawCanvas(QPainter&, const QRect&); - virtual void itemPressed(const MusEWidget::CItem*); - virtual void itemReleased(const MusEWidget::CItem*, const QPoint&); - virtual void itemMoved(const MusEWidget::CItem*, const QPoint&); + virtual void itemPressed(const CItem*); + virtual void itemReleased(const CItem*, const QPoint&); + virtual void itemMoved(const CItem*, const QPoint&); virtual void curPartChanged(); virtual void resizeEvent(QResizeEvent*); @@ -123,7 +126,10 @@ class PianoCanvas : public EventCanvas { colorMode = mode; redraw(); } - virtual void modifySelected(MusEWidget::NoteInfo::ValType type, int delta); + virtual void modifySelected(NoteInfo::ValType type, int delta); }; + +} // namespace MusEGui + #endif diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index a06d2a8c..d09ebc34 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -78,6 +78,7 @@ using namespace std; using MusEGlobal::debugMsg; using MusEGlobal::heavyDebugMsg; +namespace MusEGui { string IntToStr(int i); QString IntToQStr(int i); @@ -196,7 +197,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) score_canvas=new ScoreCanvas(this, mainw); xscroll = new QScrollBar(Qt::Horizontal, mainw); yscroll = new QScrollBar(Qt::Vertical, mainw); - time_bar = new MusEWidget::MTScaleFlo(score_canvas, mainw); + time_bar = new MusEGui::MTScaleFlo(score_canvas, mainw); connect(xscroll, SIGNAL(valueChanged(int)), score_canvas, SLOT(x_scroll_event(int))); connect(score_canvas, SIGNAL(xscroll_changed(int)), xscroll, SLOT(setValue(int))); @@ -209,7 +210,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) connect(score_canvas, SIGNAL(canvas_height_changed(int)), SLOT(canvas_height_changed(int))); connect(score_canvas, SIGNAL(viewport_height_changed(int)), SLOT(viewport_height_changed(int))); - connect(song, SIGNAL(songChanged(int)), score_canvas, SLOT(song_changed(int))); + connect(MusEGlobal::song, SIGNAL(songChanged(int)), score_canvas, SLOT(song_changed(int))); connect(xscroll, SIGNAL(valueChanged(int)), time_bar, SLOT(set_xpos(int))); connect(score_canvas, SIGNAL(pos_add_changed()), time_bar, SLOT(pos_add_changed())); @@ -244,10 +245,10 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) connect(srec, SIGNAL(toggled(bool)), score_canvas, SLOT(set_steprec(bool))); - edit_tools = new MusEWidget::EditToolBar(this, MusEWidget::PointerTool | MusEWidget::PencilTool | MusEWidget::RubberTool); + edit_tools = new MusEGui::EditToolBar(this, MusEGui::PointerTool | MusEGui::PencilTool | MusEGui::RubberTool); addToolBar(edit_tools); - edit_tools->set(MusEWidget::PointerTool); - score_canvas->set_tool(MusEWidget::PointerTool); + edit_tools->set(MusEGui::PointerTool); + score_canvas->set_tool(MusEGui::PointerTool); connect(edit_tools, SIGNAL(toolChanged(int)), score_canvas, SLOT(set_tool(int))); QToolBar* panic_toolbar = addToolBar(tr("panic")); @@ -489,8 +490,8 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos) clipboard_changed(); selection_changed(); - connect(song, SIGNAL(songChanged(int)), SLOT(song_changed(int))); - connect(song, SIGNAL(newPartsCreated(const std::map< Part*, std::set<Part*> >&)), score_canvas, SLOT(add_new_parts(const std::map< Part*, std::set<Part*> >&))); + connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(song_changed(int))); + connect(MusEGlobal::song, SIGNAL(newPartsCreated(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&)), score_canvas, SLOT(add_new_parts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&))); score_canvas->fully_recalculate(); score_canvas->goto_tick(initPos,true); @@ -534,7 +535,7 @@ void ScoreEdit::init_shortcuts() } -void ScoreEdit::add_parts(PartList* pl, bool all_in_one) +void ScoreEdit::add_parts(MusECore::PartList* pl, bool all_in_one) { score_canvas->add_staves(pl, all_in_one); } @@ -605,7 +606,7 @@ void ScoreEdit::song_changed(int flags) { if (flags & (SC_SELECTION | SC_EVENT_MODIFIED | SC_EVENT_REMOVED)) { - map<Event*, Part*> selection=get_events(score_canvas->get_all_parts(),1); + map<MusECore::Event*, MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1); if (selection.empty()) { apply_velo_to_label->setText(APPLY_TO_NEW_STRING); @@ -616,8 +617,8 @@ void ScoreEdit::song_changed(int flags) int velo=-1; int velo_off=-1; - for (map<Event*, Part*>::iterator it=selection.begin(); it!=selection.end(); it++) - if (it->first->type()==Note) + for (map<MusECore::Event*, MusECore::Part*>::iterator it=selection.begin(); it!=selection.end(); it++) + if (it->first->type()==MusECore::Note) { if (velo==-1) velo=it->first->velo(); else if ((velo>=0) && (velo!=it->first->velo())) velo=-2; @@ -708,14 +709,14 @@ void ScoreEdit::menu_command(int cmd) erase_notes(score_canvas->get_all_parts(), 1); break; case CMD_COPY: copy_notes(score_canvas->get_all_parts(), 1); break; - case CMD_COPY_RANGE: copy_notes(score_canvas->get_all_parts(), MusEUtil::any_event_selected(score_canvas->get_all_parts()) ? 3 : 2); break; + case CMD_COPY_RANGE: copy_notes(score_canvas->get_all_parts(), MusECore::any_event_selected(score_canvas->get_all_parts()) ? 3 : 2); break; case CMD_PASTE: menu_command(CMD_SELECT_NONE); - paste_notes(3072); + MusECore::paste_notes(3072); break; case CMD_PASTE_DIALOG: menu_command(CMD_SELECT_NONE); - paste_notes(score_canvas->get_selected_part()); + MusECore::paste_notes(score_canvas->get_selected_part()); break; case CMD_QUANTIZE: quantize_notes(score_canvas->get_all_parts()); break; case CMD_VELOCITY: modify_velocity(score_canvas->get_all_parts()); break; @@ -751,22 +752,22 @@ void ScoreEdit::selection_changed() //duplicated from songfile.cpp's MusE::readPart(); the only differences: //"none" is supported and tag_name is settable -Part* read_part(Xml& xml, QString tag_name="part") +MusECore::Part* read_part(MusECore::Xml& xml, QString tag_name="part") { - Part* part = 0; + MusECore::Part* part = 0; for (;;) { - Xml::Token token = xml.parse(); + MusECore::Xml::Token token = xml.parse(); const QString& tag = xml.s1(); switch (token) { - case Xml::Error: - case Xml::End: + case MusECore::Xml::Error: + case MusECore::Xml::End: return part; - case Xml::Text: + case MusECore::Xml::Text: { int trackIdx, partIdx; if (tag=="none") @@ -775,7 +776,7 @@ Part* read_part(Xml& xml, QString tag_name="part") { sscanf(tag.toLatin1().constData(), "%d:%d", &trackIdx, &partIdx); if (debugMsg) cout << "read_part: trackIdx="<<trackIdx<<", partIdx="<<partIdx; - Track* track = song->tracks()->index(trackIdx); + MusECore::Track* track = MusEGlobal::song->tracks()->index(trackIdx); if (track) part = track->parts()->find(partIdx); if (debugMsg) cout << ", track="<<track<<", part="<<part<<endl; @@ -783,11 +784,11 @@ Part* read_part(Xml& xml, QString tag_name="part") } break; - case Xml::TagStart: + case MusECore::Xml::TagStart: xml.unknown("read_part"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == tag_name) return part; @@ -799,24 +800,24 @@ Part* read_part(Xml& xml, QString tag_name="part") -void staff_t::read_status(Xml& xml) +void staff_t::read_status(MusECore::Xml& xml) { for (;;) { - Xml::Token token = xml.parse(); - if (token == Xml::Error || token == Xml::End) + MusECore::Xml::Token token = xml.parse(); + if (token == MusECore::Xml::Error || token == MusECore::Xml::End) break; const QString& tag = xml.s1(); switch (token) { - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "type") type = staff_type_t(xml.parseInt()); else if (tag == "clef") clef = clef_t(xml.parseInt()); else if (tag == "part") { - Part* part=read_part(xml); + MusECore::Part* part=read_part(xml); if (part) parts.insert(part); else @@ -826,7 +827,7 @@ void staff_t::read_status(Xml& xml) xml.unknown("staff"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "staff") goto staff_readstatus_end; @@ -840,15 +841,15 @@ void staff_t::read_status(Xml& xml) } -void staff_t::write_status(int level, Xml& xml) const +void staff_t::write_status(int level, MusECore::Xml& xml) const { xml.tag(level++, "staff"); xml.intTag(level, "type", type); xml.intTag(level, "clef", clef); - for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++) + for (set<MusECore::Part*>::iterator part=parts.begin(); part!=parts.end(); part++) { - Track* track = (*part)->track(); - int trkIdx = song->tracks()->index(track); + MusECore::Track* track = (*part)->track(); + int trkIdx = MusEGlobal::song->tracks()->index(track); int partIdx = track->parts()->index(*part); if((trkIdx == -1) || (partIdx == -1)) @@ -863,7 +864,7 @@ void staff_t::write_status(int level, Xml& xml) const // writeStatus //--------------------------------------------------------- -void ScoreEdit::writeStatus(int level, Xml& xml) const +void ScoreEdit::writeStatus(int level, MusECore::Xml& xml) const { xml.tag(level++, "scoreedit"); TopWin::writeStatus(level, xml); @@ -910,15 +911,15 @@ void ScoreEdit::writeStatus(int level, Xml& xml) const xml.intTag(level, "preambleContainsKeysig", preamble_keysig_action->isChecked()); xml.intTag(level, "preambleContainsTimesig", preamble_timesig_action->isChecked()); - Part* selected_part=score_canvas->get_selected_part(); + MusECore::Part* selected_part=score_canvas->get_selected_part(); if (selected_part==NULL) { xml.put(level, "<selectedPart>none</selectedPart>"); } else { - Track* track = selected_part->track(); - int trkIdx = song->tracks()->index(track); + MusECore::Track* track = selected_part->track(); + int trkIdx = MusEGlobal::song->tracks()->index(track); int partIdx = track->parts()->index(selected_part); if((trkIdx == -1) || (partIdx == -1)) @@ -933,7 +934,7 @@ void ScoreEdit::writeStatus(int level, Xml& xml) const xml.tag(level, "/scoreedit"); } -void ScoreCanvas::write_staves(int level, Xml& xml) const +void ScoreCanvas::write_staves(int level, MusECore::Xml& xml) const { for (list<staff_t>::const_iterator staff=staves.begin(); staff!=staves.end(); staff++) staff->write_status(level, xml); @@ -944,21 +945,21 @@ void ScoreCanvas::write_staves(int level, Xml& xml) const // readStatus //--------------------------------------------------------- -void ScoreEdit::readStatus(Xml& xml) +void ScoreEdit::readStatus(MusECore::Xml& xml) { bool apply_velo_temp=apply_velo; apply_velo=false; for (;;) { - Xml::Token token = xml.parse(); - if (token == Xml::Error || token == Xml::End) + MusECore::Xml::Token token = xml.parse(); + if (token == MusECore::Xml::Error || token == MusECore::Xml::End) break; const QString& tag = xml.s1(); switch (token) { - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "name") set_name(xml.parse1()); else if (tag == "tool") @@ -1031,7 +1032,7 @@ void ScoreEdit::readStatus(Xml& xml) xml.unknown("ScoreEdit"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "scoreedit") return; @@ -1042,25 +1043,25 @@ void ScoreEdit::readStatus(Xml& xml) apply_velo=apply_velo_temp; } -void ScoreEdit::read_configuration(Xml& xml) +void ScoreEdit::read_configuration(MusECore::Xml& xml) { for (;;) { - Xml::Token token = xml.parse(); - if (token == Xml::Error || token == Xml::End) + MusECore::Xml::Token token = xml.parse(); + if (token == MusECore::Xml::Error || token == MusECore::Xml::End) break; const QString& tag = xml.s1(); switch (token) { - case Xml::TagStart: + case MusECore::Xml::TagStart: if (tag == "topwin") TopWin::readConfiguration(SCORE, xml); else xml.unknown("ScoreEdit"); break; - case Xml::TagEnd: + case MusECore::Xml::TagEnd: if (tag == "scoreedit") return; @@ -1071,7 +1072,7 @@ void ScoreEdit::read_configuration(Xml& xml) } -void ScoreEdit::write_configuration(int level, Xml& xml) +void ScoreEdit::write_configuration(int level, MusECore::Xml& xml) { xml.tag(level++, "scoreedit"); TopWin::writeConfiguration(SCORE, level, xml); @@ -1081,7 +1082,7 @@ void ScoreEdit::write_configuration(int level, Xml& xml) -void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) +void ScoreCanvas::add_staves(MusECore::PartList* pl, bool all_in_one) { if (!pl->empty()) { @@ -1089,12 +1090,12 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) if (all_in_one) { - clefTypes clef=((MidiTrack*)pl->begin()->second->track())->getClef(); + clefTypes clef=((MusECore::MidiTrack*)pl->begin()->second->track())->getClef(); staff.parts.clear(); - for (ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++) + for (MusECore::ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++) { - if (((MidiTrack*)part_it->second->track())->getClef() != clef) + if (((MusECore::MidiTrack*)part_it->second->track())->getClef() != clef) clef=grandStaff; staff.parts.insert(part_it->second); @@ -1129,25 +1130,25 @@ void ScoreCanvas::add_staves(PartList* pl, bool all_in_one) } else { - set<Track*> tracks; - for (ciPart it=pl->begin(); it!=pl->end(); it++) + set<MusECore::Track*> tracks; + for (MusECore::ciPart it=pl->begin(); it!=pl->end(); it++) tracks.insert(it->second->track()); - TrackList* tracklist = song->tracks(); + MusECore::TrackList* tracklist = MusEGlobal::song->tracks(); // this loop is used for inserting track-staves in the // correct order. simply iterating through tracks's contents // would sort after the pointer values, i.e. randomly - for (ciTrack track_it=tracklist->begin(); track_it!=tracklist->end(); track_it++) + for (MusECore::ciTrack track_it=tracklist->begin(); track_it!=tracklist->end(); track_it++) if (tracks.find(*track_it)!=tracks.end()) { staff.parts.clear(); - for (ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++) + for (MusECore::ciPart part_it=pl->begin(); part_it!=pl->end(); part_it++) if (part_it->second->track() == *track_it) staff.parts.insert(part_it->second); staff.cleanup_parts(); staff.update_part_indices(); - switch (((MidiTrack*)(*track_it))->getClef()) + switch (((MusECore::MidiTrack*)(*track_it))->getClef()) { case trebleClef: staff.type=NORMAL; @@ -1193,8 +1194,8 @@ ScoreCanvas::ScoreCanvas(ScoreEdit* pr, QWidget* parent_widget) : View(parent_wi srec=false; for (int i=0;i<128;i++) held_notes[i]=false; - steprec=new StepRec(held_notes); - connect(song, SIGNAL(midiNote(int, int)), SLOT(midi_note(int,int))); + steprec=new MusECore::StepRec(held_notes); + connect(MusEGlobal::song, SIGNAL(midiNote(int, int)), SLOT(midi_note(int,int))); x_pos=0; x_left=0; @@ -1235,8 +1236,8 @@ ScoreCanvas::ScoreCanvas(ScoreEdit* pr, QWidget* parent_widget) : View(parent_wi y_scroll_pos=0; connect (MusEGlobal::heartBeatTimer, SIGNAL(timeout()), SLOT(heartbeat_timer_event())); - connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(pos_changed(int,unsigned,bool))); - connect(song, SIGNAL(playChanged(bool)), SLOT(play_changed(bool))); + connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(pos_changed(int,unsigned,bool))); + connect(MusEGlobal::song, SIGNAL(playChanged(bool)), SLOT(play_changed(bool))); connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(config_changed())); @@ -1436,9 +1437,9 @@ void ScoreCanvas::move_staff_below(list<staff_t>::iterator dest, list<staff_t>:: move_staff_above(dest, src); } -set<Part*> ScoreCanvas::get_all_parts() +set<MusECore::Part*> ScoreCanvas::get_all_parts() { - set<Part*> result; + set<MusECore::Part*> result; for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++) result.insert(it->parts.begin(), it->parts.end()); @@ -1567,7 +1568,7 @@ void ScoreCanvas::init_pixmaps() mycolors[0]=Qt::black; for (int i=1;i<NUM_PARTCOLORS;i++) - mycolors[i]=MusEConfig::config.partColors[i]; + mycolors[i]=MusEGlobal::config.partColors[i]; mycolors[BLACK_PIXMAP]=Qt::black; mycolors[HIGHLIGHTED_PIXMAP]=Qt::red; mycolors[SELECTED_PIXMAP]=QColor(255,160,0); @@ -1697,14 +1698,14 @@ void staff_t::create_appropriate_eventlist() // phase one: fill the list ----------------------------------------- //insert note on events - for (set<Part*>::const_iterator part_it=parts.begin(); part_it!=parts.end(); part_it++) + for (set<MusECore::Part*>::const_iterator part_it=parts.begin(); part_it!=parts.end(); part_it++) { - Part* part=*part_it; - EventList* el=part->events(); + MusECore::Part* part=*part_it; + MusECore::EventList* el=part->events(); - for (iEvent it=el->begin(); it!=el->end(); it++) + for (MusECore::iEvent it=el->begin(); it!=el->end(); it++) { - Event& event=it->second; + MusECore::Event& event=it->second; if ( ( event.isNote() && !event.isNoteOff() && // (event.endTick() <= part->lenTick()) ) && @@ -1746,7 +1747,7 @@ void staff_t::create_appropriate_eventlist() } //insert key changes - for (iKeyEvent it=keymap.begin(); it!=keymap.end(); it++) + for (MusECore::iKeyEvent it=MusEGlobal::keymap.begin(); it!=MusEGlobal::keymap.end(); it++) eventlist.insert(pair<unsigned, FloEvent>(it->second.tick, FloEvent(it->second.tick,FloEvent::KEY_CHANGE, it->second.key ) ) ); @@ -1776,28 +1777,28 @@ void staff_t::create_appropriate_eventlist() } -bool is_sharp_key(key_enum t) +bool is_sharp_key(MusECore::key_enum t) { - return ((t>=KEY_SHARP_BEGIN) && (t<=KEY_SHARP_END)); + return ((t>=MusECore::KEY_SHARP_BEGIN) && (t<=MusECore::KEY_SHARP_END)); } -bool is_b_key(key_enum t) +bool is_b_key(MusECore::key_enum t) { - return ((t>=KEY_B_BEGIN) && (t<=KEY_B_END)); + return ((t>=MusECore::KEY_B_BEGIN) && (t<=MusECore::KEY_B_END)); } -int n_accidentials(key_enum t) +int n_accidentials(MusECore::key_enum t) { if (is_sharp_key(t)) - return t-KEY_SHARP_BEGIN-1; + return t-MusECore::KEY_SHARP_BEGIN-1; else - return t-KEY_B_BEGIN-1; + return t-MusECore::KEY_B_BEGIN-1; } //note needs to be 0..11 //always assumes violin clef //only for internal use -note_pos_t note_pos_(int note, key_enum key) +note_pos_t note_pos_(int note, MusECore::key_enum key) { note_pos_t result; //C CIS D DIS E F FIS G GIS A AIS H @@ -1826,7 +1827,7 @@ note_pos_t note_pos_(int note, key_enum key) } // Special cases for GES / FIS keys - if (key==KEY_GES) + if (key==MusECore::KEY_GES) { // convert a H to a Ces if (note==11) @@ -1835,7 +1836,7 @@ note_pos_t note_pos_(int note, key_enum key) result.vorzeichen=B; } } - else if (key==KEY_FIS) + else if (key==MusECore::KEY_FIS) { // convert a F to an Eis if (note==5) @@ -1864,7 +1865,7 @@ note_pos_t note_pos_(int note, key_enum key) // in violin clef, line 2 is E4 // in bass clef, line 2 is G2 -note_pos_t note_pos (unsigned note, key_enum key, clef_t clef) +note_pos_t note_pos (unsigned note, MusECore::key_enum key, clef_t clef) { int octave=(note/12)-1; //integer division. note is unsigned note=note%12; @@ -2170,7 +2171,7 @@ void ScoreCanvas::draw_accidentials(QPainter& p, int x, int y_offset, const list void staff_t::create_itemlist() { - key_enum tmp_key=KEY_C; + MusECore::key_enum tmp_key=MusECore::KEY_C; int lastevent=0; int next_measure=-1; int last_measure=-1; @@ -2802,7 +2803,7 @@ void ScoreCanvas::draw_note_lines(QPainter& p, int y, bool reserve_akkolade_spac void staff_t::calc_item_pos() { - key_enum curr_key=KEY_C; //this has to be KEY_C or KEY_C_B and nothing else, + MusECore::key_enum curr_key=MusECore::KEY_C; //this has to be KEY_C or KEY_C_B and nothing else, //because only with these two keys the next (initial) //key signature is properly drawn. int pos_add=0; @@ -2884,7 +2885,7 @@ void staff_t::calc_item_pos() } else if (it->type==FloItem::KEY_CHANGE) { - key_enum new_key=it->key; + MusECore::key_enum new_key=it->key; list<int> aufloes_list=calc_accidentials(curr_key, clef, new_key); list<int> new_acc_list=calc_accidentials(new_key, clef); @@ -2915,12 +2916,12 @@ void ScoreCanvas::calc_pos_add_list() //process key changes - key_enum curr_key=KEY_C; //this has to be KEY_C or KEY_C_B and nothing else, + MusECore::key_enum curr_key=MusECore::KEY_C; //this has to be KEY_C or KEY_C_B and nothing else, //because only with these two keys the next (initial) //key signature is properly calculated. - for (iKeyEvent it=keymap.begin(); it!=keymap.end(); it++) + for (MusECore::iKeyEvent it=MusEGlobal::keymap.begin(); it!=MusEGlobal::keymap.end(); it++) { - key_enum new_key=it->second.key; + MusECore::key_enum new_key=it->second.key; list<int> aufloes_list=calc_accidentials(curr_key, VIOLIN, new_key); //clef argument is unneccessary list<int> new_acc_list=calc_accidentials(new_key, VIOLIN); //in this case int n_acc_drawn=aufloes_list.size() + new_acc_list.size(); @@ -2974,7 +2975,7 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte // init accidentials properly vorzeichen_t curr_accidential[7]; vorzeichen_t default_accidential[7]; - key_enum curr_key; + MusECore::key_enum curr_key; curr_key=key_at_tick(from_it->first); list<int> new_acc_list=calc_accidentials(curr_key, staff.clef); @@ -3064,8 +3065,8 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte p.drawLine(it->x-it->pix->width()*AUX_LINE_LEN/2 -x_pos+x_left,y_offset + 2*YLEN - (i-2)*YLEN/2,it->x+it->pix->width()*AUX_LINE_LEN/2-x_pos+x_left,y_offset + 2*YLEN - (i-2)*YLEN/2); } - it->is_active= ( (song->cpos() >= it->source_event->tick() + it->source_part->tick()) && - (song->cpos() < it->source_event->endTick() + it->source_part->tick()) ); + it->is_active= ( (MusEGlobal::song->cpos() >= it->source_event->tick() + it->source_part->tick()) && + (MusEGlobal::song->cpos() < it->source_event->endTick() + it->source_part->tick()) ); int color_index; @@ -3087,7 +3088,7 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte if (it->source_event->selected()) color_index=SELECTED_PIXMAP; - if (audio->isPlaying() && it->is_active) + if (MusEGlobal::audio->isPlaying() && it->is_active) color_index=HIGHLIGHTED_PIXMAP; @@ -3187,7 +3188,7 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte } else if (it->type==FloItem::KEY_CHANGE) { - key_enum new_key=it->key; + MusECore::key_enum new_key=it->key; if (heavyDebugMsg) cout << "\tKEY CHANGE: from "<<curr_key<<" to "<<new_key<<endl; list<int> aufloes_list=calc_accidentials(curr_key, staff.clef, new_key); @@ -3268,15 +3269,15 @@ bool ScoreCanvas::need_redraw_for_hilighting(ScoreItemList& itemlist, int x1, in bool ScoreCanvas::need_redraw_for_hilighting(ScoreItemList::iterator from_it, ScoreItemList::iterator to_it) { //if we aren't playing, there will never be a need for redrawing due to highlighting things - if (audio->isPlaying()==false) + if (MusEGlobal::audio->isPlaying()==false) return false; for (ScoreItemList::iterator it2=from_it; it2!=to_it; it2++) for (set<FloItem, floComp>::iterator it=it2->second.begin(); it!=it2->second.end();it++) if (it->type==FloItem::NOTE) { - bool is_active= ( (song->cpos() >= it->source_event->tick() + it->source_part->tick()) && - (song->cpos() < it->source_event->endTick() + it->source_part->tick()) ); + bool is_active= ( (MusEGlobal::song->cpos() >= it->source_event->tick() + it->source_part->tick()) && + (MusEGlobal::song->cpos() < it->source_event->endTick() + it->source_part->tick()) ); if (it->is_active != is_active) return true; } @@ -3335,7 +3336,7 @@ void ScoreCanvas::draw_preamble(QPainter& p, int y_offset, clef_t clef, bool res { x_left+=KEYCHANGE_ACC_LEFTDIST; - key_enum key=key_at_tick(tick); + MusECore::key_enum key=key_at_tick(tick); QPixmap* pix_acc=is_sharp_key(key) ? &pix_sharp[BLACK_PIXMAP] : &pix_b[BLACK_PIXMAP]; list<int> acclist=calc_accidentials(key,clef); @@ -3446,7 +3447,7 @@ void ScoreCanvas::draw(QPainter& p, const QRect&) } -list<int> calc_accidentials(key_enum key, clef_t clef, key_enum next_key) +list<int> calc_accidentials(MusECore::key_enum key, clef_t clef, MusECore::key_enum next_key) { list<int> result; @@ -3524,11 +3525,11 @@ int ScoreCanvas::x_to_tick(int x) return t > min_t ? t : min_t; } -key_enum ScoreCanvas::key_at_tick(int t_) +MusECore::key_enum ScoreCanvas::key_at_tick(int t_) { unsigned int t= (t_>=0) ? t_ : 0; - return keymap.keyAtTick(t); + return MusEGlobal::keymap.keyAtTick(t); } timesig_t ScoreCanvas::timesig_at_tick(int t_) @@ -3555,7 +3556,7 @@ int ScoreCanvas::height_to_pitch(int h, clef_t clef) } } -int ScoreCanvas::height_to_pitch(int h, clef_t clef, key_enum key) +int ScoreCanvas::height_to_pitch(int h, clef_t clef, MusECore::key_enum key) { int add=0; @@ -3697,7 +3698,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) if ((mouse_erases_notes) || (event->button()==Qt::MidButton)) //erase? { - audio->msgDeleteEvent(dragged_event, dragged_event_part, true, false, false); + MusEGlobal::audio->msgDeleteEvent(dragged_event, dragged_event_part, true, false, false); } else if (event->button()==Qt::LeftButton) //edit? { @@ -3711,8 +3712,8 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) { if (mouse_inserts_notes) { - Part* curr_part = NULL; - set<Part*> possible_dests=staff_it->parts_at_tick(tick); + MusECore::Part* curr_part = NULL; + set<MusECore::Part*> possible_dests=staff_it->parts_at_tick(tick); if (!possible_dests.empty()) { @@ -3738,7 +3739,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) if (!ctrl) deselect_all(); - Event newevent(Note); + MusECore::Event newevent(MusECore::Note); newevent.setPitch(y_to_pitch(y,tick, staff_it->clef)); newevent.setVelo(note_velo); newevent.setVeloOff(note_velo_off); @@ -3759,7 +3760,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) newevent.setLenTick(curr_part->lenTick() - newevent.tick()); } - audio->msgAddEvent(newevent, curr_part, true, false, false); + MusEGlobal::audio->msgAddEvent(newevent, curr_part, true, false, false); dragged_event_part=curr_part; dragged_event=newevent; @@ -3777,7 +3778,7 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event) drag_cursor_changed=true; setCursor(Qt::SizeAllCursor); - song->update(SC_SELECTION); + MusEGlobal::song->update(SC_SELECTION); } } else // !mouse_inserts_notes. open a lasso @@ -3805,8 +3806,8 @@ void ScoreCanvas::mouseReleaseEvent (QMouseEvent* event) if (flo_quantize(dragged_event.lenTick(), quant_ticks()) <= 0) { if (debugMsg) cout << "new length <= 0, erasing item" << endl; - if (undo_started) song->undo(); - audio->msgDeleteEvent(dragged_event, dragged_event_part, true, false, false); + if (undo_started) MusEGlobal::song->undo(); + MusEGlobal::audio->msgDeleteEvent(dragged_event, dragged_event_part, true, false, false); } else { @@ -3823,7 +3824,7 @@ void ScoreCanvas::mouseReleaseEvent (QMouseEvent* event) clicked_event_ptr->setSelected(!clicked_event_ptr->selected()); - song->update(SC_SELECTION); + MusEGlobal::song->update(SC_SELECTION); } setMouseTracking(false); @@ -3864,12 +3865,12 @@ void ScoreCanvas::mouseReleaseEvent (QMouseEvent* event) if (!ctrl) deselect_all(); - set<Event*> already_processed; + set<MusECore::Event*> already_processed; for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++) it->apply_lasso(lasso.translated(x_pos-x_left, y_pos - it->y_draw), already_processed); - song->update(SC_SELECTION); + MusEGlobal::song->update(SC_SELECTION); have_lasso=false; redraw(); @@ -3924,7 +3925,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) clicked_event_ptr->setSelected(true); - song->update(SC_SELECTION); + MusEGlobal::song->update(SC_SELECTION); } old_pitch=-1; @@ -3950,7 +3951,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) if (new_pitch != old_pitch) { if (debugMsg) cout << "changing pitch, delta="<<new_pitch-original_dragged_event.pitch()<<endl; - if (undo_started) song->undo(); + if (undo_started) MusEGlobal::song->undo(); undo_started=transpose_notes(part_to_set(dragged_event_part),1, new_pitch-original_dragged_event.pitch()); old_pitch=new_pitch; } @@ -3972,7 +3973,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) if (dest_tick != old_dest_tick) { - if (undo_started) song->undo(); //FINDMICH EXTEND + if (undo_started) MusEGlobal::song->undo(); //FINDMICH EXTEND undo_started=move_notes(part_to_set(dragged_event_part),1, (signed)dest_tick-original_dragged_event.tick()); old_dest_tick=dest_tick; } @@ -3984,7 +3985,7 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) tick+=quant_ticks(); if (dragged_event.tick()+old_len + dragged_event_part->tick() != unsigned(tick)) { - Event tmp=dragged_event.clone(); + MusECore::Event tmp=dragged_event.clone(); signed relative_tick=tick-signed(dragged_event_part->tick()); signed new_len=relative_tick-dragged_event.tick(); @@ -4011,12 +4012,12 @@ void ScoreCanvas::mouseMoveEvent (QMouseEvent* event) } } - if (undo_started) song->undo(); - Undo operations; - operations.push_back(UndoOp(UndoOp::ModifyEvent, tmp, dragged_event, dragged_event_part, false, false)); + if (undo_started) MusEGlobal::song->undo(); + MusECore::Undo operations; + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, tmp, dragged_event, dragged_event_part, false, false)); if (newpartlen != dragged_event_part->lenTick()) schedule_resize_all_same_len_clone_parts(dragged_event_part, newpartlen, operations); - undo_started=song->applyOperationGroup(operations); + undo_started=MusEGlobal::song->applyOperationGroup(operations); old_len=new_len; } @@ -4180,11 +4181,11 @@ void ScoreCanvas::pos_changed(int index, unsigned tick, bool scroll) { if (scroll) //potential need to scroll? { - switch (song->follow()) + switch (MusEGlobal::song->follow()) { - case Song::NO: break; - case Song::JUMP: goto_tick(tick,false); break; - case Song::CONTINUOUS: goto_tick(tick,true); break; + case MusECore::Song::NO: break; + case MusECore::Song::JUMP: goto_tick(tick,false); break; + case MusECore::Song::CONTINUOUS: goto_tick(tick,true); break; } } @@ -4264,9 +4265,9 @@ void ScoreCanvas::set_tool(int tool) { switch (tool) { - case MusEWidget::PointerTool: mouse_erases_notes=false; mouse_inserts_notes=false; break; - case MusEWidget::RubberTool: mouse_erases_notes=true; mouse_inserts_notes=false; break; - case MusEWidget::PencilTool: mouse_erases_notes=false; mouse_inserts_notes=true; break; + case MusEGui::PointerTool: mouse_erases_notes=false; mouse_inserts_notes=false; break; + case MusEGui::RubberTool: mouse_erases_notes=true; mouse_inserts_notes=false; break; + case MusEGui::PencilTool: mouse_erases_notes=false; mouse_inserts_notes=true; break; default: cerr << "ERROR: THIS SHOULD NEVER HAPPEN: set_tool called with unknown tool ("<<tool<<")"<<endl; } @@ -4394,28 +4395,28 @@ void ScoreCanvas::set_velo_off(int velo) void ScoreCanvas::deselect_all() { - set<Part*> all_parts=get_all_parts(); + set<MusECore::Part*> all_parts=get_all_parts(); - for (set<Part*>::iterator part=all_parts.begin(); part!=all_parts.end(); part++) - for (iEvent event=(*part)->events()->begin(); event!=(*part)->events()->end(); event++) + for (set<MusECore::Part*>::iterator part=all_parts.begin(); part!=all_parts.end(); part++) + for (MusECore::iEvent event=(*part)->events()->begin(); event!=(*part)->events()->end(); event++) event->second.setSelected(false); - song->update(SC_SELECTION); + MusEGlobal::song->update(SC_SELECTION); } bool staff_t::cleanup_parts() { bool did_something=false; - for (set<Part*>::iterator it=parts.begin(); it!=parts.end();) + for (set<MusECore::Part*>::iterator it=parts.begin(); it!=parts.end();) { bool valid=false; - for (iTrack track=song->tracks()->begin(); track!=song->tracks()->end(); track++) - if ((*track)->type() == Track::MIDI) + for (MusECore::iTrack track=MusEGlobal::song->tracks()->begin(); track!=MusEGlobal::song->tracks()->end(); track++) + if ((*track)->type() == MusECore::Track::MIDI) { - PartList* pl=(*track)->parts(); - for (iPart part=pl->begin(); part!=pl->end(); part++) + MusECore::PartList* pl=(*track)->parts(); + for (MusECore::iPart part=pl->begin(); part!=pl->end(); part++) if (*it == part->second) { valid=true; @@ -4438,18 +4439,18 @@ bool staff_t::cleanup_parts() return did_something; } -set<Part*> staff_t::parts_at_tick(unsigned tick) +set<MusECore::Part*> staff_t::parts_at_tick(unsigned tick) { - set<Part*> result; + set<MusECore::Part*> result; - for (set<Part*>::iterator it=parts.begin(); it!=parts.end(); it++) + for (set<MusECore::Part*>::iterator it=parts.begin(); it!=parts.end(); it++) if ((tick >= (*it)->tick()) && (tick<=(*it)->endTick())) result.insert(*it); return result; } -void staff_t::apply_lasso(QRect rect, set<Event*>& already_processed) +void staff_t::apply_lasso(QRect rect, set<MusECore::Event*>& already_processed) { for (ScoreItemList::iterator it=itemlist.begin(); it!=itemlist.end(); it++) for (set<FloItem>::iterator it2=it->second.begin(); it2!=it->second.end(); it2++) @@ -4476,7 +4477,7 @@ void ScoreCanvas::midi_note(int pitch, int velo) else held_notes[pitch]=false; - if ( srec && selected_part && !audio->isPlaying() && velo ) + if ( srec && selected_part && !MusEGlobal::audio->isPlaying() && velo ) steprec->record(selected_part,pitch,quant_ticks(),quant_ticks(),velo,MusEGlobal::globalKeyState&Qt::ControlModifier,MusEGlobal::globalKeyState&Qt::ShiftModifier); } @@ -4485,10 +4486,10 @@ void ScoreCanvas::midi_note(int pitch, int velo) void ScoreCanvas::update_parts() { if (selected_part!=NULL) //if it's null, let it be null - selected_part=MusEUtil::partFromSerialNumber(selected_part_index); + selected_part=MusECore::partFromSerialNumber(selected_part_index); if (dragged_event_part!=NULL) //same thing here - dragged_event_part=MusEUtil::partFromSerialNumber(dragged_event_part_index); + dragged_event_part=MusECore::partFromSerialNumber(dragged_event_part_index); for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++) it->update_parts(); @@ -4499,14 +4500,14 @@ void staff_t::update_parts() parts.clear(); for (set<int>::iterator it=part_indices.begin(); it!=part_indices.end(); it++) - parts.insert(MusEUtil::partFromSerialNumber(*it)); + parts.insert(MusECore::partFromSerialNumber(*it)); } void staff_t::update_part_indices() { part_indices.clear(); - for (set<Part*>::iterator it=parts.begin(); it!=parts.end(); it++) + for (set<MusECore::Part*>::iterator it=parts.begin(); it!=parts.end(); it++) part_indices.insert((*it)->sn()); } @@ -4522,17 +4523,17 @@ void ScoreEdit::keyPressEvent(QKeyEvent* event) } else if (key == shortcuts[SHRT_TOOL_POINTER].key) { - edit_tools->set(MusEWidget::PointerTool); + edit_tools->set(MusEGui::PointerTool); return; } else if (key == shortcuts[SHRT_TOOL_PENCIL].key) { - edit_tools->set(MusEWidget::PencilTool); + edit_tools->set(MusEGui::PencilTool); return; } else if (key == shortcuts[SHRT_TOOL_RUBBER].key) { - edit_tools->set(MusEWidget::RubberTool); + edit_tools->set(MusEGui::RubberTool); return; } else //Default: @@ -4543,11 +4544,11 @@ void ScoreEdit::keyPressEvent(QKeyEvent* event) } -void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param) +void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >& param) { for (list<staff_t>::iterator staff=staves.begin(); staff!=staves.end(); staff++) { - for (std::map< Part*, set<Part*> >::const_iterator it = param.begin(); it!=param.end(); it++) + for (std::map< MusECore::Part*, set<MusECore::Part*> >::const_iterator it = param.begin(); it!=param.end(); it++) if (staff->parts.find(it->first)!=staff->parts.end()) staff->parts.insert(it->second.begin(), it->second.end()); @@ -4559,6 +4560,8 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param) fully_recalculate(); } +} // namespace MusEGui + //the following assertions are made: // pix_quarter.width() == pix_half.width() diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h index 8f21e76b..0d1432b8 100644 --- a/muse2/muse/midiedit/scoreedit.h +++ b/muse2/muse/midiedit/scoreedit.h @@ -67,8 +67,8 @@ using std::string; -#define TICKS_PER_WHOLE (MusEConfig::config.division*4) -#define SONG_LENGTH (song->len()) +#define TICKS_PER_WHOLE (MusEGlobal::config.division*4) +#define SONG_LENGTH (MusEGlobal::song->len()) @@ -84,11 +84,11 @@ enum {CMD_COLOR_BLACK, CMD_COLOR_VELO, CMD_COLOR_PART, CMD_SELECT_ILOOP, CMD_SELECT_OLOOP}; -class ScoreCanvas; -namespace MusEWidget { +namespace MusEGui { class EditToolBar; -} +class ScoreCanvas; + //--------------------------------------------------------- // ScoreEdit @@ -105,7 +105,7 @@ class ScoreEdit : public TopWin QGridLayout* mainGrid; QWidget* mainw; - MusEWidget::EditToolBar* edit_tools; + MusEGui::EditToolBar* edit_tools; QSpinBox* velo_spinbox; QSpinBox* velo_off_spinbox; @@ -160,7 +160,7 @@ class ScoreEdit : public TopWin QScrollBar* xscroll; QScrollBar* yscroll; ScoreCanvas* score_canvas; - MusEWidget::MTScaleFlo* time_bar; + MusEGui::MTScaleFlo* time_bar; QLabel* apply_velo_to_label; bool apply_velo; @@ -184,7 +184,7 @@ class ScoreEdit : public TopWin void clipboard_changed(); signals: - void deleted(TopWin*); + void deleted(MusEGui::TopWin*); void name_changed(); void velo_changed(int); void velo_off_changed(int); @@ -200,12 +200,12 @@ class ScoreEdit : public TopWin ScoreEdit(QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT); ~ScoreEdit(); - void writeStatus(int level, Xml& xml) const; - void readStatus(Xml& xml); - static void read_configuration(Xml&); - static void write_configuration(int, Xml&); + void writeStatus(int level, MusECore::Xml& xml) const; + void readStatus(MusECore::Xml& xml); + static void read_configuration(MusECore::Xml&); + static void write_configuration(int, MusECore::Xml&); - void add_parts(PartList* pl, bool all_in_one=false); + void add_parts(MusECore::PartList* pl, bool all_in_one=false); QString get_name() { return name; } bool get_apply_velo() { return apply_velo; } }; @@ -253,8 +253,8 @@ class FloEvent enum typeEnum { NOTE_ON = 30, NOTE_OFF = 10, BAR = 20, KEY_CHANGE=23, TIME_SIG=26 }; //the order matters! typeEnum type; unsigned tick; - Part* source_part; - Event* source_event; + MusECore::Part* source_part; + MusECore::Event* source_event; int pitch; mutable int vel; @@ -263,10 +263,10 @@ class FloEvent int num; int denom; - key_enum key; + MusECore::key_enum key; - FloEvent(unsigned ti, int p,int v,int l,typeEnum t, Part* part=NULL, Event* event=NULL) + FloEvent(unsigned ti, int p,int v,int l,typeEnum t, MusECore::Part* part=NULL, MusECore::Event* event=NULL) { pitch=p; vel=v; @@ -285,7 +285,7 @@ class FloEvent source_event=NULL; source_part=NULL; } - FloEvent(unsigned ti, typeEnum t, key_enum k) + FloEvent(unsigned ti, typeEnum t, MusECore::key_enum k) { type=t; key=k; @@ -300,8 +300,8 @@ class FloItem enum typeEnum { NOTE=21, REST=22, NOTE_END=01, REST_END=02, BAR =10, KEY_CHANGE=13, TIME_SIG=16}; //the order matters! typeEnum type; unsigned begin_tick; - Event* source_event; - Part* source_part; + MusECore::Event* source_event; + MusECore::Part* source_part; note_pos_t pos; int len; @@ -312,7 +312,7 @@ class FloItem int num; int denom; - key_enum key; + MusECore::key_enum key; mutable stem_t stem; mutable int shift; @@ -331,7 +331,7 @@ class FloItem - FloItem(typeEnum t, note_pos_t p, int l=0,int d=0, bool ti=false, unsigned beg=0, Part* part=NULL, Event* event=NULL) + FloItem(typeEnum t, note_pos_t p, int l=0,int d=0, bool ti=false, unsigned beg=0, MusECore::Part* part=NULL, MusECore::Event* event=NULL) { pos=p; dots=d; @@ -357,7 +357,7 @@ class FloItem source_part=NULL; } - FloItem(typeEnum t, key_enum k) + FloItem(typeEnum t, MusECore::key_enum k) { type=t; key=k; @@ -533,7 +533,7 @@ enum staff_mode_t struct staff_t { - set<Part*> parts; + set<MusECore::Part*> parts; set<int> part_indices; ScoreEventList eventlist; ScoreItemList itemlist; @@ -555,7 +555,7 @@ struct staff_t void process_itemlist(); void calc_item_pos(); - void apply_lasso(QRect rect, set<Event*>& already_processed); + void apply_lasso(QRect rect, set<MusECore::Event*>& already_processed); void recalculate() { @@ -572,7 +572,7 @@ struct staff_t parent=parent_; } - staff_t (ScoreCanvas* parent_, staff_type_t type_, clef_t clef_, set<Part*> parts_) + staff_t (ScoreCanvas* parent_, staff_type_t type_, clef_t clef_, set<MusECore::Part*> parts_) { type=type_; clef=clef_; @@ -583,18 +583,18 @@ struct staff_t bool cleanup_parts(); - set<Part*> parts_at_tick(unsigned tick); + set<MusECore::Part*> parts_at_tick(unsigned tick); - void read_status(Xml& xml); - void write_status(int level, Xml& xml) const; + void read_status(MusECore::Xml& xml); + void write_status(int level, MusECore::Xml& xml) const; - void update_parts(); //re-populates the set<Part*> from the set<int> - void update_part_indices(); //re-populates the set<int> from the set<Part*> + void update_parts(); //re-populates the set<MusECore::Part*> from the set<int> + void update_part_indices(); //re-populates the set<int> from the set<MusECore::Part*> }; -list<int> calc_accidentials(key_enum key, clef_t clef, key_enum next_key=KEY_C); -note_pos_t note_pos_(int note, key_enum key); -note_pos_t note_pos (unsigned note, key_enum key, clef_t clef); +list<int> calc_accidentials(MusECore::key_enum key, clef_t clef, MusECore::key_enum next_key=MusECore::KEY_C); +note_pos_t note_pos_(int note, MusECore::key_enum key); +note_pos_t note_pos (unsigned note, MusECore::key_enum key, clef_t clef); int calc_len(int l, int d); list<note_len_t> parse_note_len(int len_ticks, int begin_tick, vector<int>& foo, bool allow_dots=true, bool allow_normal=true); @@ -606,7 +606,7 @@ int calc_timesig_width(int num, int denom); int calc_number_width(int n); -class ScoreCanvas : public MusEWidget::View +class ScoreCanvas : public MusEGui::View { Q_OBJECT private: @@ -625,7 +625,7 @@ class ScoreCanvas : public MusEWidget::View - static int height_to_pitch(int h, clef_t clef, key_enum key); + static int height_to_pitch(int h, clef_t clef, MusECore::key_enum key); static int height_to_pitch(int h, clef_t clef); static int y_to_height(int y); int y_to_pitch(int y, int t, clef_t clef); @@ -671,7 +671,7 @@ class ScoreCanvas : public MusEWidget::View list<staff_t> staves; - StepRec* steprec; + MusECore::StepRec* steprec; // the drawing area is split into a "preamble" containing clef, // key and time signature, and the "item's area" containing the @@ -693,7 +693,7 @@ class ScoreCanvas : public MusEWidget::View float y_scroll_speed; float y_scroll_pos; - Part* selected_part; + MusECore::Part* selected_part; int selected_part_index; int last_len; @@ -717,11 +717,11 @@ class ScoreCanvas : public MusEWidget::View bool inserting; bool dragging; bool drag_cursor_changed; - Part* dragged_event_part; + MusECore::Part* dragged_event_part; int dragged_event_part_index; - Event dragged_event; - Event original_dragged_event; - Event* clicked_event_ptr; + MusECore::Event dragged_event; + MusECore::Event original_dragged_event; + MusECore::Event* clicked_event_ptr; int old_pitch; unsigned old_dest_tick; @@ -765,7 +765,7 @@ class ScoreCanvas : public MusEWidget::View void deselect_all(); void midi_note(int pitch, int velo); - void add_new_parts(const std::map< Part*, std::set<Part*> >&); + void add_new_parts(const std::map< MusECore::Part*, std::set<MusECore::Part*> >&); public slots: void x_scroll_event(int); @@ -788,7 +788,7 @@ class ScoreCanvas : public MusEWidget::View void set_steprec(bool); - void update_parts(); //re-populates the set<Part*>s from the set<int>s + void update_parts(); //re-populates the set<MusECore::Part*>s from the set<int>s signals: void xscroll_changed(int); void yscroll_changed(int); @@ -813,7 +813,7 @@ class ScoreCanvas : public MusEWidget::View ScoreCanvas(ScoreEdit*, QWidget*); ~ScoreCanvas(); - void add_staves(PartList* pl, bool all_in_one); + void add_staves(MusECore::PartList* pl, bool all_in_one); void push_back_staff(staff_t& staff) { staves.push_back(staff); } //FINDMICH dirty. very dirty. int canvas_width(); @@ -830,17 +830,17 @@ class ScoreCanvas : public MusEWidget::View int get_last_len() {return last_len;} void set_last_len(int l) {last_len=l;} - Part* get_selected_part() {return selected_part;} - void set_selected_part(Part* p) {selected_part=p; if (selected_part) selected_part_index=selected_part->sn();} - Part* get_dragged_event_part() {return dragged_event_part;} - void set_dragged_event_part(Part* p) {dragged_event_part=p; if (dragged_event_part) dragged_event_part_index=dragged_event_part->sn();} + MusECore::Part* get_selected_part() {return selected_part;} + void set_selected_part(MusECore::Part* p) {selected_part=p; if (selected_part) selected_part_index=selected_part->sn();} + MusECore::Part* get_dragged_event_part() {return dragged_event_part;} + void set_dragged_event_part(MusECore::Part* p) {dragged_event_part=p; if (dragged_event_part) dragged_event_part_index=dragged_event_part->sn();} - set<Part*> get_all_parts(); + set<MusECore::Part*> get_all_parts(); - void write_staves(int level, Xml& xml) const; + void write_staves(int level, MusECore::Xml& xml) const; timesig_t timesig_at_tick(int t); - key_enum key_at_tick(int t); + MusECore::key_enum key_at_tick(int t); int tick_to_x(int t); int delta_tick_to_delta_x(int t); int x_to_tick(int x); @@ -851,6 +851,6 @@ int calc_measure_len(const list<int>& nums, int denom); vector<int> create_emphasize_list(const list<int>& nums, int denom); vector<int> create_emphasize_list(int num, int denom); - +} // namespace MusEGui #endif |