Changeset 9852
- Timestamp:
- 03/04/09 11:25:40 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/GraphicsWindowCocoa.mm
r9845 r9852 141 141 142 142 143 std::ostream& operator<<(std::ostream& os, const NSRect& rect) 144 { 145 os << rect.origin.x << "/" << rect.origin.y << " " << rect.size.width << "x" << rect.size.height; 146 return os; 147 } 148 143 149 // ---------------------------------------------------------------------------------------------------------- 144 150 // Cocoa uses a coordinate system where its origin is in the bottom left corner, … … 148 154 // ---------------------------------------------------------------------------------------------------------- 149 155 150 static NSRect convertFromQuartzCoordinates(osgViewer::GraphicsWindowCocoa* win,const NSRect& rect) 151 { 152 NSRect frame = [[win->getWindow() screen] frame]; 153 156 static NSRect convertFromQuartzCoordinates(const NSRect& rect) 157 { 158 NSRect frame = [[[NSScreen screens] objectAtIndex: 0] frame]; 154 159 float y = frame.size.height - rect.origin.y - rect.size.height; 155 return NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 156 } 157 158 static NSRect convertToQuartzCoordinates(osgViewer::GraphicsWindowCocoa* win,const NSRect& rect) 159 { 160 NSRect frame = [[win->getWindow() screen] frame]; 160 NSRect converted = NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 161 162 // std::cout << "converting from Quartz " << rect << " to " << converted << " using screen rect " << frame << std::endl; 163 164 return converted; 165 } 166 167 static NSRect convertToQuartzCoordinates(const NSRect& rect) 168 { 169 NSRect frame = [[[NSScreen screens] objectAtIndex: 0] frame]; 161 170 162 171 float y = frame.size.height - (rect.origin.y + rect.size.height); 163 return NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 172 NSRect converted = NSMakeRect(rect.origin.x, y, rect.size.width, rect.size.height); 173 174 // std::cout << "converting To Quartz " << rect << " to " << converted << " using screen rect " << frame << std::endl; 175 176 return converted; 164 177 } 165 178 … … 714 727 715 728 // convert to quartz-coordinate-system 716 bounds = convertToQuartzCoordinates( _win,bounds);729 bounds = convertToQuartzCoordinates(bounds); 717 730 718 731 // std::cout << "windowdidmove: " << bounds.origin.x << " " << bounds.origin.y << " " << bounds.size.width << " " << bounds.size.height << std::endl; … … 753 766 { 754 767 NSRect nsrect = [_win->getWindow() frame]; 755 nsrect = convertToQuartzCoordinates( _win.get(),nsrect);768 nsrect = convertToQuartzCoordinates(nsrect); 756 769 757 770 rect.origin.x = nsrect.origin.x; … … 823 836 style |= NSResizableWindowMask; 824 837 } 825 838 826 839 DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 827 840 int screenLeft(0), screenTop(0); … … 842 855 } 843 856 844 rect = convertFromQuartzCoordinates( this,rect);857 rect = convertFromQuartzCoordinates(rect); 845 858 [_window setFrameOrigin: rect.origin]; 846 859 … … 1094 1107 1095 1108 NSRect rect = NSMakeRect(x,y,width, height); 1096 rect = convertFromQuartzCoordinates( this,rect);1109 rect = convertFromQuartzCoordinates(rect); 1097 1110 1098 1111 [_window setFrame: [NSWindow frameRectForContentRect: rect styleMask: [_window styleMask]] display: YES];
