VLCTimeNavigationTitleView.m 2.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*****************************************************************************
 * VLCTimeNavigationTitleView.m
 * VLC for iOS
 *****************************************************************************
 * Copyright (c) 2015 VideoLAN. All rights reserved.
 * $Id$
 *
 * Author: Tobias Conradi <videolan # tobias-conradi.de>
 *
 * Refer to the COPYING file of the official project for license.
 *****************************************************************************/


#import "VLCTimeNavigationTitleView.h"
#import "VLCSlider.h"

@implementation VLCTimeNavigationTitleView

-(void)awakeFromNib {

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        self.positionSlider.scrubbingSpeedChangePositions = @[@(0.), @(100.), @(200.), @(300)];

    self.timeDisplayButton.isAccessibilityElement = YES;

    self.aspectRatioButton.accessibilityLabel = NSLocalizedString(@"VIDEO_ASPECT_RATIO_BUTTON", nil);
    self.aspectRatioButton.isAccessibilityElement = YES;
28

Felix Paul Kühne's avatar
Felix Paul Kühne committed
29
    [self.aspectRatioButton setImage:[UIImage imageNamed:@"ratioIcon"] forState:UIControlStateNormal];
30

31 32 33
    self.minimizePlaybackButton.accessibilityLabel = NSLocalizedString(@"MINIMIZE_PLAYBACK_VIEW", nil);
    self.minimizePlaybackButton.isAccessibilityElement = YES;

34 35 36 37 38 39 40 41
    // workaround for radar://22897614 ( http://www.openradar.me/22897614 )
    UISlider *slider = self.positionSlider;
    if ([slider respondsToSelector:@selector(semanticContentAttribute)]) {
        UISemanticContentAttribute attribute = slider.semanticContentAttribute;
        slider.semanticContentAttribute = UISemanticContentAttributeUnspecified;
        slider.semanticContentAttribute = attribute;
    }

42
    [self setNeedsLayout];
43 44

    [super awakeFromNib];
45 46 47 48 49 50 51 52
}

- (void)layoutSubviews
{
    [super layoutSubviews];

    CGRect remainder = self.bounds;
    CGRect slice;
53 54 55 56

    CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.minimizePlaybackButton.frame), CGRectMinXEdge);
    self.minimizePlaybackButton.frame = slice;

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    if (!self.aspectRatioButton.hidden) {
        [self.aspectRatioButton sizeToFit];
        CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.aspectRatioButton.frame), CGRectMaxXEdge);
        self.aspectRatioButton.frame = slice;
    }

    [self.timeDisplayButton sizeToFit];
    CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.timeDisplayButton.frame), CGRectMaxXEdge);
    self.timeDisplayButton.frame = slice;

    self.positionSlider.frame = remainder;
}

- (void)setHideAspectRatio:(BOOL)hideAspectRatio
{
    _hideAspectRatio = hideAspectRatio;
    self.aspectRatioButton.hidden = hideAspectRatio;
    [self setNeedsLayout];
}


@end