Commit 7ef21141 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

added fullscreen mode on Mac (patch #2040 by Takahiro Horikawa)

parent b5eb318a
...@@ -172,10 +172,12 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc, ...@@ -172,10 +172,12 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename, int fourcc,
void cvSetModeWindow_W32(const char* name, double prop_value); void cvSetModeWindow_W32(const char* name, double prop_value);
void cvSetModeWindow_GTK(const char* name, double prop_value); void cvSetModeWindow_GTK(const char* name, double prop_value);
void cvSetModeWindow_CARBON(const char* name, double prop_value); void cvSetModeWindow_CARBON(const char* name, double prop_value);
void cvSetModeWindow_COCOA(const char* name, double prop_value);
double cvGetModeWindow_W32(const char* name); double cvGetModeWindow_W32(const char* name);
double cvGetModeWindow_GTK(const char* name); double cvGetModeWindow_GTK(const char* name);
double cvGetModeWindow_CARBON(const char* name); double cvGetModeWindow_CARBON(const char* name);
double cvGetModeWindow_COCOA(const char* name);
double cvGetPropWindowAutoSize_W32(const char* name); double cvGetPropWindowAutoSize_W32(const char* name);
double cvGetPropWindowAutoSize_GTK(const char* name); double cvGetPropWindowAutoSize_GTK(const char* name);
......
...@@ -62,6 +62,8 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu ...@@ -62,6 +62,8 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
cvSetModeWindow_GTK(name,prop_value); cvSetModeWindow_GTK(name,prop_value);
#elif defined (HAVE_CARBON) #elif defined (HAVE_CARBON)
cvSetModeWindow_CARBON(name,prop_value); cvSetModeWindow_CARBON(name,prop_value);
#elif defined (HAVE_COCOA)
cvSetModeWindow_COCOA(name,prop_value);
#endif #endif
break; break;
...@@ -99,6 +101,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id) ...@@ -99,6 +101,8 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
return cvGetModeWindow_GTK(name); return cvGetModeWindow_GTK(name);
#elif defined (HAVE_CARBON) #elif defined (HAVE_CARBON)
return cvGetModeWindow_CARBON(name); return cvGetModeWindow_CARBON(name);
#elif defined (HAVE_COCOA)
return cvGetModeWindow_COCOA(name);
#else #else
return -1; return -1;
#endif #endif
......
...@@ -109,13 +109,15 @@ static bool wasInitialized = false; ...@@ -109,13 +109,15 @@ static bool wasInitialized = false;
CvMouseCallback mouseCallback; CvMouseCallback mouseCallback;
void *mouseParam; void *mouseParam;
BOOL autosize; BOOL autosize;
BOOL firstContent; BOOL firstContent;
int status;
} }
@property(assign) CvMouseCallback mouseCallback; @property(assign) CvMouseCallback mouseCallback;
@property(assign) void *mouseParam; @property(assign) void *mouseParam;
@property(assign) BOOL autosize; @property(assign) BOOL autosize;
@property(assign) BOOL firstContent; @property(assign) BOOL firstContent;
@property(retain) NSMutableDictionary *sliders; @property(retain) NSMutableDictionary *sliders;
@property(readwrite) int status;
- (CVView *)contentView; - (CVView *)contentView;
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags; - (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags;
- (void)cvMouseEvent:(NSEvent *)event; - (void)cvMouseEvent:(NSEvent *)event;
...@@ -533,6 +535,75 @@ CV_IMPL int cvWaitKey (int maxWait) ...@@ -533,6 +535,75 @@ CV_IMPL int cvWaitKey (int maxWait)
return returnCode; return returnCode;
} }
double cvGetModeWindow_COCOA( const char* name )
{
double result = -1;
CVWindow *window = nil;
CV_FUNCNAME( "cvGetModeWindow_COCOA" );
__BEGIN__;
if( name == NULL )
{
CV_ERROR( CV_StsNullPtr, "NULL name string" );
}
window = cvGetWindow( name );
if ( window == NULL )
{
CV_ERROR( CV_StsNullPtr, "NULL window" );
}
result = window.status;
__END__;
return result;
}
void cvSetModeWindow_COCOA( const char* name, double prop_value )
{
CVWindow *window = nil;
NSDictionary *fullscreenOptions = nil;
NSAutoreleasePool* localpool = nil;
CV_FUNCNAME( "cvSetModeWindow_COCOA" );
__BEGIN__;
if( name == NULL )
{
CV_ERROR( CV_StsNullPtr, "NULL name string" );
}
window = cvGetWindow(name);
if ( window == NULL )
{
CV_ERROR( CV_StsNullPtr, "NULL window" );
}
if ( [window autosize] )
{
return;
}
localpool = [[NSAutoreleasePool alloc] init];
fullscreenOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSFullScreenModeSetting];
if ( [[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_NORMAL )
{
[[window contentView] exitFullScreenModeWithOptions:fullscreenOptions];
window.status=CV_WINDOW_NORMAL;
}
else if( ![[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_FULLSCREEN )
{
[[window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:fullscreenOptions];
window.status=CV_WINDOW_FULLSCREEN;
}
[localpool drain];
__END__;
}
@implementation CVWindow @implementation CVWindow
@synthesize mouseCallback; @synthesize mouseCallback;
...@@ -540,6 +611,7 @@ CV_IMPL int cvWaitKey (int maxWait) ...@@ -540,6 +611,7 @@ CV_IMPL int cvWaitKey (int maxWait)
@synthesize autosize; @synthesize autosize;
@synthesize firstContent; @synthesize firstContent;
@synthesize sliders; @synthesize sliders;
@synthesize status;
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags { - (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags {
//cout << "cvSendMouseEvent" << endl; //cout << "cvSendMouseEvent" << endl;
...@@ -787,9 +859,11 @@ CV_IMPL int cvWaitKey (int maxWait) ...@@ -787,9 +859,11 @@ CV_IMPL int cvWaitKey (int maxWait)
NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
CVWindow *cvwindow = (CVWindow *)[self window]; CVWindow *cvwindow = (CVWindow *)[self window];
int height = 0; int height = 0;
for(NSString *key in [cvwindow sliders]) { if ([cvwindow respondsToSelector:@selector(sliders)]) {
height += [[[cvwindow sliders] valueForKey:key] frame].size.height; for(NSString *key in [cvwindow sliders]) {
} height += [[[cvwindow sliders] valueForKey:key] frame].size.height;
}
}
NSRect imageRect = {{0,0}, {[image size].width, [image size].height}}; NSRect imageRect = {{0,0}, {[image size].width, [image size].height}};
......
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