shuttle control: make scroll events step by precisely 1 of the current units
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 7 Jul 2011 16:49:10 +0000 (16:49 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 7 Jul 2011 16:49:10 +0000 (16:49 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9801 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/shuttle_control.cc

index 24f70904981d905ad96c3e2d6b70a6f4e7735c1f..dd7cd753e67719da91e3c59c11c6cc9aab5c4e6f 100644 (file)
@@ -304,20 +304,42 @@ ShuttleControl::on_scroll_event (GdkEventScroll* ev)
                return true;
        }
 
+       bool semis = (Config->get_shuttle_units() == Semitones);
+
        switch (ev->direction) {
        case GDK_SCROLL_UP:
        case GDK_SCROLL_RIGHT:
-               shuttle_fract += 0.005;
+               if (semis) {
+                       if (shuttle_fract == 0) {
+                               shuttle_fract = semitones_as_fract (1, false);
+                       } else {
+                               bool rev;
+                               int st = fract_as_semitones (shuttle_fract, rev);
+                               shuttle_fract = semitones_as_fract (st + 1, rev);
+                       }
+               } else {
+                       shuttle_fract += 0.00125;
+               }
                break;
        case GDK_SCROLL_DOWN:
        case GDK_SCROLL_LEFT:
-               shuttle_fract -= 0.005;
+               if (semis) {
+                       if (shuttle_fract == 0) {
+                               shuttle_fract = semitones_as_fract (1, true);
+                       } else {
+                               bool rev;
+                               int st = fract_as_semitones (shuttle_fract, rev);
+                               shuttle_fract = semitones_as_fract (st - 1, rev);
+                       }
+               } else {
+                       shuttle_fract -= 0.00125;
+               }
                break;
        default:
                return false;
        }
-
-       if (Config->get_shuttle_units() == Semitones) {
+       
+       if (semis) {
 
                float lower_side_of_dead_zone = semitones_as_fract (-24, true);
                float upper_side_of_dead_zone = semitones_as_fract (-24, false);