diff options
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/muse/midiedit/dcanvas.cpp | 252 | ||||
-rw-r--r-- | muse2/muse/midiedit/dcanvas.h | 5 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.cpp | 28 | ||||
-rw-r--r-- | muse2/muse/midiedit/dlist.h | 5 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.cpp | 8 | ||||
-rw-r--r-- | muse2/muse/midiedit/drumedit.h | 3 |
6 files changed, 177 insertions, 124 deletions
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp index 550de13b..07e5a430 100644 --- a/muse2/muse/midiedit/dcanvas.cpp +++ b/muse2/muse/midiedit/dcanvas.cpp @@ -111,9 +111,9 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy, const char* name) : EventCanvas(pr, parent, sx, sy, name) { - using MusEUtil::drummaps_almost_equal; + drumEditor=dynamic_cast<DrumEdit*>(pr); - old_style_drummap_mode = dynamic_cast<DrumEdit*>(pr)->old_style_drummap_mode(); + old_style_drummap_mode = drumEditor->old_style_drummap_mode(); if (old_style_drummap_mode) { @@ -122,7 +122,7 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, must_delete_our_drum_map=false; instrument_number_mapping_t temp; - for (ciPart it=pr->parts()->begin(); it!=pr->parts()->end(); it++) + for (ciPart it=drumEditor->parts()->begin(); it!=drumEditor->parts()->end(); it++) temp.tracks.insert(it->second->track()); for (int i=0;i<DRUM_MAPSIZE;i++) @@ -134,121 +134,8 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx, else { if (debugMsg) printf("DrumCanvas in new style drummap mode\n"); - TrackList* tl=song->tracks(); - - QList< QSet<Track*> > track_groups; - - for (ciTrack track = tl->begin(); track!=tl->end(); track++) - { - ciPart p_it; - for (p_it=pr->parts()->begin(); p_it!=pr->parts()->end(); p_it++) - if (p_it->second->track() == *track) - break; - - if (p_it!=pr->parts()->end()) // if *track is represented by some part in this editor - { - bool inserted=false; - - switch (dynamic_cast<DrumEdit*>(pr)->group_mode()) - { - case DrumEdit::GROUP_SAME_CHANNEL: - for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) - if ( ((MidiTrack*)*group->begin())->outChannel() == ((MidiTrack*)*track)->outChannel() && - ((MidiTrack*)*group->begin())->outPort() == ((MidiTrack*)*track)->outPort() && - (drummaps_almost_equal(((MidiTrack*)*group->begin())->drummap(), ((MidiTrack*)*track)->drummap())) ) - { - group->insert(*track); - inserted=true; - break; - } - break; - - case DrumEdit::GROUP_MAX: - for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) - if (drummaps_almost_equal(((MidiTrack*)*group->begin())->drummap(), ((MidiTrack*)*track)->drummap())) - { - group->insert(*track); - inserted=true; - break; - } - break; - - case DrumEdit::DONT_GROUP: - inserted=false; - break; - - default: - printf("THIS SHOULD NEVER HAPPEN: group_mode() is invalid!\n"); - inserted=false; - } - - if (!inserted) - { - QSet<Track*> temp; - temp.insert(*track); - track_groups.push_back(temp); - } - } - } - - printf("FINDMICH DEBUG: we have %i groups\n",track_groups.size()); - - // from now, we assume that every track_group's entry only groups tracks with identical - // drum maps, but not necessarily identical hide-lists together. - QList< std::pair<MidiTrack*,int> > ignore_order_entries; - for (global_drum_ordering_t::iterator order_it=global_drum_ordering.begin(); order_it!=global_drum_ordering.end(); order_it++) - { - // if this entry should be ignored, ignore it. - if (ignore_order_entries.contains(*order_it)) - continue; - - // look if we have order_it->first (the MidiTrack*) in any of our track groups - QList< QSet<Track*> >::iterator group; - for (group=track_groups.begin(); group!=track_groups.end(); group++) - if (group->contains(order_it->first)) - break; - - if (group!=track_groups.end()) // we have - { - int pitch=order_it->second; - - bool mute=true; - bool hidden=true; - for (QSet<Track*>::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) - { - if (dynamic_cast<MidiTrack*>(*track)->drummap()[pitch].mute == false) - mute=false; - - if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] == false) - hidden=false; - } - - if (!hidden) - { - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - dynamic_cast<MidiTrack*>(*track)->drummap()[pitch].mute=mute; - - if (dynamic_cast<MidiTrack*>(*group->begin())->drummap()[pitch].anote != pitch) - printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast<MidiTrack*>(*group->begin())->drummap()[pitch].anote,pitch); - - instrument_map.append(instrument_number_mapping_t(*group, pitch)); - } - - for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) - ignore_order_entries.append(std::pair<MidiTrack*,int>(dynamic_cast<MidiTrack*>(*track), pitch)); - } - // else ignore it - } - - - // populate ourDrumMap - - int size = instrument_map.size(); - ourDrumMap=new DrumMap[size]; - must_delete_our_drum_map=true; - - for (int i=0;i<size;i++) - ourDrumMap[i] = dynamic_cast<MidiTrack*>(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch]; + ourDrumMap=NULL; + rebuildOurDrumMap(); } @@ -1411,3 +1298,132 @@ void DrumCanvas::propagate_drummap_change(int instr) for (QSet<Track*>::const_iterator it = tracks.begin(); it != tracks.end(); it++) dynamic_cast<MidiTrack*>(*it)->drummap()[index] = ourDrumMap[instr]; } + + +void DrumCanvas::rebuildOurDrumMap() +{ + using MusEUtil::drummaps_almost_equal; + + if (!old_style_drummap_mode) + { + TrackList* tl=song->tracks(); + QList< QSet<Track*> > track_groups; + + instrument_map.clear(); + + for (ciTrack track = tl->begin(); track!=tl->end(); track++) + { + ciPart p_it; + for (p_it=drumEditor->parts()->begin(); p_it!=drumEditor->parts()->end(); p_it++) + if (p_it->second->track() == *track) + break; + + if (p_it!=drumEditor->parts()->end()) // if *track is represented by some part in this editor + { + bool inserted=false; + + switch (drumEditor->group_mode()) + { + case DrumEdit::GROUP_SAME_CHANNEL: + for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) + if ( ((MidiTrack*)*group->begin())->outChannel() == ((MidiTrack*)*track)->outChannel() && + ((MidiTrack*)*group->begin())->outPort() == ((MidiTrack*)*track)->outPort() && + (drummaps_almost_equal(((MidiTrack*)*group->begin())->drummap(), ((MidiTrack*)*track)->drummap())) ) + { + group->insert(*track); + inserted=true; + break; + } + break; + + case DrumEdit::GROUP_MAX: + for (QList< QSet<Track*> >::iterator group=track_groups.begin(); group!=track_groups.end(); group++) + if (drummaps_almost_equal(((MidiTrack*)*group->begin())->drummap(), ((MidiTrack*)*track)->drummap())) + { + group->insert(*track); + inserted=true; + break; + } + break; + + case DrumEdit::DONT_GROUP: + inserted=false; + break; + + default: + printf("THIS SHOULD NEVER HAPPEN: group_mode() is invalid!\n"); + inserted=false; + } + + if (!inserted) + { + QSet<Track*> temp; + temp.insert(*track); + track_groups.push_back(temp); + } + } + } + + // from now, we assume that every track_group's entry only groups tracks with identical + // drum maps, but not necessarily identical hide-lists together. + QList< std::pair<MidiTrack*,int> > ignore_order_entries; + for (global_drum_ordering_t::iterator order_it=global_drum_ordering.begin(); order_it!=global_drum_ordering.end(); order_it++) + { + // if this entry should be ignored, ignore it. + if (ignore_order_entries.contains(*order_it)) + continue; + + // look if we have order_it->first (the MidiTrack*) in any of our track groups + QList< QSet<Track*> >::iterator group; + for (group=track_groups.begin(); group!=track_groups.end(); group++) + if (group->contains(order_it->first)) + break; + + if (group!=track_groups.end()) // we have + { + int pitch=order_it->second; + + bool mute=true; + bool hidden=true; + for (QSet<Track*>::iterator track=group->begin(); track!=group->end() && (mute || hidden); track++) + { + if (dynamic_cast<MidiTrack*>(*track)->drummap()[pitch].mute == false) + mute=false; + + if (dynamic_cast<MidiTrack*>(*track)->drummap_hidden()[pitch] == false) + hidden=false; + } + + if (!hidden) + { + for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) + dynamic_cast<MidiTrack*>(*track)->drummap()[pitch].mute=mute; + + if (dynamic_cast<MidiTrack*>(*group->begin())->drummap()[pitch].anote != pitch) + printf("THIS SHOULD NEVER HAPPEN: track's_drummap[pitch].anote (%i)!= pitch (%i) !!!\n",dynamic_cast<MidiTrack*>(*group->begin())->drummap()[pitch].anote,pitch); + + instrument_map.append(instrument_number_mapping_t(*group, pitch)); + } + + for (QSet<Track*>::iterator track=group->begin(); track!=group->end(); track++) + ignore_order_entries.append(std::pair<MidiTrack*,int>(dynamic_cast<MidiTrack*>(*track), pitch)); + } + // else ignore it + } + + + // maybe delete and then populate ourDrumMap + + if (must_delete_our_drum_map && ourDrumMap!=NULL) + delete [] ourDrumMap; + + int size = instrument_map.size(); + ourDrumMap=new DrumMap[size]; + must_delete_our_drum_map=true; + + for (int i=0;i<size;i++) + ourDrumMap[i] = dynamic_cast<MidiTrack*>(*instrument_map[i].tracks.begin())->drummap()[instrument_map[i].pitch]; + + emit ourDrumMapChanged(); + } +} diff --git a/muse2/muse/midiedit/dcanvas.h b/muse2/muse/midiedit/dcanvas.h index f0c601f5..0f519b70 100644 --- a/muse2/muse/midiedit/dcanvas.h +++ b/muse2/muse/midiedit/dcanvas.h @@ -41,6 +41,7 @@ class QDragLeaveEvent; class DrumMap; class MidiEditor; +class DrumEdit; //--------------------------------------------------------- // DEvent @@ -86,6 +87,8 @@ class DrumCanvas : public EventCanvas { bool must_delete_our_drum_map; //FINDMICH really delete it! QVector<instrument_number_mapping_t> instrument_map; + DrumEdit* drumEditor; + StepRec* steprec; // Cursor tool position @@ -119,6 +122,7 @@ class DrumCanvas : public EventCanvas { signals: void newWidth(int); + void ourDrumMapChanged(); private slots: void midiNote(int pitch, int velo); @@ -152,6 +156,7 @@ class DrumCanvas : public EventCanvas { int getOurDrumMapSize() { return instrument_map.size(); } //FINDMICH UGLY void propagate_drummap_change(int instrument); //FINDMICH move to drumedit + void rebuildOurDrumMap(); }; #endif diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp index 7de39b81..c35f2a21 100644 --- a/muse2/muse/midiedit/dlist.cpp +++ b/muse2/muse/midiedit/dlist.cpp @@ -37,7 +37,6 @@ #include "icons.h" #include "dlist.h" #include "song.h" -#include "scrollscale.h" #include "dcanvas.h" //--------------------------------------------------------- @@ -595,6 +594,12 @@ void DList::sizeChange(int, int, int) void DList::returnPressed() { + if (editEntry==NULL) + { + printf("THIS SHOULD NEVER HAPPEN: editEntry is NULL in DList::returnPressed()!\n"); + return; + } + int val = -1; if (selectedColumn != COL_NAME) { @@ -690,6 +695,12 @@ void DList::returnPressed() void DList::pitchEdited() { + if (editEntry==NULL) + { + printf("THIS SHOULD NEVER HAPPEN: editEntry is NULL in DList::pitchEdited()!\n"); + return; + } + int val=pitch_editor->value(); int instrument=(editEntry-ourDrumMap); @@ -784,11 +795,11 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bo ourDrumMap=dcanvas->getOurDrumMap(); ourDrumMapSize=dcanvas->getOurDrumMapSize(); old_style_drummap_mode=oldstyle; + connect(dcanvas, SIGNAL(ourDrumMapChanged()), SLOT(ourDrumMapChanged())); if (!h){ h = new QHeaderView(Qt::Horizontal, parent);} header = h; - scroll = 0; //ORCAN- CHECK if really needed: header->setTracking(true); connect(header, SIGNAL(sectionResized(int,int,int)), SLOT(sizeChange(int,int,int))); @@ -896,3 +907,16 @@ int DList::getSelectedInstrument() } +void DList::ourDrumMapChanged() +{ + int selIdx = currentlySelected - ourDrumMap; + + ourDrumMap=dcanvas->getOurDrumMap(); + ourDrumMapSize=dcanvas->getOurDrumMapSize(); + + editEntry=NULL; + if (selIdx >= ourDrumMapSize) selIdx=ourDrumMapSize-1; + currentlySelected = &ourDrumMap[selIdx]; + + redraw(); +} diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h index 52bf8de4..1d87f3dc 100644 --- a/muse2/muse/midiedit/dlist.h +++ b/muse2/muse/midiedit/dlist.h @@ -35,7 +35,6 @@ class QHeaderView; class QMouseEvent; class QPainter; -class ScrollScale; class Device; class QLineEdit; class DrumMap; @@ -93,7 +92,6 @@ class DList : public MusEWidget::View { bool old_style_drummap_mode; QHeaderView* header; - ScrollScale* scroll; QLineEdit* editor; DPitchEdit* pitch_editor; DrumMap* editEntry; @@ -133,13 +131,14 @@ class DList : public MusEWidget::View { public slots: void tracklistChanged(); void songChanged(int); + void ourDrumMapChanged(); + public: 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(); - void setScroll(ScrollScale* s) { scroll = s; } int getSelectedInstrument(); enum DCols { COL_MUTE=0, COL_NAME, COL_VOL, COL_QNT, COL_ENOTE, COL_LEN, diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp index a74f3dd1..4cb6a7b1 100644 --- a/muse2/muse/midiedit/drumedit.cpp +++ b/muse2/muse/midiedit/drumedit.cpp @@ -420,6 +420,7 @@ DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned ini connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int))); connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn())); connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut())); + connect(canvas, SIGNAL(ourDrumMapChanged()), SLOT(ourDrumMapChanged())); time->setOrigin(offset, 0); QList<int> mops; @@ -1343,3 +1344,10 @@ bool DrumEdit::old_style_drummap_mode() return false; } + +void DrumEdit::ourDrumMapChanged() +{ + int vmin,vmax; + vscroll->range(&vmin, &vmax); + vscroll->setRange(vmin, dynamic_cast<DrumCanvas*>(canvas)->getOurDrumMapSize()*TH); +} diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h index d854d054..7d85cb2f 100644 --- a/muse2/muse/midiedit/drumedit.h +++ b/muse2/muse/midiedit/drumedit.h @@ -136,8 +136,9 @@ class DrumEdit : public MidiEditor { void execDeliveredScript(int); void execUserScript(int); CtrlEdit* addCtrl(); - + void ourDrumMapChanged(); virtual void updateHScrollRange(); + signals: void deleted(TopWin*); |