From 6b0f9242beca3df3c5e98a215b9fe0059436770a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 2 Apr 2014 20:20:57 +0200 Subject: Initial attempt at moving sample power positions. --- dgedit/samplesorter.cc | 27 +++++++++++++++++++++++++++ dgedit/samplesorter.h | 1 + 2 files changed, 28 insertions(+) diff --git a/dgedit/samplesorter.cc b/dgedit/samplesorter.cc index 8f857a6..299a552 100644 --- a/dgedit/samplesorter.cc +++ b/dgedit/samplesorter.cc @@ -248,6 +248,30 @@ Selection *SampleSorter::getSelectionByCoordinate(int px, int py) void SampleSorter::mouseMoveEvent(QMouseEvent *event) { + if(sel_moving) { + QMap::iterator i = sorted.begin(); + while(i != sorted.end()) { + Selection &sel = i.value(); + if(sel_moving == &sel) { + float power = unmapX(event->x()); + power *= power; + power *= max; + printf("power: %f => %f\n", i.key(), power); + sorted.erase(i); + while(sorted.find(power) != sorted.end()) power += 0.000001; + sorted[power] = sel; + emit activeSelectionChanged(sorted[power]); + sel_moving = &sorted[power]; + printf("Found it!\n"); + break; + } + i++; + } + update(); + return; + } + + if(cur_thr != -1 && cur_thr < threshold.size()) { float val = unmapX(event->x()); if(val < 0.0) val = 0.0; @@ -275,6 +299,7 @@ void SampleSorter::mousePressEvent(QMouseEvent *event) Selection *psel = getSelectionByCoordinate(event->x(), event->y()); if(psel) { emit activeSelectionChanged(*psel); + sel_moving = psel; return; } @@ -302,6 +327,8 @@ void SampleSorter::mousePressEvent(QMouseEvent *event) void SampleSorter::mouseReleaseEvent(QMouseEvent *event) { if(event->button() == Qt::LeftButton) { + sel_moving = NULL; + if(threshold_is_moving) { if(threshold[cur_thr] == 0.0 || threshold[cur_thr] == 1.0) { threshold.remove(cur_thr); diff --git a/dgedit/samplesorter.h b/dgedit/samplesorter.h index 7b214e7..4ffaf2a 100644 --- a/dgedit/samplesorter.h +++ b/dgedit/samplesorter.h @@ -85,6 +85,7 @@ private: bool selection_is_moving_right; int cur_thr; + Selection *sel_moving; }; #endif/*__DRUMGIZMO_SAMPLESORTER_H__*/ -- cgit v1.2.3