ホイールによるボリュームと再生時間のコントロールの調整。(#20760)
@@ -85,4 +85,40 @@ | ||
85 | 85 | |
86 | 86 | [super keyDown:event]; |
87 | 87 | } |
88 | + | |
89 | +- (void)scrollWheel:(NSEvent *)theEvent | |
90 | +{ | |
91 | + BOOL cancelVolumeControl = NO; | |
92 | + CGFloat deltaX = [theEvent deltaX]; | |
93 | + CGFloat deltaY = [theEvent deltaY]; | |
94 | + | |
95 | + if(fabs(deltaY / deltaX) < 0.5) { | |
96 | + cancelVolumeControl = YES; | |
97 | + } | |
98 | + | |
99 | +// NSLog(@"X -> %.2f, Y -> %.2f", deltaX, deltaY); | |
100 | + | |
101 | + if(deltaX != 0) { | |
102 | + int sign = deltaX < 0 ? -1 : 1; | |
103 | + if(sign == -1) deltaX = -deltaX; | |
104 | + | |
105 | + QTMovie *movie = [self movie]; | |
106 | + QTTime current = [movie currentTime]; | |
107 | + NSTimeInterval cur; | |
108 | + if(!QTGetTimeInterval(current, &cur)) return; | |
109 | + | |
110 | + CGFloat newTime = cur - sign * 0.08 * (0.1 * deltaX * deltaX + deltaX); | |
111 | + if(newTime < 0) newTime = 0; | |
112 | + QTTime new = QTMakeTimeWithTimeInterval(newTime); | |
113 | + | |
114 | + [movie setCurrentTime:new]; | |
115 | + } | |
116 | + if(deltaY != 0 && !cancelVolumeControl) { | |
117 | + QTMovie *movie = [self movie]; | |
118 | + CGFloat vol = [movie volume]; | |
119 | + [movie setVolume:vol + deltaY / 20]; | |
120 | + } | |
121 | + | |
122 | +// [super scrollWheel:theEvent]; | |
123 | +} | |
88 | 124 | @end |