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
8c2246bd
Commit
8c2246bd
authored
Jun 20, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed slider rendering in highgui windows on MacOSX (ticket #608; thanks to tingfan for the patch)
parent
f6bc96c4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
cap_qtkit.mm
modules/highgui/src/cap_qtkit.mm
+4
-0
window_cocoa.mm
modules/highgui/src/window_cocoa.mm
+31
-12
No files found.
modules/highgui/src/cap_qtkit.mm
View file @
8c2246bd
...
@@ -795,6 +795,7 @@ double CvCaptureFile::getProperty(int property_id){
...
@@ -795,6 +795,7 @@ double CvCaptureFile::getProperty(int property_id){
double retval;
double retval;
QTTime t;
QTTime t;
//cerr << "get_prop"<<endl;
switch (property_id) {
switch (property_id) {
case CV_CAP_PROP_POS_MSEC:
case CV_CAP_PROP_POS_MSEC:
[[mCaptureSession attributeForKey:QTMovieCurrentTimeAttribute] getValue:&t];
[[mCaptureSession attributeForKey:QTMovieCurrentTimeAttribute] getValue:&t];
...
@@ -815,6 +816,9 @@ double CvCaptureFile::getProperty(int property_id){
...
@@ -815,6 +816,9 @@ double CvCaptureFile::getProperty(int property_id){
case CV_CAP_PROP_FPS:
case CV_CAP_PROP_FPS:
retval = currentFPS;
retval = currentFPS;
break;
break;
case CV_CAP_PROP_FRAME_COUNT:
retval = movieDuration*movieFPS/1000;
break;
case CV_CAP_PROP_FOURCC:
case CV_CAP_PROP_FOURCC:
default:
default:
retval = 0;
retval = 0;
...
...
modules/highgui/src/window_cocoa.mm
View file @
8c2246bd
...
@@ -74,6 +74,7 @@ CV_IMPL int cvWaitKey (int maxWait) {return 0;}
...
@@ -74,6 +74,7 @@ CV_IMPL int cvWaitKey (int maxWait) {return 0;}
using namespace std;
using namespace std;
const int TOP_BORDER = 7;
const int TOP_BORDER = 7;
const int MIN_SLIDER_WIDTH=200;
static NSApplication *application = nil;
static NSApplication *application = nil;
static NSAutoreleasePool *pool = nil;
static NSAutoreleasePool *pool = nil;
...
@@ -221,8 +222,16 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
...
@@ -221,8 +222,16 @@ CV_IMPL void cvShowImage( const char* name, const CvArr* arr)
[[window contentView] setImageData:(CvArr *)arr];
[[window contentView] setImageData:(CvArr *)arr];
if([window autosize] || [window firstContent] || empty)
if([window autosize] || [window firstContent] || empty)
{
{
//Set new view size considering sliders (reserve height and min width)
NSRect vrectNew = vrectOld;
NSRect vrectNew = vrectOld;
vrectNew.size = [[[window contentView] image] size];
int slider_height = 0;
for(NSString *key in [window sliders]) {
slider_height += [[[window sliders] valueForKey:key] frame].size.height;
}
vrectNew.size.height = [[[window contentView] image] size].height + slider_height;
vrectNew.size.width = std::max<int>([[[window contentView] image] size].width, MIN_SLIDER_WIDTH);
[[window contentView] setFrameSize:vrectNew.size]; //adjust sliders to fit new window size
rect.size.width += vrectNew.size.width - vrectOld.size.width;
rect.size.width += vrectNew.size.width - vrectOld.size.width;
rect.size.height += vrectNew.size.height - vrectOld.size.height;
rect.size.height += vrectNew.size.height - vrectOld.size.height;
rect.origin.y -= vrectNew.size.height - vrectOld.size.height;
rect.origin.y -= vrectNew.size.height - vrectOld.size.height;
...
@@ -646,16 +655,25 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -646,16 +655,25 @@ CV_IMPL int cvWaitKey (int maxWait)
[sliders setValue:slider forKey:cvname];
[sliders setValue:slider forKey:cvname];
[[self contentView] addSubview:slider];
[[self contentView] addSubview:slider];
//update contentView size to contain sliders
NSSize viewSize=[[self contentView] frame].size,
sliderSize=[slider frame].size;
viewSize.height += sliderSize.height;
viewSize.width = std::max<int>(viewSize.width, MIN_SLIDER_WIDTH);
// Update slider sizes
// Update slider sizes
[[self contentView] setFrameSize:
[[self contentView] frame].s
ize];
[[self contentView] setFrameSize:
viewS
ize];
[[self contentView] setNeedsDisplay:YES];
[[self contentView] setNeedsDisplay:YES];
//update window size to contain sliders
NSRect rect = [self frame];
rect.size.height += [slider frame].size.height;
rect.size.width = std::max<int>(rect.size.width, MIN_SLIDER_WIDTH);
[self setFrame:rect display:YES];
int height = 0;
for(NSString *key in sliders) {
height += [[sliders valueForKey:key] frame].size.height;
}
[self setContentMinSize:NSMakeSize(0, height)];
}
}
- (CVView *)contentView {
- (CVView *)contentView {
...
@@ -755,6 +773,7 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -755,6 +773,7 @@ CV_IMPL int cvWaitKey (int maxWait)
NSSlider *slider = [[cvwindow sliders] valueForKey:key];
NSSlider *slider = [[cvwindow sliders] valueForKey:key];
NSRect r = [slider frame];
NSRect r = [slider frame];
r.origin.y = height - r.size.height;
r.origin.y = height - r.size.height;
r.size.width = [[cvwindow contentView] frame].size.width;
[slider setFrame:r];
[slider setFrame:r];
height -= r.size.height;
height -= r.size.height;
}
}
...
@@ -773,7 +792,7 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -773,7 +792,7 @@ CV_IMPL int cvWaitKey (int maxWait)
}
}
NSRect imageRect = {{0,0}, {
self.frame.size.width, self.frame.size.height-height-6
}};
NSRect imageRect = {{0,0}, {
[image size].width, [image size].height
}};
if(image != nil) {
if(image != nil) {
[image drawInRect: imageRect
[image drawInRect: imageRect
...
@@ -803,9 +822,9 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -803,9 +822,9 @@ CV_IMPL int cvWaitKey (int maxWait)
value = NULL;
value = NULL;
userData = NULL;
userData = NULL;
[self setFrame:NSMakeRect(0,0,200,
25
)];
[self setFrame:NSMakeRect(0,0,200,
30
)];
name = [[NSTextField alloc] initWithFrame:NSMakeRect(
0, 0,120, 20
)];
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];
...
@@ -814,7 +833,7 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -814,7 +833,7 @@ CV_IMPL int cvWaitKey (int maxWait)
[[name cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[[name cell] setLineBreakMode:NSLineBreakByTruncatingTail];
[self addSubview:name];
[self addSubview:name];
slider = [[NSSlider alloc] initWithFrame:NSMakeRect(120, 0, 7
6, 20
)];
slider = [[NSSlider alloc] initWithFrame:NSMakeRect(120, 0, 7
0, 25
)];
[slider setAutoresizingMask:NSViewWidthSizable];
[slider setAutoresizingMask:NSViewWidthSizable];
[slider setMinValue:0];
[slider setMinValue:0];
[slider setMaxValue:100];
[slider setMaxValue:100];
...
@@ -825,7 +844,7 @@ CV_IMPL int cvWaitKey (int maxWait)
...
@@ -825,7 +844,7 @@ CV_IMPL int cvWaitKey (int maxWait)
[self setAutoresizingMask:NSViewWidthSizable];
[self setAutoresizingMask:NSViewWidthSizable];
[self setFrame:NSMakeRect(12, 0, 182
, 30)];
//[self setFrame:NSMakeRect(12, 0, 100
, 30)];
return self;
return self;
}
}
...
...
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