[vlc-commits] macosx: implemented scroll wheel behaviour for fullscreen volume slider, too

David Fuhrmann git at videolan.org
Fri Sep 7 22:32:10 CEST 2012


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Fri Sep  7 22:29:51 2012 +0200| [04e7801fbec46686821202423cccda790516d7b7] | committer: David Fuhrmann

macosx: implemented scroll wheel behaviour for fullscreen volume slider, too

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=04e7801fbec46686821202423cccda790516d7b7
---

 modules/gui/macosx/fspanel.h |    2 +-
 modules/gui/macosx/misc.h    |   12 +++++++-
 modules/gui/macosx/misc.m    |   66 +++++++++++++++++++++++-------------------
 3 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/modules/gui/macosx/fspanel.h b/modules/gui/macosx/fspanel.h
index 5230f25..0d4a789 100644
--- a/modules/gui/macosx/fspanel.h
+++ b/modules/gui/macosx/fspanel.h
@@ -109,7 +109,7 @@
 
 @end
 
- at interface VLCFSVolumeSlider : NSSlider
+ at interface VLCFSVolumeSlider : VLCVolumeSliderCommon
 {
 }
 - (void)drawKnobInRect: (NSRect)knobRect;
diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h
index 0172a2a..7c76bb0 100644
--- a/modules/gui/macosx/misc.h
+++ b/modules/gui/macosx/misc.h
@@ -145,10 +145,20 @@
 @end
 
 /*****************************************************************************
+ * VLCVolumeSliderCommon
+ *****************************************************************************/
+
+ at interface VLCVolumeSliderCommon : NSSlider
+
+- (void)scrollWheel:(NSEvent *)o_event;
+
+ at end
+
+/*****************************************************************************
  * ITSlider
  *****************************************************************************/
 
- at interface ITSlider : NSSlider
+ at interface ITSlider : VLCVolumeSliderCommon
 {
     NSImage *img;
     NSRect image_rect;
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index c8db07d..3cb382b 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -664,6 +664,43 @@ void _drawFrameInRect(NSRect frameRect)
 @end
 
 /*****************************************************************************
+ * VLCVolumeSliderCommon
+ *****************************************************************************/
+
+ at implementation VLCVolumeSliderCommon : NSSlider
+
+- (void)scrollWheel:(NSEvent *)o_event
+{
+    intf_thread_t * p_intf = VLCIntf;
+    CGFloat f_deltaY = [o_event deltaY];
+    CGFloat f_deltaX = [o_event deltaX];
+
+    if (!OSX_SNOW_LEOPARD && [o_event isDirectionInvertedFromDevice])
+        f_deltaX = -f_deltaX; // optimisation, actually double invertion of f_deltaY here
+    else
+        f_deltaY = -f_deltaY;
+
+    // positive for left / down, negative otherwise
+    CGFloat f_delta = f_deltaX + f_deltaY;
+    CGFloat f_abs;
+    int i_vlckey;
+
+    if (f_delta > 0.0f) {
+        i_vlckey = ACTIONID_VOL_DOWN;
+        f_abs = f_delta;
+    }
+    else {
+        i_vlckey = ACTIONID_VOL_UP;
+        f_abs = -f_delta;
+    }
+
+    for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++)
+        var_SetInteger(p_intf->p_libvlc, "key-action", i_vlckey);
+}
+
+ at end
+
+/*****************************************************************************
  * ITSlider
  *****************************************************************************/
 
@@ -707,35 +744,6 @@ void _drawFrameInRect(NSRect frameRect)
     [self drawKnobInRect: knobRect];
 }
 
-- (void)scrollWheel:(NSEvent *)o_event
-{
-    intf_thread_t * p_intf = VLCIntf;
-    CGFloat f_deltaY = [o_event deltaY];
-    CGFloat f_deltaX = [o_event deltaX];
-
-    if (!OSX_SNOW_LEOPARD && [o_event isDirectionInvertedFromDevice])
-        f_deltaX = -f_deltaX; // optimisation, actually double invertion of f_deltaY here
-    else
-        f_deltaY = -f_deltaY;
-
-    // positive for left / down, negative otherwise
-    CGFloat f_delta = f_deltaX + f_deltaY;
-    CGFloat f_abs;
-    int i_vlckey;
-
-    if (f_delta > 0.0f) {
-        i_vlckey = ACTIONID_VOL_DOWN;
-        f_abs = f_delta;
-    }
-    else {
-        i_vlckey = ACTIONID_VOL_UP;
-        f_abs = -f_delta;
-    }
-
-    for (NSUInteger i = 0; i < (int)(f_abs/4.+1.) && f_abs > 0.05 ; i++)
-        var_SetInteger( p_intf->p_libvlc, "key-action", i_vlckey );
-}
-
 @end
 
 /*****************************************************************************



More information about the vlc-commits mailing list