diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/video_out/macosx/video_window.h | 14 | ||||
-rw-r--r-- | src/video_out/macosx/video_window.m | 49 |
2 files changed, 38 insertions, 25 deletions
diff --git a/src/video_out/macosx/video_window.h b/src/video_out/macosx/video_window.h index f0f01c314..f9217f56e 100644 --- a/src/video_out/macosx/video_window.h +++ b/src/video_out/macosx/video_window.h @@ -68,14 +68,11 @@ typedef enum { @interface XineVideoWindow : NSWindow { int width, height; - BOOL keepAspectRatio; XineOpenGLView * xineView; } - (id) initWithContentSize:(NSSize)size; - (XineOpenGLView *) xineView; -- (void) setKeepsAspectRatio:(BOOL)flag; -- (BOOL) keepsAspectRatio; @end @@ -94,5 +91,16 @@ typedef enum { extern NSString *XineViewDidResizeNotification; + +/* NSWindow aspect ratio convenience methods */ + +@interface NSWindow (AspectRatioAdditions) + +- (void) setKeepsAspectRatio:(BOOL)flag; +- (BOOL) keepsAspectRatio; + +@end + + #endif /* HAVE_VIDEO_WINDOW_H */ diff --git a/src/video_out/macosx/video_window.m b/src/video_out/macosx/video_window.m index fc1bd9d4e..d3b3aec83 100644 --- a/src/video_out/macosx/video_window.m +++ b/src/video_out/macosx/video_window.m @@ -36,7 +36,6 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; @implementation XineVideoWindow - - (void) setContentSize: (NSSize) size { [xineView setViewSizeInMainThread:size]; @@ -85,7 +84,6 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; [self setContentView: xineView]; [self setTitle: @"xine video output"]; - keepAspectRatio = NO; return self; } @@ -134,22 +132,6 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; return standard_frame; } -- (void) setKeepsAspectRatio: (BOOL) flag { - if (flag) { - NSSize size = [self frame].size; - [self setAspectRatio:size]; - } - else { - [self setResizeIncrements:NSMakeSize(1.0, 1.0)]; - } - - keepAspectRatio = flag; -} - -- (BOOL) keepsAspectRatio { - return keepAspectRatio; -} - /* Delegate methods */ - (void) xineViewDidResize:(NSNotification *)note { @@ -159,7 +141,7 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; [self setFrame:[self frameRectForContentRect:frame] display:YES]; } -@end +@end /* XineVideoWindow */ @implementation XineOpenGLView @@ -236,7 +218,6 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; [super encodeWithCoder:coder]; } - - (void) dealloc { if (texture_buffer) free (texture_buffer); @@ -318,7 +299,6 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; [self setViewSizeInMainThread:size]; } - - (void) initTextures { [mutex lock]; @@ -644,4 +624,29 @@ NSString *XineViewDidResizeNotification = @"XineViewDidResizeNotification"; delegate = aDelegate; } -@end +@end /* XineOpenGLView */ + + +@implementation NSWindow (AspectRatioAdditions) + +- (void) setKeepsAspectRatio: (BOOL) flag { + if (flag) { + NSSize size = [self frame].size; + [self setAspectRatio:size]; + } + else { + [self setResizeIncrements:NSMakeSize(1.0, 1.0)]; + } +} + +/* XXX: This is 100% untested ... */ +- (BOOL) keepsAspectRatio { + NSSize size = [self aspectRatio]; + if (size.width == 0 && size.height == 0) + return false; + else + return true; +} + +@end /* NSWindow (AspectRatioAdditions) */ + |