summaryrefslogtreecommitdiff
path: root/dgedit/samplesorter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dgedit/samplesorter.cc')
-rw-r--r--dgedit/samplesorter.cc27
1 files changed, 27 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);