Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
05acf40a
Commit
05acf40a
authored
Jun 21, 2017
by
Matt Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove ARC and auto synthesize assumptions in cocoa_window.mm
parent
2c30f358
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
92 deletions
+70
-92
window_cocoa.mm
modules/highgui/src/window_cocoa.mm
+70
-92
No files found.
modules/highgui/src/window_cocoa.mm
View file @
05acf40a
...
@@ -82,46 +82,42 @@ static NSAutoreleasePool *pool = nil;
...
@@ -82,46 +82,42 @@ static NSAutoreleasePool *pool = nil;
static NSMutableDictionary *windows = nil;
static NSMutableDictionary *windows = nil;
static bool wasInitialized = false;
static bool wasInitialized = false;
@interface CVView : NSView
@interface CVView : NSView {
{
NSImage *image;
NSImage *_image;
}
}
@property(
strong
) NSImage *image;
@property(
retain
) NSImage *image;
- (void)setImageData:(CvArr *)arr;
- (void)setImageData:(CvArr *)arr;
@end
@end
@interface CVSlider : NSView
@interface CVSlider : NSView {
{
NSSlider *slider;
NSSlider *_slider;
NSTextField *name;
NSTextField *_name;
int *value;
int *_value;
void *userData;
void *_userData;
CvTrackbarCallback callback;
CvTrackbarCallback _callback;
CvTrackbarCallback2 callback2;
CvTrackbarCallback2 _callback2;
}
}
@property(retain) NSSlider *slider;
@property(strong) NSSlider *slider;
@property(retain) NSTextField *name;
@property(strong) NSTextField *name;
@property(assign) int *value;
@property(assign) int *value;
@property(assign) void *userData;
@property(assign) void *userData;
@property(assign) CvTrackbarCallback callback;
@property(assign) CvTrackbarCallback callback;
@property(assign) CvTrackbarCallback2 callback2;
@property(assign) CvTrackbarCallback2 callback2;
@end
@end
@interface CVWindow : NSWindow
@interface CVWindow : NSWindow {
{
NSMutableDictionary *sliders;
CvMouseCallback _mouseCallback;
CvMouseCallback mouseCallback;
void *_mouseParam;
void *mouseParam;
BOOL _autosize;
BOOL autosize;
BOOL _firstContent;
BOOL firstContent;
NSMutableDictionary *_sliders;
int status;
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(
strong
) NSMutableDictionary *sliders;
@property(
retain
) NSMutableDictionary *sliders;
@property(readwrite) int status;
@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;
...
@@ -701,21 +697,14 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -701,21 +697,14 @@ void cv::setWindowTitle(const String& winname, const String& title)
}
}
@implementation CVWindow
@implementation CVWindow
#if defined(__LP64__)
@synthesize mouseCallback;
@synthesize mouseCallback;
@synthesize mouseParam;
@synthesize mouseParam;
@synthesize autosize;
@synthesize autosize;
@synthesize firstContent;
@synthesize firstContent;
@synthesize sliders;
@synthesize sliders;
@synthesize status;
@synthesize status;
#else // 32-bit Obj-C does not have automatic synthesize
@synthesize mouseCallback = _mouseCallback;
@synthesize mouseParam = _mouseParam;
@synthesize autosize = _autosize;
@synthesize firstContent = _firstContent;
@synthesize sliders = _sliders;
@synthesize status = _status;
#endif
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags {
- (void)cvSendMouseEvent:(NSEvent *)event type:(int)type flags:(int)flags {
(void)event;
(void)event;
//cout << "cvSendMouseEvent" << endl;
//cout << "cvSendMouseEvent" << endl;
...
@@ -740,13 +729,12 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -740,13 +729,12 @@ void cv::setWindowTitle(const String& winname, const String& title)
mp.y = mp.y * imageSize.height / std::max(viewHeight, 1.);
mp.y = mp.y * imageSize.height / std::max(viewHeight, 1.);
if( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height )
if( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height )
_mouseCallback(type, mp.x, mp.y, flags, _
mouseParam);
mouseCallback(type, mp.x, mp.y, flags,
mouseParam);
}
}
- (void)cvMouseEvent:(NSEvent *)event {
- (void)cvMouseEvent:(NSEvent *)event {
//cout << "cvMouseEvent" << endl;
//cout << "cvMouseEvent" << endl;
if(!mouseCallback)
if([self mouseCallback] == nil)
return;
return;
int flags = 0;
int flags = 0;
...
@@ -806,13 +794,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -806,13 +794,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
- (void)createSliderWithName:(const char *)name maxValue:(int)max value:(int *)value callback:(CvTrackbarCallback)callback {
- (void)createSliderWithName:(const char *)name maxValue:(int)max value:(int *)value callback:(CvTrackbarCallback)callback {
//cout << "createSliderWithName" << endl;
//cout << "createSliderWithName" << endl;
if(
_
sliders == nil)
if(sliders == nil)
_
sliders = [[NSMutableDictionary alloc] init];
sliders = [[NSMutableDictionary alloc] init];
NSString *cvname = [NSString stringWithFormat:@"%s", name];
NSString *cvname = [NSString stringWithFormat:@"%s", name];
// Avoid overwriting slider
// Avoid overwriting slider
if([
_
sliders valueForKey:cvname]!=nil)
if([sliders valueForKey:cvname]!=nil)
return;
return;
// Create slider
// Create slider
...
@@ -831,11 +819,11 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -831,11 +819,11 @@ void cv::setWindowTitle(const String& winname, const String& title)
[slider setCallback:callback];
[slider setCallback:callback];
// Save slider
// Save slider
[
_
sliders setValue:slider forKey:cvname];
[sliders setValue:slider forKey:cvname];
[[self contentView] addSubview:slider];
[[self contentView] addSubview:slider];
//update contentView size to contain
_
sliders
//update contentView size to contain sliders
NSSize viewSize=[[self contentView] frame].size,
NSSize viewSize=[[self contentView] frame].size,
sliderSize=[slider frame].size;
sliderSize=[slider frame].size;
viewSize.height += sliderSize.height;
viewSize.height += sliderSize.height;
...
@@ -845,7 +833,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -845,7 +833,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
[[self contentView] setFrameSize:viewSize];
[[self contentView] setFrameSize:viewSize];
[[self contentView] setNeedsDisplay:YES];
[[self contentView] setNeedsDisplay:YES];
//update window size to contain
_
sliders
//update window size to contain sliders
NSRect rect = [self frame];
NSRect rect = [self frame];
rect.size.height += [slider frame].size.height;
rect.size.height += [slider frame].size.height;
rect.size.width = std::max<int>(rect.size.width, MIN_SLIDER_WIDTH);
rect.size.width = std::max<int>(rect.size.width, MIN_SLIDER_WIDTH);
...
@@ -862,16 +850,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -862,16 +850,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
@end
@end
@implementation CVView
@implementation CVView
#if defined(__LP64__)
@synthesize image;
@synthesize image;
#else // 32-bit Obj-C does not have automatic synthesize
@synthesize image = _image;
#endif
- (id)init {
- (id)init {
//cout << "CVView init" << endl;
//cout << "CVView init" << endl;
[super init];
[super init];
_
image = [[NSImage alloc] init];
image = [[NSImage alloc] init];
return self;
return self;
}
}
...
@@ -926,11 +911,11 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -926,11 +911,11 @@ void cv::setWindowTitle(const String& winname, const String& title)
dst[i * 4 + 2] = src[i * 3 + 2];
dst[i * 4 + 2] = src[i * 3 + 2];
}
}
if(
_
image )
if( image )
[
_
image release];
[image release];
_
image = [[NSImage alloc] init];
image = [[NSImage alloc] init];
[
_
image addRepresentation:bitmap];
[image addRepresentation:bitmap];
[bitmap release];
[bitmap release];
/*CGColorSpaceRelease(colorspace);
/*CGColorSpaceRelease(colorspace);
...
@@ -951,7 +936,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -951,7 +936,7 @@ void cv::setWindowTitle(const String& winname, const String& title)
int height = size.height;
int height = size.height;
CVWindow *cvwindow = (CVWindow *)[self window];
CVWindow *cvwindow = (CVWindow *)[self window];
if ([cvwindow respondsToSelector:@selector(
_
sliders)]) {
if ([cvwindow respondsToSelector:@selector(sliders)]) {
for(NSString *key in [cvwindow sliders]) {
for(NSString *key in [cvwindow sliders]) {
NSSlider *slider = [[cvwindow sliders] valueForKey:key];
NSSlider *slider = [[cvwindow sliders] valueForKey:key];
NSRect r = [slider frame];
NSRect r = [slider frame];
...
@@ -971,17 +956,17 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -971,17 +956,17 @@ void cv::setWindowTitle(const String& winname, const String& title)
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;
if ([cvwindow respondsToSelector:@selector(
_
sliders)]) {
if ([cvwindow respondsToSelector:@selector(sliders)]) {
for(NSString *key in [cvwindow sliders]) {
for(NSString *key in [cvwindow sliders]) {
height += [[[cvwindow sliders] valueForKey:key] frame].size.height;
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}};
if(
_
image != nil) {
if(image != nil) {
[
_
image drawInRect: imageRect
[image drawInRect: imageRect
fromRect: NSZeroRect
fromRect: NSZeroRect
operation: NSCompositeSourceOver
operation: NSCompositeSourceOver
fraction: 1.0];
fraction: 1.0];
...
@@ -993,47 +978,40 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -993,47 +978,40 @@ void cv::setWindowTitle(const String& winname, const String& title)
@end
@end
@implementation CVSlider
@implementation CVSlider
#if defined(__LP64__)
@synthesize slider;
@synthesize slider;
@synthesize name;
@synthesize name;
@synthesize value;
@synthesize value;
@synthesize userData;
@synthesize userData;
@synthesize callback;
@synthesize callback;
@synthesize callback2;
@synthesize callback2;
#else // 32-bit Obj-C does not have automatic synthesize
@synthesize slider = _slider;
@synthesize name = _name;
@synthesize value = _value;
@synthesize userData = _userData;
@synthesize callback = _callback;
@synthesize callback2 = _callback2;
#endif
- (id)init {
- (id)init {
[super init];
[super init];
_
callback = NULL;
callback = NULL;
_
value = NULL;
value = NULL;
_
userData = NULL;
userData = NULL;
[self setFrame:NSMakeRect(0,0,200,30)];
[self setFrame:NSMakeRect(0,0,200,30)];
_
name = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 0,110, 25)];
name = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 0,110, 25)];
[
_
name setEditable:NO];
[name setEditable:NO];
[
_
name setSelectable:NO];
[name setSelectable:NO];
[
_
name setBezeled:NO];
[name setBezeled:NO];
[
_
name setBordered:NO];
[name setBordered:NO];
[
_
name setDrawsBackground:NO];
[name setDrawsBackground:NO];
[[
_
name cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[[name cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[self addSubview:
_
name];
[self addSubview:name];
_
slider = [[NSSlider alloc] initWithFrame:NSMakeRect(120, 0, 70, 25)];
slider = [[NSSlider alloc] initWithFrame:NSMakeRect(120, 0, 70, 25)];
[
_
slider setAutoresizingMask:NSViewWidthSizable];
[slider setAutoresizingMask:NSViewWidthSizable];
[
_
slider setMinValue:0];
[slider setMinValue:0];
[
_
slider setMaxValue:100];
[slider setMaxValue:100];
[
_
slider setContinuous:YES];
[slider setContinuous:YES];
[
_
slider setTarget:self];
[slider setTarget:self];
[
_
slider setAction:@selector(sliderChanged:)];
[slider setAction:@selector(sliderChanged:)];
[self addSubview:
_
slider];
[self addSubview:slider];
[self setAutoresizingMask:NSViewWidthSizable];
[self setAutoresizingMask:NSViewWidthSizable];
...
@@ -1044,13 +1022,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
...
@@ -1044,13 +1022,13 @@ void cv::setWindowTitle(const String& winname, const String& title)
- (void)sliderChanged:(NSNotification *)notification {
- (void)sliderChanged:(NSNotification *)notification {
(void)notification;
(void)notification;
int pos = [
_
slider intValue];
int pos = [slider intValue];
if(
_
value)
if(value)
*
_
value = pos;
*value = pos;
if(
_
callback)
if(callback)
_
callback(pos);
callback(pos);
if(
_
callback2)
if(callback2)
_callback2(pos, _
userData);
callback2(pos,
userData);
}
}
@end
@end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment