summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-04-02 20:20:57 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-04-02 20:20:57 +0200
commit6b0f9242beca3df3c5e98a215b9fe0059436770a (patch)
treed31b91cd28b92836b662b4c82d60b6c145820d7a
parenta50452f0159d882348a8456cf50d72b758355332 (diff)
Initial attempt at moving sample power positions.
-rw-r--r--dgedit/samplesorter.cc27
-rw-r--r--dgedit/samplesorter.h1
2 files changed, 28 insertions, 0 deletions
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<float, Selection>::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__*/