[vlc-commits] macosx: re-implement 'keep aspect ratio' (close #6430)

Felix Paul Kühne git at videolan.org
Fri Apr 6 15:10:25 CEST 2012


vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri Apr  6 15:08:51 2012 +0200| [e5cca173ce000b75da3f7e3de6fb6f282799f3d7] | committer: Felix Paul Kühne

macosx: re-implement 'keep aspect ratio' (close #6430)
(cherry picked from commit f325462b082c9cecda54b4d9dc68f43e046cefcf)

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

 modules/gui/macosx/MainMenu.m   |    2 +-
 modules/gui/macosx/MainWindow.m |   22 ++++++++++++++++++++++
 modules/gui/macosx/controls.m   |    2 +-
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 73d3e11..4f4456a 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -988,7 +988,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
     {
         NSMenuItem *o_lmi_tmp2;
         o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""];
-        [o_lmi_tmp2 setTarget: self];
+        [o_lmi_tmp2 setTarget: [[VLCMain sharedInstance] controls]];
         [o_lmi_tmp2 setEnabled: YES];
         [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
         [o_parent setEnabled: YES];
diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 43acb9e..1d3248d 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -131,6 +131,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
 #endif
     i_lastShownVolume = -1;
     t_hide_mouse_timer = nil;
+    [o_detached_video_window setDelegate: self];
     [self useOptimizedDrawing: YES];
 
     [o_play_btn setToolTip: _NS("Play/Pause")];
@@ -1046,6 +1047,27 @@ static VLCMainWindow *_o_sharedInstance = nil;
     }
 }
 
+- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
+{
+    id videoWindow = [o_video_view window];
+    if (![[VLCMain sharedInstance] activeVideoPlayback] || nativeVideoSize.width == 0. || nativeVideoSize.height == 0. || window != videoWindow)
+        return proposedFrameSize;
+
+    if( [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked] )
+    {
+        NSRect videoWindowFrame = [videoWindow frame];
+        NSRect viewRect = [o_video_view convertRect:[o_video_view bounds] toView: nil];
+        NSRect contentRect = [videoWindow contentRectForFrameRect:videoWindowFrame];
+        float marginy = viewRect.origin.y + videoWindowFrame.size.height - contentRect.size.height;
+        float marginx = contentRect.size.width - viewRect.size.width;
+
+        proposedFrameSize.height = (proposedFrameSize.width - marginx) * nativeVideoSize.height / nativeVideoSize.width + marginy;
+    }
+
+    return proposedFrameSize;
+}
+
+
 #pragma mark -
 #pragma mark Update interface and respond to foreign events
 - (void)showDropZone
diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index 5e1517d..4deced9 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -207,7 +207,7 @@
 
 - (IBAction)lockVideosAspectRatio:(id)sender
 {
-    [[VLCCoreInteraction sharedInstance] setAspectRatioLocked: [sender state]];
+    [[VLCCoreInteraction sharedInstance] setAspectRatioLocked: ![sender state]];
     [sender setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
 }
 



More information about the vlc-commits mailing list