vlc | branch: master | Felix Paul Kühne <[email protected]> | Fri Apr 6 15:08:51 2012 +0200| [f325462b082c9cecda54b4d9dc68f43e046cefcf] | committer: Felix Paul Kühne
macosx: re-implement 'keep aspect ratio' (close #6430) > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f325462b082c9cecda54b4d9dc68f43e046cefcf --- 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 b12cab7..5938fbe 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]]; } _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
