summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Suhr Christensen <jsc@umbraculum.org>2014-04-02 20:37:19 +0200
committerJonas Suhr Christensen <jsc@umbraculum.org>2014-04-02 20:37:19 +0200
commit8d2f80f5e83ed9b22574562af0db0590f2c67c1f (patch)
tree8ee3055d9e22997ce78d325282fec0e82f755125
parent60aaa8343c04908da31f031781ca16c01ab51049 (diff)
parent6b0f9242beca3df3c5e98a215b9fe0059436770a (diff)
Merge branch 'master' of http://git.drumgizmo.org/drumgizmo
-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__*/