[vlc-commits] macosx: implement magnification gesture as an additional fullscreen toggle
David Fuhrmann
git at videolan.org
Mon Jun 25 17:47:11 CEST 2012
vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Mon Jun 25 17:43:46 2012 +0200| [ea90ac95c6b98a9d94a0099ecc755f568d5f96c8] | committer: David Fuhrmann
macosx: implement magnification gesture as an additional fullscreen toggle
close #6926
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ea90ac95c6b98a9d94a0099ecc755f568d5f96c8
---
modules/gui/macosx/VideoView.h | 1 +
modules/gui/macosx/VideoView.m | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/modules/gui/macosx/VideoView.h b/modules/gui/macosx/VideoView.h
index c1a56c5..a10057b 100644
--- a/modules/gui/macosx/VideoView.h
+++ b/modules/gui/macosx/VideoView.h
@@ -30,5 +30,6 @@
*****************************************************************************/
@interface VLCVoutView : NSView
{
+ CGFloat f_cumulated_magnification;
}
@end
diff --git a/modules/gui/macosx/VideoView.m b/modules/gui/macosx/VideoView.m
index 6824912..428d187 100644
--- a/modules/gui/macosx/VideoView.m
+++ b/modules/gui/macosx/VideoView.m
@@ -40,6 +40,12 @@
#import <vlc_common.h>
#import <vlc_keys.h>
+#import <AppKit/NSEvent.h>
+
+ at interface NSEvent (Undocumented)
++ (CGFloat)standardMagnificationThreshold;
+ at 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
More information about the vlc-commits
mailing list