macosx: implement magnification gesture as an additional fullscreen toggle
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 25 Jun 2012 15:43:46 +0000 (17:43 +0200)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Mon, 25 Jun 2012 15:46:40 +0000 (17:46 +0200)
close #6926

modules/gui/macosx/VideoView.h
modules/gui/macosx/VideoView.m

index c1a56c5..a10057b 100644 (file)
@@ -30,5 +30,6 @@
  *****************************************************************************/
 @interface VLCVoutView : NSView
 {
+    CGFloat f_cumulated_magnification;
 }
 @end
index 6824912..428d187 100644 (file)
 #import <vlc_common.h>
 #import <vlc_keys.h>
 
+#import <AppKit/NSEvent.h>
+
+@interface NSEvent (Undocumented)
++ (CGFloat)standardMagnificationThreshold;
+@end
+
 /*****************************************************************************
  * DeviceCallback: Callback triggered when the video-device variable is changed
  *****************************************************************************/
@@ -75,6 +81,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
 - (void)awakeFromNib
 {
     [self registerForDraggedTypes:[NSArray arrayWithObject: NSFilenamesPboardType]];
+
+    f_cumulated_magnification = 0.0;
 }
 
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
@@ -252,4 +260,22 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
     [[self window] makeFirstResponder: subview];
 }
 
+- (void)magnifyWithEvent:(NSEvent *)event
+{
+    f_cumulated_magnification += [event magnification];
+    CGFloat f_threshold = [NSEvent standardMagnificationThreshold];
+    BOOL b_fullscreen = [[VLCMainWindow sharedInstance] isFullscreen];
+
+    if( ( f_cumulated_magnification > f_threshold && !b_fullscreen ) || ( f_cumulated_magnification < -f_threshold && b_fullscreen ) )
+    {
+        f_cumulated_magnification = 0.0;
+        [[VLCCoreInteraction sharedInstance] toggleFullscreen];
+    }
+}
+
+- (void)beginGestureWithEvent:(NSEvent *)event
+{
+    f_cumulated_magnification = 0.0;
+}
+
 @end