fullscreen_cocoa.patch

patch file for supporting full screen mode for Cocoa bindings - Takahiro Horikawa, 2012-06-13 03:16 am

Download (4.9 kB)

 
opencv/modules/highgui/src/window.cpp (working copy)
62 62
            cvSetModeWindow_GTK(name,prop_value);
63 63
        #elif defined (HAVE_CARBON)
64 64
            cvSetModeWindow_CARBON(name,prop_value);
65
        #elif defined (HAVE_COCOA)
66
            cvSetModeWindow_COCOA(name,prop_value);
65 67
        #endif
66 68
    break;
67 69

  
......
99 101
            return cvGetModeWindow_GTK(name);
100 102
        #elif defined (HAVE_CARBON)
101 103
            return cvGetModeWindow_CARBON(name);
104
        #elif defined (HAVE_COCOA)
105
            return cvGetModeWindow_COCOA(name);
102 106
        #else
103 107
            return -1;
104 108
        #endif
opencv/modules/highgui/src/window_cocoa.mm (working copy)
109 109
	CvMouseCallback mouseCallback;
110 110
	void *mouseParam;
111 111
	BOOL autosize;
112
	BOOL firstContent; 
112
	BOOL firstContent;
113
    int status;
113 114
}
114 115
@property(assign) CvMouseCallback mouseCallback;
115 116
@property(assign) void *mouseParam;
116 117
@property(assign) BOOL autosize;
117 118
@property(assign) BOOL firstContent; 
118 119
@property(retain) NSMutableDictionary *sliders;
120
@property(readwrite) int status;
119 121
- (CVView *)contentView;
120 122
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags;
121 123
- (void)cvMouseEvent:(NSEvent *)event;
......
533 535
	return returnCode;
534 536
}
535 537

  
538
double cvGetModeWindow_COCOA( const char* name )
539
{
540
    double result = -1;
541
    CVWindow *window = nil;
542

  
543
    CV_FUNCNAME( "cvGetModeWindow_COCOA" );
544

  
545
    __BEGIN__;
546
    if( name == NULL )
547
    {
548
        CV_ERROR( CV_StsNullPtr, "NULL name string" );
549
    }
550

  
551
    window = cvGetWindow( name );
552
    if ( window == NULL )
553
    {
554
        CV_ERROR( CV_StsNullPtr, "NULL window" );
555
    }
556

  
557
    result = window.status;
558

  
559
    __END__;
560
    return result;
561
}
562

  
563
void cvSetModeWindow_COCOA( const char* name, double prop_value )
564
{
565
    CVWindow *window = nil;
566
    NSDictionary *fullscreenOptions = nil;
567
    NSAutoreleasePool* localpool = nil;
568

  
569
    CV_FUNCNAME( "cvSetModeWindow_COCOA" );
570

  
571
    __BEGIN__;
572
    if( name == NULL )
573
    {
574
        CV_ERROR( CV_StsNullPtr, "NULL name string" );
575
    }
576

  
577
    window = cvGetWindow(name);
578
    if ( window == NULL )
579
    {
580
        CV_ERROR( CV_StsNullPtr, "NULL window" );
581
    }
582

  
583
    if ( [window autosize] )
584
    {
585
        return;
586
    }
587

  
588
    localpool = [[NSAutoreleasePool alloc] init];
589

  
590
    fullscreenOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSFullScreenModeSetting];
591
    if ( [[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_NORMAL )
592
    {
593
        [[window contentView] exitFullScreenModeWithOptions:fullscreenOptions];
594
        window.status=CV_WINDOW_NORMAL;
595
    }
596
    else if( ![[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_FULLSCREEN )
597
    {
598
        [[window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:fullscreenOptions];
599
        window.status=CV_WINDOW_FULLSCREEN;
600
    }
601

  
602
    [localpool drain];
603

  
604
    __END__;
605
}
606

  
536 607
@implementation CVWindow 
537 608

  
538 609
@synthesize mouseCallback;
......
540 611
@synthesize autosize;
541 612
@synthesize firstContent; 
542 613
@synthesize sliders;
614
@synthesize status;
543 615

  
544 616
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags {
545 617
	//cout << "cvSendMouseEvent" << endl; 
......
787 859
	NSAutoreleasePool* localpool = [[NSAutoreleasePool alloc] init];
788 860
	CVWindow *cvwindow = (CVWindow *)[self window];
789 861
	int height = 0;
790
	for(NSString *key in [cvwindow sliders]) {
791
		height += [[[cvwindow sliders] valueForKey:key] frame].size.height;
792
	}
862
    if ([cvwindow respondsToSelector:@selector(sliders)]) {
863
        for(NSString *key in [cvwindow sliders]) {
864
            height += [[[cvwindow sliders] valueForKey:key] frame].size.height;
865
        }
866
    }
793 867
	
794 868

  
795 869
	NSRect imageRect = {{0,0}, {[image size].width, [image size].height}};
opencv/modules/highgui/src/precomp.hpp (working copy)
172 172
void cvSetModeWindow_W32(const char* name, double prop_value);
173 173
void cvSetModeWindow_GTK(const char* name, double prop_value);
174 174
void cvSetModeWindow_CARBON(const char* name, double prop_value);
175
void cvSetModeWindow_COCOA(const char* name, double prop_value);
175 176

  
176 177
double cvGetModeWindow_W32(const char* name);
177 178
double cvGetModeWindow_GTK(const char* name);
178 179
double cvGetModeWindow_CARBON(const char* name);
180
double cvGetModeWindow_COCOA(const char* name);
179 181

  
180 182
double cvGetPropWindowAutoSize_W32(const char* name);
181 183
double cvGetPropWindowAutoSize_GTK(const char* name);