diff options
Diffstat (limited to 'src/samplesorter.cc')
-rw-r--r-- | src/samplesorter.cc | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/samplesorter.cc b/src/samplesorter.cc index 29c24e6..15d6c3f 100644 --- a/src/samplesorter.cc +++ b/src/samplesorter.cc @@ -37,9 +37,9 @@ #define MAXFLOAT (3.40282347e+38F) #endif -SampleSorter::SampleSorter(Selections& s, Selections& p, Instrument& instrument) - : selections(s) - , selections_preview(p) +SampleSorter::SampleSorter(Ranges& s, Ranges& p, Instrument& instrument) + : ranges(s) + , ranges_preview(p) , instrument(instrument) { setMouseTracking(true); @@ -84,9 +84,9 @@ void SampleSorter::setAttackLength(int len) relayout(); } -void SampleSorter::addSelection(sel_id_t id) +void SampleSorter::addRange(sel_id_t id) { - Selection s = selections.get(id); + Range s = ranges.get(id); double energy = 0.0; for(size_t idx = s.from; @@ -98,14 +98,14 @@ void SampleSorter::addSelection(sel_id_t id) } s.energy = pow(energy, spread); - selections.update(id, s); + ranges.update(id, s); relayout(); } -void SampleSorter::addSelectionPreview(sel_id_t id) +void SampleSorter::addRangePreview(sel_id_t id) { - Selection s = selections_preview.get(id); + Range s = ranges_preview.get(id); double energy = 0.0; for(size_t idx = s.from; @@ -117,7 +117,7 @@ void SampleSorter::addSelectionPreview(sel_id_t id) } s.energy = pow(energy, spread); - selections_preview.update(id, s); + ranges_preview.update(id, s); relayout(); } @@ -128,11 +128,11 @@ void SampleSorter::relayout() max = 0.0; { - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); if(sel.energy < min) { @@ -149,11 +149,11 @@ void SampleSorter::relayout() if(show_preview) { - QVector<sel_id_t> ids = selections_preview.ids(); + QVector<sel_id_t> ids = ranges_preview.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections_preview.get(*i); + Range sel = ranges_preview.get(*i); if(sel.energy < min) { @@ -203,12 +203,12 @@ void SampleSorter::paintEvent(QPaintEvent* event) { - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); - if(*i == selections.active()) + Range sel = ranges.get(*i); + if(*i == ranges.active()) { painter.setPen(colPtSel); } @@ -226,11 +226,11 @@ void SampleSorter::paintEvent(QPaintEvent* event) if(show_preview) { - QVector<sel_id_t> ids = selections_preview.ids(); + QVector<sel_id_t> ids = ranges_preview.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections_preview.get(*i); + Range sel = ranges_preview.get(*i); painter.setPen(colPtPreview); float x = (sel.energy / max); x = sqrt(x); @@ -243,16 +243,16 @@ void SampleSorter::paintEvent(QPaintEvent* event) } -sel_id_t SampleSorter::getSelectionByCoordinate(int px, int py) +sel_id_t SampleSorter::getRangeByCoordinate(int px, int py) { // Hit radius is slithly larger than the circles themselves. int hit_r = C_RADIUS + 1; - QVector<sel_id_t> ids = selections.ids(); + QVector<sel_id_t> ids = ranges.ids(); QVector<sel_id_t>::iterator i = ids.begin(); while(i != ids.end()) { - Selection sel = selections.get(*i); + Range sel = ranges.get(*i); float x = (sel.energy/max); x = sqrt(x); x *= (float)width() * 0.9; @@ -273,14 +273,14 @@ void SampleSorter::mouseMoveEvent(QMouseEvent* event) { if(sel_moving != SEL_NONE) { - Selection sel = selections.get(sel_moving); + Range sel = ranges.get(sel_moving); if(sel_moving != SEL_NONE) { double power = unmapX(event->x()); power *= power; power *= max; sel.energy = power; - selections.update(sel_moving, sel); + ranges.update(sel_moving, sel); } update(); @@ -288,7 +288,7 @@ void SampleSorter::mouseMoveEvent(QMouseEvent* event) } else { - sel_id_t psel = getSelectionByCoordinate(event->x(), event->y()); + sel_id_t psel = getRangeByCoordinate(event->x(), event->y()); if(psel != SEL_NONE) { setCursor(Qt::OpenHandCursor); @@ -304,9 +304,9 @@ void SampleSorter::mousePressEvent(QMouseEvent* event) { if(event->button() == Qt::LeftButton) { - sel_id_t psel = getSelectionByCoordinate(event->x(), event->y()); + sel_id_t psel = getRangeByCoordinate(event->x(), event->y()); sel_moving = psel; - selections.setActive(psel); + ranges.setActive(psel); if(psel != SEL_NONE) { setCursor(Qt::ClosedHandCursor); @@ -319,7 +319,7 @@ void SampleSorter::mouseReleaseEvent(QMouseEvent* event) if(event->button() == Qt::LeftButton) { sel_moving = SEL_NONE; - sel_id_t psel = getSelectionByCoordinate(event->x(), event->y()); + sel_id_t psel = getRangeByCoordinate(event->x(), event->y()); if(psel != SEL_NONE) { setCursor(Qt::OpenHandCursor); @@ -333,8 +333,8 @@ void SampleSorter::mouseReleaseEvent(QMouseEvent* event) void SampleSorter::keyReleaseEvent(QKeyEvent* event) { - if(selections.active() != SEL_NONE && event->key() == Qt::Key_Delete) + if(ranges.active() != SEL_NONE && event->key() == Qt::Key_Delete) { - selections.remove(selections.active()); + ranges.remove(ranges.active()); } } |