Commit f325462b authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: re-implement 'keep aspect ratio' (close #6430)

parent 6cbf48f1
...@@ -988,7 +988,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -988,7 +988,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
{ {
NSMenuItem *o_lmi_tmp2; NSMenuItem *o_lmi_tmp2;
o_lmi_tmp2 = [o_menu addItemWithTitle: _NS("Lock Aspect Ratio") action: @selector(lockVideosAspectRatio:) keyEquivalent: @""]; 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 setEnabled: YES];
[o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]]; [o_lmi_tmp2 setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
[o_parent setEnabled: YES]; [o_parent setEnabled: YES];
......
...@@ -131,6 +131,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -131,6 +131,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
#endif #endif
i_lastShownVolume = -1; i_lastShownVolume = -1;
t_hide_mouse_timer = nil; t_hide_mouse_timer = nil;
[o_detached_video_window setDelegate: self];
[self useOptimizedDrawing: YES]; [self useOptimizedDrawing: YES];
[o_play_btn setToolTip: _NS("Play/Pause")]; [o_play_btn setToolTip: _NS("Play/Pause")];
...@@ -1046,6 +1047,27 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -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 -
#pragma mark Update interface and respond to foreign events #pragma mark Update interface and respond to foreign events
- (void)showDropZone - (void)showDropZone
......
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
- (IBAction)lockVideosAspectRatio:(id)sender - (IBAction)lockVideosAspectRatio:(id)sender
{ {
[[VLCCoreInteraction sharedInstance] setAspectRatioLocked: [sender state]]; [[VLCCoreInteraction sharedInstance] setAspectRatioLocked: ![sender state]];
[sender setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]]; [sender setState: [[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment