VLCTimeNavigationTitleView.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*****************************************************************************
  2. * VLCTimeNavigationTitleView.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2015 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Author: Tobias Conradi <videolan # tobias-conradi.de>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCTimeNavigationTitleView.h"
  13. #import "VLCSlider.h"
  14. @implementation VLCTimeNavigationTitleView
  15. -(void)awakeFromNib {
  16. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
  17. self.positionSlider.scrubbingSpeedChangePositions = @[@(0.), @(100.), @(200.), @(300)];
  18. self.timeDisplayButton.isAccessibilityElement = YES;
  19. self.aspectRatioButton.accessibilityLabel = NSLocalizedString(@"VIDEO_ASPECT_RATIO_BUTTON", nil);
  20. self.aspectRatioButton.isAccessibilityElement = YES;
  21. [self.aspectRatioButton setImage:[UIImage imageNamed:@"ratioIcon"] forState:UIControlStateNormal];
  22. self.minimizePlaybackButton.accessibilityLabel = NSLocalizedString(@"MINIMIZE_PLAYBACK_VIEW", nil);
  23. self.minimizePlaybackButton.isAccessibilityElement = YES;
  24. // workaround for radar://22897614 ( http://www.openradar.me/22897614 )
  25. UISlider *slider = self.positionSlider;
  26. if ([slider respondsToSelector:@selector(semanticContentAttribute)]) {
  27. UISemanticContentAttribute attribute = slider.semanticContentAttribute;
  28. slider.semanticContentAttribute = UISemanticContentAttributeUnspecified;
  29. slider.semanticContentAttribute = attribute;
  30. }
  31. [self setNeedsLayout];
  32. }
  33. - (void)layoutSubviews
  34. {
  35. [super layoutSubviews];
  36. CGRect remainder = self.bounds;
  37. CGRect slice;
  38. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.minimizePlaybackButton.frame), CGRectMinXEdge);
  39. self.minimizePlaybackButton.frame = slice;
  40. if (!self.aspectRatioButton.hidden) {
  41. [self.aspectRatioButton sizeToFit];
  42. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.aspectRatioButton.frame), CGRectMaxXEdge);
  43. self.aspectRatioButton.frame = slice;
  44. }
  45. [self.timeDisplayButton sizeToFit];
  46. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.timeDisplayButton.frame), CGRectMaxXEdge);
  47. self.timeDisplayButton.frame = slice;
  48. self.positionSlider.frame = remainder;
  49. }
  50. - (void)setHideAspectRatio:(BOOL)hideAspectRatio
  51. {
  52. _hideAspectRatio = hideAspectRatio;
  53. self.aspectRatioButton.hidden = hideAspectRatio;
  54. [self setNeedsLayout];
  55. }
  56. @end