Less crap in the dock menu.
[enjoyable.git] / NJOutputController.m
index e60a83e..bcafe0d 100644 (file)
@@ -19,7 +19,6 @@
 #import "NJOutputMouseButton.h"
 #import "NJOutputMouseMove.h"
 #import "NJOutputMouseScroll.h"
-#import "NJOutputSwitchMouseMode.h"
 
 @implementation NJOutputController
 
     
     if (row != 5) {
         scrollDirSelect.selectedSegment = -1;
+        scrollSpeedSlider.floatValue = scrollSpeedSlider.minValue;
         [scrollDirSelect resignIfFirstResponder];
-    } else if (scrollDirSelect.selectedSegment == -1)
-        scrollDirSelect.selectedSegment = 0;    
+    } else {
+        if (scrollDirSelect.selectedSegment == -1)
+            scrollDirSelect.selectedSegment = 0;
+        if (scrollDirSelect.selectedSegment < 2
+            && !scrollSpeedSlider.floatValue)
+            scrollSpeedSlider.floatValue = 15.f;
+        else if (scrollDirSelect.selectedSegment >= 2
+                 && scrollSpeedSlider.floatValue)
+            scrollSpeedSlider.floatValue = scrollSpeedSlider.minValue;
+    }
+        
 }
 
 - (IBAction)radioChanged:(NSView *)sender {
     [self commit];
 }
 
+- (void)scrollSpeedChanged:(NSSlider *)sender {
+    [radioButtons selectCellAtRow:5 column:0];
+    [sender.window makeFirstResponder:sender];
+    if (!sender.floatValue && scrollDirSelect.selectedSegment < 2)
+        scrollDirSelect.selectedSegment += 2;
+    else if (sender.floatValue && scrollDirSelect.selectedSegment >= 2)
+        scrollDirSelect.selectedSegment -= 2;
+    [self commit];
+}
+
 - (NJOutput *)currentOutput {
     return mappingsController.currentMapping[inputController.selectedInput];
 }
         }
         case 5: {
             NJOutputMouseScroll *ms = [[NJOutputMouseScroll alloc] init];
-            ms.amount = scrollDirSelect.selectedSegment ? 1 : -1;
+            ms.direction = (scrollDirSelect.selectedSegment & 1) ? 1 : -1;
+            ms.speed = scrollDirSelect.selectedSegment < 2
+                ? scrollSpeedSlider.floatValue
+                : 0.f;
             return ms;
         }
-        case 6: {
-            NJOutputSwitchMouseMode *tms = [[NJOutputSwitchMouseMode alloc] init];
-            return tms;
-        }
         default:
             return nil;
     }
     [mouseSpeedSlider setEnabled:enabled];
     [mouseBtnSelect setEnabled:enabled];
     [scrollDirSelect setEnabled:enabled];
+    [scrollSpeedSlider setEnabled:enabled];
 }
 
 - (void)loadOutput:(NJOutput *)output forInput:(NJInput *)input {
     }
     else if ([output isKindOfClass:NJOutputMouseScroll.class]) {
         [radioButtons selectCellAtRow:5 column:0];
-        scrollDirSelect.selectedSegment = [(NJOutputMouseScroll *)output amount] > 0;
-    }
-    else if ([output isKindOfClass:NJOutputSwitchMouseMode.class]) {
-        [radioButtons selectCellAtRow:6 column:0];
+        int direction = [(NJOutputMouseScroll *)output direction];
+        float speed = [(NJOutputMouseScroll *)output speed];
+        scrollDirSelect.selectedSegment = (direction > 0) + !speed * 2;
+        scrollSpeedSlider.floatValue = speed;
     } else {
         [radioButtons selectCellAtRow:self.enabled ? 0 : -1 column:0];
     }