demux: mkv: handle WAVE_FORMAT_MPEG_ADTS_AAC
[vlc.git] / modules / gui / macosx / VLCDefaultValueSlider.m
blobaecb590cbcfdd22cbabd238853565f55b87349e8
1 /*****************************************************************************
2  * VLCDefaultValueSlider.m: Custom NSSlider which allows a defaultValue
3  *****************************************************************************
4  * Copyright (C) 2016 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Marvin Scholz <epirat07 -at- gmail -dot- com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
24 #import "VLCDefaultValueSlider.h"
25 #import "VLCDefaultValueSliderCell.h"
27 @implementation VLCDefaultValueSlider
29 - (instancetype)initWithCoder:(NSCoder *)coder
31     if ([coder isKindOfClass: [NSKeyedUnarchiver class]]) {
32         NSKeyedUnarchiver *keyedUnarchiver = (id)coder;
33         NSString *oldClass = NSStringFromClass([self.superclass cellClass]);
34         [keyedUnarchiver setClass:[VLCDefaultValueSliderCell class] forClassName:oldClass];
35     }
36     self = [super initWithCoder:coder];
37     if (self) {
38         _isScrollable = YES;
39     }
40     return self;
43 - (void)scrollWheel:(NSEvent *)event
45     if (!_isScrollable)
46         return [super scrollWheel:event];
47     double increment;
48     CGFloat deltaY = [event scrollingDeltaY];
49     double range = [self maxValue] - [self minValue];
51     // Scroll less for high precision, else it's too fast
52     if (event.hasPreciseScrollingDeltas) {
53         increment = (range * 0.002) * deltaY;
54     } else {
55         if (deltaY == 0.0)
56             return;
57         increment = (range * 0.01 * deltaY);
58     }
60     // If scrolling is inversed, increment in other direction
61     if (!event.isDirectionInvertedFromDevice)
62         increment = -increment;
64     [self setDoubleValue:self.doubleValue - increment];
65     [self sendAction:self.action to:self.target];
68 - (void)setDefaultValue:(double)value
70     [(VLCDefaultValueSliderCell *)self.cell setDefaultValue:value];
73 - (double)defaultValue
75     return [(VLCDefaultValueSliderCell *)self.cell defaultValue];
78 @end