summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse/CMakeLists.txt4
-rw-r--r--muse/ChangeLog2
-rw-r--r--muse/muse/midiedit/CMakeLists.txt1
-rw-r--r--muse/muse/midiedit/miditracker.cpp15
-rw-r--r--muse/muse/midiedit/miditracker.h6
-rw-r--r--muse/muse/midiedit/trackpattern.cpp197
-rw-r--r--muse/muse/midiedit/trackpattern.h79
7 files changed, 221 insertions, 83 deletions
diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt
index 4d50367e..e414d48b 100644
--- a/muse/CMakeLists.txt
+++ b/muse/CMakeLists.txt
@@ -26,8 +26,8 @@ if (NOT CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR "lib")
endif (NOT CMAKE_INSTALL_LIBDIR)
-# set(CMAKE_BUILD_TYPE debug)
-set(CMAKE_BUILD_TYPE release)
+set(CMAKE_BUILD_TYPE debug)
+# set(CMAKE_BUILD_TYPE release)
# for debugging the make system uncomment next line:
# set(CMAKE_VERBOSE_MAKEFILE ON)
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 372d2a53..b6f2f700 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,5 @@
+04.03 (ng)
+ - update III miditracker
02.02 (ng)
- updated partlistedit, direct editing of time & parameters on list edit
01.02 (ng)
diff --git a/muse/muse/midiedit/CMakeLists.txt b/muse/muse/midiedit/CMakeLists.txt
index 0d69b1f5..00fc169f 100644
--- a/muse/muse/midiedit/CMakeLists.txt
+++ b/muse/muse/midiedit/CMakeLists.txt
@@ -30,6 +30,7 @@ QT4_WRAP_CPP ( midiedit_mocs
pianoroll.h
prcanvas.h
miditracker.h
+ trackpattern.h
)
QT4_WRAP_UI ( midiedit_ui_headers
diff --git a/muse/muse/midiedit/miditracker.cpp b/muse/muse/midiedit/miditracker.cpp
index f0b6b961..6e6a9a5b 100644
--- a/muse/muse/midiedit/miditracker.cpp
+++ b/muse/muse/midiedit/miditracker.cpp
@@ -109,6 +109,7 @@ MidiTrackerEditor::MidiTrackerEditor(PartList* pl, bool /*init*/)
//-------------
_timingPattern =
new TimingPattern(this, "Timing", firstTick, lastTick, _quant);
+ int nbrRow = _timingPattern->getAbsoluteNbrRow();
//---------------
//tracks matrices
@@ -123,12 +124,20 @@ MidiTrackerEditor::MidiTrackerEditor(PartList* pl, bool /*init*/)
if(trackNotFound) {
TrackPattern* tp;
tp = new TrackPattern(this, track->name(), firstTick, lastTick,
- _quant, pl, (MidiTrack*) track);
+ _quant, pl, (MidiTrack*) track, nbrRow);
_trackPatterns.push_back(tp);
}
}
}
+ //signals from TimingPattern and TrackPattern
+ connect(_timingPattern, SIGNAL(moveCurrentRow(unsigned)),
+ this, SLOT(updateMoveCurrentRow(unsigned)));
+ for(unsigned i = 0; i < _trackPatterns.size(); i++) {
+ connect(_trackPatterns[i], SIGNAL(moveCurrentRow(unsigned)),
+ this, SLOT(updateMoveCurrentRow(unsigned)));
+ }
+
/*
addToolBarBreak();
toolbar = new Toolbar1(initRaster, initQuant);
@@ -233,3 +242,7 @@ void MidiTrackerEditor::cmd(QAction* /*a*/) {
// _trackPatterns[i]->fillTrackPat();
// _timingPattern->fillTimmingPat();
//}
+
+void MidiTrackerEditor::updateMoveCurrentRow(unsigned index) {
+ emit signalMoveCurrentRow(index);
+}
diff --git a/muse/muse/midiedit/miditracker.h b/muse/muse/midiedit/miditracker.h
index edff20ee..aad3a090 100644
--- a/muse/muse/midiedit/miditracker.h
+++ b/muse/muse/midiedit/miditracker.h
@@ -27,6 +27,7 @@ using AL::Xml;
class MidiTrackerEditor : public MidiEditor {
Q_OBJECT
+
private:
int _quant;
QuantCombo* _quantCombo;
@@ -41,7 +42,9 @@ class MidiTrackerEditor : public MidiEditor {
TimingPattern* _timingPattern;
private slots:
+ void updateMoveCurrentRow(unsigned);
virtual void cmd(QAction*);
+
public:
MidiTrackerEditor(PartList*, bool);
~MidiTrackerEditor() {}
@@ -61,6 +64,9 @@ class MidiTrackerEditor : public MidiEditor {
protected:
//void resizeEvent(QResizeEvent *event);
+
+ signals:
+ void signalMoveCurrentRow(unsigned);
};
#endif
diff --git a/muse/muse/midiedit/trackpattern.cpp b/muse/muse/midiedit/trackpattern.cpp
index 781879f3..84f4aeda 100644
--- a/muse/muse/midiedit/trackpattern.cpp
+++ b/muse/muse/midiedit/trackpattern.cpp
@@ -4,6 +4,8 @@
class EventList;
+#define MAX(x,y) (x>y?x:y)
+
#define EMPTYCHAR "-"
#define NONREADCHAR "*"
#define SPACECHAR "-"
@@ -11,10 +13,11 @@ class EventList;
#define STOPCHAR "="
#define SEPCHAR " "
//#define FONT "Console"
-//#define FONT "Monospace"
-#define FONT "MiscFixed"
+#define FONT "Monospace"
+//#define FONT "MiscFixed"
#define FONT_HEIGHT 14
-#define OFFSET_Y 4
+#define OFFSET_HEIGHT 3
+#define OFFSET_Y 3
//----------------------------------------------------------
// EventPat
@@ -266,45 +269,110 @@ CtrlPat::~CtrlPat() {}
//----------------------------------------------------------
// BaseTrackPat
//----------------------------------------------------------
-BaseTrackPat::BaseTrackPat(QMainWindow* parent) {
+BaseTrackPat::BaseTrackPat(QMainWindow* parent, unsigned anr) {
_parent = parent;
- _currentRow = 0;
- _numRow = 0;
+ _tree = new QTreeWidget(this);
+
+ _absoluteNbrRow = anr;
+
+ _update = false;
+
+ connect(_tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
+ SLOT(currentItemChanged(QTreeWidgetItem*)));
+ connect(_tree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
+ SLOT(currentItemChanged(QTreeWidgetItem*)));
+ connect(_parent, SIGNAL(signalMoveCurrentRow(unsigned)), this,
+ SLOT(moveRowFromSignal(unsigned)));
+ //connect(_tree, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged()));
}
BaseTrackPat::~BaseTrackPat() {
}
-void BaseTrackPat::setNumRow(unsigned nr) {
- _numRow = nr;
+void BaseTrackPat::setRowMag() {
+ _rowMag = (unsigned) height()/_fontHeight - OFFSET_Y;
+ _lastRow = _firstRow + _rowMag - 1;
}
-
-unsigned BaseTrackPat::getNumRow() {
- return _numRow;
+void BaseTrackPat::setFirstRow(unsigned f) {
+ _firstRow = f;
+ _lastRow = f + _rowMag - 1;
+}
+void BaseTrackPat::setRelativeCurrentRow(unsigned r) {
+ _relativeCurrentRow = r;
+ _absoluteCurrentRow = r + _firstRow;
+}
+void BaseTrackPat::setAbsoluteCurrentRow(unsigned a) {
+ _absoluteCurrentRow = a;
+ _relativeCurrentRow = a - _firstRow;
}
unsigned BaseTrackPat::getRowMag() {
- return (unsigned) height()/FONT_HEIGHT - OFFSET_Y;
+ return _rowMag;
+}
+unsigned BaseTrackPat::getFirstRow() {
+ return _firstRow;
+}
+unsigned BaseTrackPat::getLastRow() {
+ return _lastRow;
+}
+unsigned BaseTrackPat::getRelativeCurrentRow() {
+ return _relativeCurrentRow;
+}
+unsigned BaseTrackPat::getAbsoluteCurrentRow() {
+ return _absoluteCurrentRow;
}
-unsigned BaseTrackPat::getCurTreeRow() {
- unsigned rmd2 = getRowMag()/2;
- if(_currentRow < rmd2) return _currentRow;
- else if(_currentRow > getNumRow() - rmd2)
- return _currentRow - getNumRow() + getRowMag();
- else return rmd2;
+unsigned BaseTrackPat::getAbsoluteNbrRow() {
+ return _absoluteNbrRow;
}
-unsigned BaseTrackPat::getLowRow() {
- unsigned rmd2 = getRowMag()/2;
- if(_currentRow < rmd2) return 0;
- else if(_currentRow > getNumRow() - rmd2)
- return _tree->topLevelItemCount() - getRowMag();
- else return _currentRow - rmd2;
+void BaseTrackPat::moveRelativeCurrentRow(unsigned newIndex) {
+ if(newIndex==0 && getFirstRow()>0) {
+ setFirstRow(getFirstRow() - 1);
+ setRelativeCurrentRow(newIndex + 1);
+ _update = true;
+ }
+ else if(newIndex==getRowMag()-1 && getLastRow()<_absoluteNbrRow-1) {
+ setFirstRow(getFirstRow() + 1);
+ setRelativeCurrentRow(newIndex - 1);
+ _update = true;
+ }
+ else setRelativeCurrentRow(newIndex);
}
-unsigned BaseTrackPat::getUpRow() {
- return getLowRow() + getRowMag();
+//void BaseTrackPat::itemSelectionChanged() {
+void BaseTrackPat::currentItemChanged(QTreeWidgetItem* nitem) {
+ int index;
+ if(nitem) {
+ index = _tree->indexOfTopLevelItem(nitem);
+
+ emit moveCurrentRow(index);
+ }
+}
+
+void BaseTrackPat::moveRowFromSignal(unsigned index) {
+ moveRelativeCurrentRow(index);
+ if(_update==true) {
+ fillPattern();
+ _update = false;
+ }
+ selectCurrentRow();
+}
+
+void BaseTrackPat::resizeEvent(QResizeEvent* /*event*/) {
+ setRowMag();
+ fillPattern();
+ selectCurrentRow();
+}
+
+void BaseTrackPat::selectCurrentRow() {
+ _tree->blockSignals(true);
+
+ QTreeWidgetItem* item = _tree->topLevelItem(getRelativeCurrentRow());
+ item->setSelected(true);
+ _tree->setCurrentItem(item);
+
+ _tree->blockSignals(false);
}
//----------------------------------------------------------
@@ -312,8 +380,8 @@ unsigned BaseTrackPat::getUpRow() {
//----------------------------------------------------------
TrackPattern::TrackPattern(QMainWindow* parent, QString name,
unsigned firstTick, unsigned lastTick,
- int quant, PartList* pl, MidiTrack* t)
- : BaseTrackPat(parent), BasePat(name, firstTick, lastTick, quant) {
+ int quant, PartList* pl, MidiTrack* t, unsigned anr)
+ : BaseTrackPat(parent, anr), BasePat(name, firstTick, lastTick, quant) {
//set attributs
_track = t;
@@ -335,7 +403,6 @@ TrackPattern::TrackPattern(QMainWindow* parent, QString name,
parent->addDockWidget(Qt::LeftDockWidgetArea, this, Qt::Horizontal);
//build the treeWidget
- _tree = new QTreeWidget(this);
_tree->setColumnCount(_voiceColumns.size() + _ctrlColumns.size());
QStringList headerLabels;
for(unsigned i = 0; i < _voiceColumns.size(); i++) {
@@ -349,13 +416,22 @@ TrackPattern::TrackPattern(QMainWindow* parent, QString name,
//set some display properties
_tree->setRootIsDecorated(false);
_tree->setUniformRowHeights(true);
+ _tree->setAlternatingRowColors(true);
QFont font =_tree->font();
font.setFamily(FONT);
_tree->setFont(font);
+ font.setPixelSize(FONT_HEIGHT);
+ _fontHeight = font.pixelSize() + OFFSET_HEIGHT;
setWidget(_tree);
+ //set the range of rows to display
+ setFirstRow(10); //TODO : choose accordingly to current position of muse song
+ setAbsoluteCurrentRow(10); //TODO : the same
+ setRowMag();
+
//fill the treeWidget
- fillTrackPat();
+ fillPattern();
+ selectCurrentRow();
//Resize the columns
for(unsigned i = 0; i < _voiceColumns.size(); i++)
@@ -363,7 +439,8 @@ TrackPattern::TrackPattern(QMainWindow* parent, QString name,
}
-TrackPattern::~TrackPattern(){}
+TrackPattern::~TrackPattern() {
+}
void TrackPattern::add(const Event* e, unsigned tick) {
if(e->isNote()) {
@@ -392,7 +469,6 @@ void TrackPattern::setQuant(int /*quant*/) {
}
void TrackPattern::buildEventMatrix() {
- _numRow = tick2row(_lastTick) - tick2row(_firstTick);
for(ciPart p = _partList->begin(); p != _partList->end(); p++) {
Part* part = p->second;
EventList* events = part->events();
@@ -404,12 +480,13 @@ void TrackPattern::buildEventMatrix() {
}
}
-void TrackPattern::fillTrackPat() {
- getRowMag();
+void TrackPattern::fillPattern() {
+ _tree->blockSignals(true);
+
_tree->clear();
for(unsigned i = 0; i < _voiceColumns.size(); i++) {
- for(unsigned j = getLowRow(); j < getUpRow(); j++) {
- QTreeWidgetItem* item = _tree->topLevelItem(j);
+ for(unsigned j = getFirstRow(); j <= getLastRow(); j++) {
+ QTreeWidgetItem* item = _tree->topLevelItem(j - getFirstRow());
if(!item) item = new QTreeWidgetItem(_tree);
VoiceEventPat* vep = (_voiceColumns[i]->getEventsCol())[j];
if(vep) item->setText(i, vep->str());
@@ -419,13 +496,7 @@ void TrackPattern::fillTrackPat() {
//TODO CTRL
}
- //select the line corresponding to the current row
- QTreeWidgetItem* item = _tree->topLevelItem(getCurTreeRow());
- item->setSelected(true);
-}
-
-void TrackPattern::resizeEvent(QResizeEvent* /*event*/) {
- fillTrackPat();
+ _tree->blockSignals(false);
}
//---------------------------------------------------------------
@@ -434,6 +505,8 @@ void TrackPattern::resizeEvent(QResizeEvent* /*event*/) {
TimingEvent::TimingEvent(unsigned row) {
_row = row;
}
+TimingEvent::~TimingEvent() {
+}
void TimingEvent::setBarBeatTick(unsigned tick) {
AL::sigmap.tickValues(tick, &_bar, &_beat, &_tick);
@@ -478,54 +551,58 @@ TimingPattern::TimingPattern(QMainWindow* parent, QString name,
parent->addDockWidget(Qt::LeftDockWidgetArea, this, Qt::Horizontal);
//build the treeWidget
- _tree = new QTreeWidget(this);
- _tree->setColumnCount(2);
QStringList headerLabels;
_tree->setHeaderLabels(QStringList("bar:bt:tick") + QStringList("row"));
_tree->setHeaderLabels(headerLabels);
//set some display properties
_tree->setRootIsDecorated(false);
_tree->setUniformRowHeights(true);
+ _tree->setAlternatingRowColors(true);
QFont font =_tree->font();
font.setFamily(FONT);
_tree->setFont(font);
+ font.setPixelSize(FONT_HEIGHT);
+ _fontHeight = font.pixelSize() + OFFSET_HEIGHT;
setWidget(_tree);
+ //set the range of rows to display
+ setFirstRow(10); //TODO : choose accordingly to current position of muse song
+ setAbsoluteCurrentRow(10); //TODO : the same
+ setRowMag();
+
//fill the treeWidget
- fillTimingPat();
+ fillPattern();
+ selectCurrentRow();
+
+ //resize the columns
for(int i = 0; i < _tree->columnCount(); i++)
_tree->resizeColumnToContents(i);
}
-TimingPattern::~TimingPattern() {}
+TimingPattern::~TimingPattern() {
+}
void TimingPattern::buildTimingMatrix() {
- _numRow = 0;
for(unsigned tick = _firstTick; tick <= _lastTick; tick++) {
if(isRow(tick)) {
TimingEvent* te = new TimingEvent(tick2row(tick) - tick2row(_firstTick));
te->setBarBeatTick(tick);
_timingEvents.push_back(te);
- _numRow++;
}
}
+ _absoluteNbrRow = _timingEvents.size();
}
-void TimingPattern::fillTimingPat() {
+void TimingPattern::fillPattern() {
+ _tree->blockSignals(true);
+
_tree->clear();
- for(unsigned i = 0; i < getRowMag(); i++) {
+ for(unsigned i = getFirstRow(); i <= getLastRow(); i++) {
QTreeWidgetItem* item = new QTreeWidgetItem(_tree);
- TimingEvent* te = _timingEvents[i + getLowRow()];
+ TimingEvent* te = _timingEvents[i];
item->setText(0, te->barBeatTickStr());
item->setText(1, te->rowStr());
}
- //select the line corresponding to the current row
- QTreeWidgetItem* item = _tree->topLevelItem(getCurTreeRow());
- item->setSelected(true);
-
-}
-
-void TimingPattern::resizeEvent(QResizeEvent* /*event*/) {
- fillTimingPat();
+ _tree->blockSignals(false);
}
diff --git a/muse/muse/midiedit/trackpattern.h b/muse/muse/midiedit/trackpattern.h
index ba2486a4..52bb87b3 100644
--- a/muse/muse/midiedit/trackpattern.h
+++ b/muse/muse/midiedit/trackpattern.h
@@ -132,22 +132,67 @@ class CtrlPat {
// BaseTrackPat
//------------------------------------------------------
class BaseTrackPat : public QDockWidget {
+ Q_OBJECT
+
protected:
QTreeWidget* _tree;
QMainWindow* _parent;
- unsigned _currentRow;
- unsigned _numRow; //contains the number of rows
+
+ unsigned _rowMag; //contains the number of rows
+ unsigned _firstRow; //absolute index of the first row
+ unsigned _lastRow; //absolute index of the last row, included
+ unsigned _relativeCurrentRow; //index of the current according to the tree
+ unsigned _absoluteCurrentRow; //index of the current row according to the
+ //event matrix
+ unsigned _absoluteNbrRow; //contains the number of rows of the matrix
+
+ int _fontHeight;
+
+ bool _update; //if true then the tree must updated
+
public:
- BaseTrackPat(QMainWindow* parent);
+ BaseTrackPat(QMainWindow* parent, unsigned anr = 0);
~BaseTrackPat();
- void setNumRow(unsigned);
- unsigned getNumRow();
- unsigned getRowMag(); //returns the number of rows to display according
- //to the size of the window
- unsigned getCurTreeRow();
- unsigned getLowRow();
- unsigned getUpRow();
+ void setRowMag(); //set _rowMag with the number of rows to display according
+ //to the size of the window, adjust _lastRow accordingly,
+ //assum that first row is set appropriately
+ void setFirstRow(unsigned f); //set _firstRow with f, that is the absolute index
+ //of the first row, adjust _lastRow appropriately
+ void setRelativeCurrentRow(unsigned r); //set _relativeCurrentRow with r
+ //and _absoluteCurrentRow accordingly
+ void setAbsoluteCurrentRow(unsigned a); //set _absoluteCurrentRow with a
+ //and _relativeCurrentRow accordingly
+
+ unsigned getRowMag();
+ unsigned getFirstRow();
+ unsigned getLastRow();
+ unsigned getRelativeCurrentRow();
+ unsigned getAbsoluteCurrentRow();
+
+ unsigned getAbsoluteNbrRow();
+
+ void moveRelativeCurrentRow(unsigned newIndex); //update _firstRow, _lastrow
+ //relativeCurrentRow,
+ //absoluteCurrentRow, considering
+ //that the new relative index is
+ //newIndex
+
+ void resizeEvent(QResizeEvent* /*event*/);
+
+ virtual void fillPattern() {} //fill the treeWidget with the right window of times
+ //according to _firstRow and _lastRow
+
+
+ void selectCurrentRow(); //block the signals and select the current row
+
+ signals:
+ void moveCurrentRow(unsigned i); //send the signal that the current row is moved
+ //at the relative index i
+ private slots:
+ void currentItemChanged(QTreeWidgetItem* nitem);
+ void moveRowFromSignal(unsigned index);
+
};
//------------------------------------------------------
@@ -162,7 +207,7 @@ class TrackPattern : public BaseTrackPat, public BasePat {
public:
TrackPattern(QMainWindow* parent, QString name,
unsigned firstTick, unsigned lastTick,
- int quant, PartList* pl, MidiTrack* t);
+ int quant, PartList* pl, MidiTrack* t, unsigned anr = 0);
~TrackPattern();
void add(const Event* e, unsigned tick); //add the Event e and
@@ -172,11 +217,8 @@ class TrackPattern : public BaseTrackPat, public BasePat {
MidiTrack* getTrack() {return _track;}
void setQuant(int quant);
void buildEventMatrix();
- void fillTrackPat(); //fill the treeWidget with the right set of events
- //according to _currentRow and the size of the window
- protected:
- void resizeEvent(QResizeEvent *event);
+ virtual void fillPattern();
};
//------------------------------------------------------
@@ -201,7 +243,7 @@ class TimingEvent {
class TimingPattern : public BasePat, public BaseTrackPat {
private:
- QTreeWidget* _tree;
+ //QTreeWidget* _tree;
std::vector<TimingEvent*> _timingEvents;
public:
TimingPattern(QMainWindow* parent, QString name, unsigned firstTick,
@@ -209,11 +251,8 @@ class TimingPattern : public BasePat, public BaseTrackPat {
~TimingPattern();
void buildTimingMatrix();
- void fillTimingPat(); //fill the treeWidget with the right window of times
- //according to _currentRow and the size of the window
- protected:
- void resizeEvent(QResizeEvent *event);
+ virtual void fillPattern();
};
#endif