summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-06-09 09:07:53 +0000
committerWerner Schweer <ws.seh.de>2006-06-09 09:07:53 +0000
commit361e29c776e325b7c26379fcc5527466c9fa3696 (patch)
tree22c86c088f70db2d1e243364180e1e9f043b3408
parente7af11295d22d1506ae2b729412f46a510d91f91 (diff)
fix controller editing
-rw-r--r--muse/muse/ctrl.cpp4
-rw-r--r--muse/muse/ctrl/ctrleditor.cpp11
-rw-r--r--muse/muse/ctrl/ctrleditor.h3
3 files changed, 12 insertions, 6 deletions
diff --git a/muse/muse/ctrl.cpp b/muse/muse/ctrl.cpp
index 4fc2514d..12f8a2e6 100644
--- a/muse/muse/ctrl.cpp
+++ b/muse/muse/ctrl.cpp
@@ -331,7 +331,7 @@ void Ctrl::write(Xml& xml)
int Ctrl::val2pixelR(CVal val, int maxpixel)
{
if (_type & INT)
- return maxpixel - (maxpixel * (val.i - min.i) / (max.i-min.i));
+ return maxpixel - ((maxpixel * (val.i - min.i) + (max.i-min.i)/2) / (max.i-min.i));
else
return maxpixel - lrint(float(maxpixel) * (val.f - min.f) / (max.f-min.f));
}
@@ -356,7 +356,7 @@ CVal Ctrl::pixel2val(int pixel, int maxpixel)
// pixel, maxpixel, _type & INT, min.i, max.i);
CVal rv;
if (_type & INT) {
- rv.i = pixel * (max.i - min.i) / maxpixel + min.i;
+ rv.i = (pixel * (max.i - min.i) + (maxpixel+min.i)/2) / maxpixel + min.i;
if (rv.i < min.i)
rv.i = min.i;
else if (rv.i > max.i)
diff --git a/muse/muse/ctrl/ctrleditor.cpp b/muse/muse/ctrl/ctrleditor.cpp
index ec12f872..e0e1db3b 100644
--- a/muse/muse/ctrl/ctrleditor.cpp
+++ b/muse/muse/ctrl/ctrleditor.cpp
@@ -212,6 +212,7 @@ void CtrlEditor::mousePress(const QPoint& pos, int button)
ciCtrlVal e = ctrl()->upper_bound(pos2.time(tt));
for (ciCtrlVal i = s; i != e; ++i) {
int yy = ctrl()->val2pixelR(i->second, wh);
+ startY = yy;
if ((yy >= (y-HANDLE2)) && (yy < (y + HANDLE2))) {
if (tt == AL::TICKS)
selected.setTick(i->first);
@@ -222,8 +223,10 @@ void CtrlEditor::mousePress(const QPoint& pos, int button)
song->removeControllerVal(ctrlTrack(), ctrl()->id(), i->first);
dragy = -1;
}
- else
+ else {
dragy = yy;
+ dragYoffset = dragy - y;
+ }
tc()->widget()->update();
break;
}
@@ -302,8 +305,8 @@ void CtrlEditor::mouseRelease()
if (ctrl()->id() == CTRL_VELOCITY || ctrl()->id() == CTRL_SVELOCITY)
song->endUndo(SC_EVENT_MODIFIED);
else {
- if (dragy != -1) {
- int wh = cheight();
+ if (dragy != -1 && dragy != startY) {
+ int wh = cheight();
CVal val = ctrl()->pixel2val(dragy, wh);
// modify controller:
song->addControllerVal(ctrlTrack(), ctrl(), selected, val);
@@ -371,7 +374,7 @@ void CtrlEditor::mouseMove(const QPoint& pos)
}
else {
if (dragy != -1)
- dragy = pos.y();
+ dragy = pos.y() + dragYoffset;
}
tc()->widget()->update();
}
diff --git a/muse/muse/ctrl/ctrleditor.h b/muse/muse/ctrl/ctrleditor.h
index e066431f..d0f2152e 100644
--- a/muse/muse/ctrl/ctrleditor.h
+++ b/muse/muse/ctrl/ctrleditor.h
@@ -34,6 +34,9 @@ class Track;
class CtrlEditor {
bool _drawCtrlName;
int dragx, dragy;
+ int dragYoffset;
+ int startY;
+
int lselected; // cached pixel position of current value
AL::Pos selected; // current selected controller value