Browse Source

Aspen: add hiding/showing controllers panel by tapping on the screen

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Gleb Pinigin 12 years ago
parent
commit
714f9097ad
2 changed files with 41 additions and 1 deletions
  1. 2 0
      AspenProject/VLCMovieViewController.h
  2. 39 1
      AspenProject/VLCMovieViewController.m

+ 2 - 0
AspenProject/VLCMovieViewController.h

@@ -23,6 +23,8 @@
     UIButton *_audioSwitcherButton;
     UIView *_controllerPanel;
 
+    BOOL _controlsHidden;
+
     UIActionSheet *_subtitleActionSheet;
     UIActionSheet *_audiotrackActionSheet;
 }

+ 39 - 1
AspenProject/VLCMovieViewController.m

@@ -9,7 +9,7 @@
 #import "VLCMovieViewController.h"
 #import "VLCExternalDisplayController.h"
 
-@interface VLCMovieViewController ()
+@interface VLCMovieViewController () <UIGestureRecognizerDelegate>
 @property (nonatomic, retain) UIPopoverController *masterPopoverController;
 @property (nonatomic, retain) UIWindow *externalWindow;
 @end
@@ -59,6 +59,12 @@
     if ([self hasExternalDisplay]) {
         [self showOnExternalDisplay];
     }
+
+    _movieView.userInteractionEnabled = NO;
+    UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toogleControlsVisible)];
+    recognizer.delegate = self;
+    [self.view addGestureRecognizer:recognizer];
+    [recognizer release];
 }
 
 - (void)viewWillAppear:(BOOL)animated
@@ -99,6 +105,38 @@
     return self;
 }
 
+#pragma mark - controls visibility
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
+{
+    if (touch.view != self.view) {
+        return NO;
+    }
+
+    return YES;
+}
+
+- (void)toogleControlsVisible
+{
+    _controlsHidden = !_controlsHidden;
+    CGFloat alpha = _controlsHidden? 0.0f: 1.0f;
+
+    if (!_controlsHidden) {
+        _controllerPanel.hidden = NO;
+        _controllerPanel.alpha = 0.0f;
+    }
+
+    void (^animationBlock)() = ^() {
+        _controllerPanel.alpha = alpha;
+    };
+
+    void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
+        _controllerPanel.hidden = _controlsHidden;
+    };
+
+    [UIView animateWithDuration:0.3f animations:animationBlock completion:completionBlock];
+}
+
 #pragma mark - controls
 
 - (IBAction)closePlayback:(id)sender