mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 14:13:15 +08:00
Merge pull request #16588 from vpisarev:fix_macos_move_window
fixed cv::moveWindow() on mac * fixed cv::moveWindow() on mac (issue #16343). Thanks to cwreynolds and saskatchewancatch for the help! * fixed warnings about _x0 and _y0 * fixed warnings about _x0 and _y0
This commit is contained in:
parent
d84360e7f3
commit
d67a6c1be4
@ -111,11 +111,14 @@ static bool wasInitialized = false;
|
||||
BOOL autosize;
|
||||
BOOL firstContent;
|
||||
int status;
|
||||
int x0, y0;
|
||||
}
|
||||
@property(assign) CvMouseCallback mouseCallback;
|
||||
@property(assign) void *mouseParam;
|
||||
@property(assign) BOOL autosize;
|
||||
@property(assign) BOOL firstContent;
|
||||
@property(assign) int x0;
|
||||
@property(assign) int y0;
|
||||
@property(retain) NSMutableDictionary *sliders;
|
||||
@property(readwrite) int status;
|
||||
- (CVView *)contentView;
|
||||
@ -251,6 +254,16 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
|
||||
contentSize.height = scaledImageSize.height + [window contentView].sliderHeight;
|
||||
contentSize.width = std::max<int>(scaledImageSize.width, MIN_SLIDER_WIDTH);
|
||||
[window setContentSize:contentSize]; //adjust sliders to fit new window size
|
||||
if([window firstContent])
|
||||
{
|
||||
int x = [window x0];
|
||||
int y = [window y0];
|
||||
if(x >= 0 && y >= 0)
|
||||
{
|
||||
y = [[window screen] visibleFrame].size.height - y;
|
||||
[window setFrameTopLeftPoint:NSMakePoint(x, y)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[window setFirstContent:NO];
|
||||
@ -274,7 +287,6 @@ CV_IMPL void cvResizeWindow( const char* name, int width, int height)
|
||||
|
||||
CV_IMPL void cvMoveWindow( const char* name, int x, int y)
|
||||
{
|
||||
|
||||
CV_FUNCNAME("cvMoveWindow");
|
||||
__BEGIN__;
|
||||
|
||||
@ -286,8 +298,14 @@ CV_IMPL void cvMoveWindow( const char* name, int x, int y)
|
||||
//cout << "cvMoveWindow"<< endl;
|
||||
window = cvGetWindow(name);
|
||||
if(window) {
|
||||
y = [[window screen] frame].size.height - y;
|
||||
[window setFrameTopLeftPoint:NSMakePoint(x, y)];
|
||||
if([window firstContent]) {
|
||||
[window setX0:x];
|
||||
[window setY0:y];
|
||||
}
|
||||
else {
|
||||
y = [[window screen] visibleFrame].size.height - y;
|
||||
[window setFrameTopLeftPoint:NSMakePoint(x, y)];
|
||||
}
|
||||
}
|
||||
[localpool1 drain];
|
||||
|
||||
@ -556,6 +574,8 @@ CV_IMPL int cvNamedWindow( const char* name, int flags )
|
||||
[window setFrameTopLeftPoint:initContentRect.origin];
|
||||
|
||||
[window setFirstContent:YES];
|
||||
[window setX0:-1];
|
||||
[window setY0:-1];
|
||||
|
||||
[window setContentView:[[CVView alloc] init]];
|
||||
|
||||
@ -818,6 +838,8 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
|
||||
@synthesize mouseParam;
|
||||
@synthesize autosize;
|
||||
@synthesize firstContent;
|
||||
@synthesize x0;
|
||||
@synthesize y0;
|
||||
@synthesize sliders;
|
||||
@synthesize status;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user