VLCTimeNavigationTitleView.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.aspectRatioButton.accessibilityLabel = NSLocalizedString(@"VIDEO_ASPECT_RATIO_BUTTON", nil);
  19. [self.aspectRatioButton setImage:[UIImage imageNamed:@"ratioIcon"] forState:UIControlStateNormal];
  20. self.minimizePlaybackButton.accessibilityLabel = NSLocalizedString(@"MINIMIZE_PLAYBACK_VIEW", nil);
  21. // workaround for radar://22897614 ( http://www.openradar.me/22897614 )
  22. UISlider *slider = self.positionSlider;
  23. if ([slider respondsToSelector:@selector(semanticContentAttribute)]) {
  24. UISemanticContentAttribute attribute = slider.semanticContentAttribute;
  25. slider.semanticContentAttribute = UISemanticContentAttributeUnspecified;
  26. slider.semanticContentAttribute = attribute;
  27. }
  28. [self setNeedsLayout];
  29. [super awakeFromNib];
  30. }
  31. - (void)layoutSubviews
  32. {
  33. [super layoutSubviews];
  34. CGRect remainder = self.bounds;
  35. CGRect slice;
  36. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.minimizePlaybackButton.frame), CGRectMinXEdge);
  37. self.minimizePlaybackButton.frame = slice;
  38. if (!self.aspectRatioButton.hidden) {
  39. [self.aspectRatioButton sizeToFit];
  40. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.aspectRatioButton.frame), CGRectMaxXEdge);
  41. self.aspectRatioButton.frame = slice;
  42. }
  43. [self.timeDisplayButton sizeToFit];
  44. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.timeDisplayButton.frame), CGRectMaxXEdge);
  45. self.timeDisplayButton.frame = slice;
  46. self.positionSlider.frame = remainder;
  47. }
  48. - (void)setHideAspectRatio:(BOOL)hideAspectRatio
  49. {
  50. _hideAspectRatio = hideAspectRatio;
  51. self.aspectRatioButton.hidden = hideAspectRatio;
  52. [self setNeedsLayout];
  53. }
  54. @end