Commit c1a89c64 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

macosx: Fix aspect ratio.

This might requires some other adjustements.
parent 4ad2f8dc
......@@ -51,6 +51,8 @@
NSRecursiveLock * o_animation_lock;
BOOL b_window_is_invisible;
NSSize videoRatio;
}
- (void)controlTintChanged;
......@@ -59,6 +61,8 @@
- (void)playStatusUpdated: (int)i_status;
- (void)setSeekable: (BOOL)b_seekable;
- (void)setVideoRatio:(NSSize)ratio;
- (NSView *)mainView;
- (BOOL)isFullscreen;
......
......@@ -70,9 +70,12 @@
[o_btn_fullscreen setState: NO];
b_fullscreen = NO;
[self setDelegate:self];
/* Make sure setVisible: returns NO */
[self orderOut:self];
b_window_is_invisible = YES;
videoRatio = NSMakeSize( 0., 0. );
}
- (void)controlTintChanged
......@@ -167,6 +170,25 @@
return o_view;
}
- (void)setVideoRatio:(NSSize)ratio
{
videoRatio = ratio;
}
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
{
if( videoRatio.height == 0. || videoRatio.width == 0. )
return proposedFrameSize;
NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
NSRect contentRect = [self contentRectForFrameRect:[self frame]];
float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
float marginx = contentRect.size.width - viewRect.size.width;
proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
return proposedFrameSize;
}
/*****************************************************************************
* Fullscreen support
*/
......
......@@ -343,20 +343,10 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
}
}
- (void)scaleWindowWithFactor: (float)factor animate: (BOOL)animate
- (NSSize)voutSizeForFactor: (float)factor
{
NSSize newsize;
int i_corrected_height, i_corrected_width;
NSPoint topleftbase;
NSPoint topleftscreen;
if ( !p_vout->b_fullscreen )
{
NSView *mainView;
NSRect new_frame;
topleftbase.x = 0;
topleftbase.y = [o_window frame].size.height;
topleftscreen = [o_window convertBaseToScreen: topleftbase];
NSSize newsize;
if( p_vout->render.i_height * p_vout->render.i_aspect >
p_vout->render.i_width * VOUT_ASPECT_FACTOR )
......@@ -374,6 +364,24 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
newsize.height = (int) ( i_corrected_height * factor );
}
return newsize;
}
- (void)scaleWindowWithFactor: (float)factor animate: (BOOL)animate
{
if ( !p_vout->b_fullscreen )
{
NSSize newsize;
NSPoint topleftbase;
NSPoint topleftscreen;
NSView *mainView;
NSRect new_frame;
topleftbase.x = 0;
topleftbase.y = [o_window frame].size.height;
topleftscreen = [o_window convertBaseToScreen: topleftbase];
newsize = [self voutSizeForFactor:factor];
/* In fullscreen mode we need to use a view that is different from
* ourselves, with the VLCEmbeddedWindow */
if([o_window isKindOfClass:[VLCEmbeddedWindow class]])
......@@ -390,8 +398,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height;
[o_window setFrame: new_frame display: animate animate: animate];
[o_window setFrame:new_frame display:animate animate:animate];
p_vout->i_changes |= VOUT_SIZE_CHANGE;
}
}
......@@ -958,7 +965,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
[self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
[o_window setAspectRatio:NSMakeSize([o_window frame].size.width, [o_window frame].size.height)];
[o_embeddedwindow setVideoRatio:[self voutSizeForFactor:1.0]];
/* Make sure our window is visible, if we are not in fullscreen */
if (![o_window isFullscreen])
......
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