VLCTimeNavigationTitleView.m 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. [self setNeedsLayout];
  25. }
  26. - (void)layoutSubviews
  27. {
  28. [super layoutSubviews];
  29. CGRect remainder = self.bounds;
  30. CGRect slice;
  31. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.minimizePlaybackButton.frame), CGRectMinXEdge);
  32. self.minimizePlaybackButton.frame = slice;
  33. if (!self.aspectRatioButton.hidden) {
  34. [self.aspectRatioButton sizeToFit];
  35. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.aspectRatioButton.frame), CGRectMaxXEdge);
  36. self.aspectRatioButton.frame = slice;
  37. }
  38. [self.timeDisplayButton sizeToFit];
  39. CGRectDivide(remainder, &slice, &remainder, CGRectGetWidth(self.timeDisplayButton.frame), CGRectMaxXEdge);
  40. self.timeDisplayButton.frame = slice;
  41. self.positionSlider.frame = remainder;
  42. }
  43. - (void)setHideAspectRatio:(BOOL)hideAspectRatio
  44. {
  45. _hideAspectRatio = hideAspectRatio;
  46. self.aspectRatioButton.hidden = hideAspectRatio;
  47. [self setNeedsLayout];
  48. }
  49. @end