Blender  V2.93
GHOST_WindowCocoa.mm
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #include "GHOST_WindowCocoa.h"
21 #include "GHOST_ContextNone.h"
22 #include "GHOST_Debug.h"
23 #include "GHOST_SystemCocoa.h"
24 
25 #if defined(WITH_GL_EGL)
26 # include "GHOST_ContextEGL.h"
27 #else
28 # include "GHOST_ContextCGL.h"
29 #endif
30 
31 #include <Cocoa/Cocoa.h>
32 #include <Metal/Metal.h>
33 #include <QuartzCore/QuartzCore.h>
34 
35 #include <sys/sysctl.h>
36 
37 #pragma mark Cocoa window delegate object
38 
39 @interface CocoaWindowDelegate : NSObject <NSWindowDelegate>
40 {
43 }
44 
45 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
46  windowCocoa:(GHOST_WindowCocoa *)winCocoa;
47 - (void)windowDidBecomeKey:(NSNotification *)notification;
48 - (void)windowDidResignKey:(NSNotification *)notification;
49 - (void)windowDidExpose:(NSNotification *)notification;
50 - (void)windowDidResize:(NSNotification *)notification;
51 - (void)windowDidMove:(NSNotification *)notification;
52 - (void)windowWillMove:(NSNotification *)notification;
53 - (BOOL)windowShouldClose:(id)sender;
54 - (void)windowDidChangeBackingProperties:(NSNotification *)notification;
55 @end
56 
57 @implementation CocoaWindowDelegate : NSObject
58 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
59  windowCocoa:(GHOST_WindowCocoa *)winCocoa
60 {
61  systemCocoa = sysCocoa;
62  associatedWindow = winCocoa;
63 }
64 
65 - (void)windowDidBecomeKey:(NSNotification *)notification
66 {
68  // work around for broken appswitching when combining cmd-tab and missioncontrol
69  [(NSWindow *)associatedWindow->getOSWindow() orderFrontRegardless];
70 }
71 
72 - (void)windowDidResignKey:(NSNotification *)notification
73 {
75 }
76 
77 - (void)windowDidExpose:(NSNotification *)notification
78 {
80 }
81 
82 - (void)windowDidMove:(NSNotification *)notification
83 {
85 }
86 
87 - (void)windowWillMove:(NSNotification *)notification
88 {
90 }
91 
92 - (void)windowWillEnterFullScreen:(NSNotification *)notification
93 {
95 }
96 
97 - (void)windowDidEnterFullScreen:(NSNotification *)notification
98 {
99  /* macOS does not send a window resize event when switching between zoomed
100  * and fullscreen, when automatic show/hide of dock and menu bar are enabled.
101  * Send our own to prevent artifacts. */
103 
105 }
106 
107 - (void)windowWillExitFullScreen:(NSNotification *)notification
108 {
110 }
111 
112 - (void)windowDidExitFullScreen:(NSNotification *)notification
113 {
114  /* See comment for windowWillEnterFullScreen. */
117 }
118 
119 - (void)windowDidResize:(NSNotification *)notification
120 {
121  // if (![[notification object] inLiveResize]) {
122  // Send event only once, at end of resize operation (when user has released mouse button)
124  //}
125  /* Live resize, send event, gets handled in wm_window.c.
126  * Needed because live resize runs in a modal loop, not letting main loop run */
127  if ([[notification object] inLiveResize]) {
129  }
130 }
131 
132 - (void)windowDidChangeBackingProperties:(NSNotification *)notification
133 {
136 }
137 
138 - (BOOL)windowShouldClose:(id)sender;
139 {
140  // Let Blender close the window rather than closing immediately
142  return false;
143 }
144 
145 @end
146 
147 #pragma mark NSWindow subclass
148 // We need to subclass it to tell that even borderless (fullscreen),
149 // it can become key (receive user events)
150 @interface CocoaWindow : NSWindow
151 {
155 }
156 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
157  windowCocoa:(GHOST_WindowCocoa *)winCocoa;
158 - (GHOST_SystemCocoa *)systemCocoa;
159 @end
160 
161 @implementation CocoaWindow
162 - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa
163  windowCocoa:(GHOST_WindowCocoa *)winCocoa
164 {
165  systemCocoa = sysCocoa;
166  associatedWindow = winCocoa;
167 }
169 {
170  return systemCocoa;
171 }
172 
173 - (BOOL)canBecomeKeyWindow
174 {
175  /* Don't make other windows active when a dialog window is open. */
177 }
178 
179 // The drag'n'drop dragging destination methods
180 - (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
181 {
182  NSPoint mouseLocation = [sender draggingLocation];
183  NSPasteboard *draggingPBoard = [sender draggingPasteboard];
184 
185  if ([[draggingPBoard types] containsObject:NSTIFFPboardType])
187  else if ([[draggingPBoard types] containsObject:NSFilenamesPboardType])
189  else if ([[draggingPBoard types] containsObject:NSStringPboardType])
191  else
192  return NSDragOperationNone;
193 
194  associatedWindow->setAcceptDragOperation(TRUE); // Drag operation is accepted by default
198  mouseLocation.x,
199  mouseLocation.y,
200  nil);
201  return NSDragOperationCopy;
202 }
203 
204 - (BOOL)wantsPeriodicDraggingUpdates
205 {
206  return NO; // No need to overflow blender event queue. Events shall be sent only on changes
207 }
208 
209 - (NSDragOperation)draggingUpdated:(id<NSDraggingInfo>)sender
210 {
211  NSPoint mouseLocation = [sender draggingLocation];
212 
216  mouseLocation.x,
217  mouseLocation.y,
218  nil);
219  return associatedWindow->canAcceptDragOperation() ? NSDragOperationCopy : NSDragOperationNone;
220 }
221 
222 - (void)draggingExited:(id<NSDraggingInfo>)sender
223 {
227 }
228 
229 - (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
230 {
232  return YES;
233  else
234  return NO;
235 }
236 
237 - (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
238 {
239  NSPoint mouseLocation = [sender draggingLocation];
240  NSPasteboard *draggingPBoard = [sender draggingPasteboard];
241  NSImage *droppedImg;
242  id data;
243 
244  switch (m_draggedObjectType) {
246  if ([NSImage canInitWithPasteboard:draggingPBoard]) {
247  droppedImg = [[NSImage alloc] initWithPasteboard:draggingPBoard];
248  data = droppedImg; //[draggingPBoard dataForType:NSTIFFPboardType];
249  }
250  else
251  return NO;
252  break;
254  data = [draggingPBoard propertyListForType:NSFilenamesPboardType];
255  break;
257  data = [draggingPBoard stringForType:NSStringPboardType];
258  break;
259  default:
260  return NO;
261  break;
262  }
266  mouseLocation.x,
267  mouseLocation.y,
268  (void *)data);
269  return YES;
270 }
271 
272 @end
273 
274 /* NSView for handling input and drawing. */
275 #define COCOA_VIEW_CLASS CocoaOpenGLView
276 #define COCOA_VIEW_BASE_CLASS NSOpenGLView
277 #include "GHOST_WindowViewCocoa.h"
278 #undef COCOA_VIEW_CLASS
279 #undef COCOA_VIEW_BASE_CLASS
280 
281 #define COCOA_VIEW_CLASS CocoaMetalView
282 #define COCOA_VIEW_BASE_CLASS NSView
284 #undef COCOA_VIEW_CLASS
285 #undef COCOA_VIEW_BASE_CLASS
286 
287 #pragma mark initialization / finalization
288 
290  const char *title,
297  const bool stereoVisual,
298  bool is_debug,
299  bool is_dialog,
300  GHOST_WindowCocoa *parentWindow)
301  : GHOST_Window(width, height, state, stereoVisual, false),
302  m_openGLView(nil),
303  m_metalView(nil),
304  m_metalLayer(nil),
305  m_systemCocoa(systemCocoa),
306  m_customCursor(0),
307  m_immediateDraw(false),
308  m_debug_context(is_debug),
309  m_is_dialog(is_dialog)
310 {
311  m_fullScreen = false;
312 
313  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
314 
315  // Creates the window
316  NSRect rect;
317  NSSize minSize;
318 
319  rect.origin.x = left;
320  rect.origin.y = bottom;
321  rect.size.width = width;
322  rect.size.height = height;
323 
324  NSWindowStyleMask styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
325  NSWindowStyleMaskResizable;
326  if (!is_dialog) {
327  styleMask |= NSWindowStyleMaskMiniaturizable;
328  }
329 
330  m_window = [[CocoaWindow alloc] initWithContentRect:rect
331  styleMask:styleMask
332  backing:NSBackingStoreBuffered
333  defer:NO];
334 
335  [m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
336 
337  // Forbid to resize the window below the blender defined minimum one
338  minSize.width = 320;
339  minSize.height = 240;
340  [m_window setContentMinSize:minSize];
341 
342  // Create NSView inside the window
343  id<MTLDevice> metalDevice = MTLCreateSystemDefaultDevice();
344  NSView *view;
345 
346  if (metalDevice) {
347  // Create metal layer and view if supported
348  m_metalLayer = [[CAMetalLayer alloc] init];
349  [m_metalLayer setEdgeAntialiasingMask:0];
350  [m_metalLayer setMasksToBounds:NO];
351  [m_metalLayer setOpaque:YES];
352  [m_metalLayer setFramebufferOnly:YES];
353  [m_metalLayer setPresentsWithTransaction:NO];
354  [m_metalLayer removeAllAnimations];
355  [m_metalLayer setDevice:metalDevice];
356 
357  m_metalView = [[CocoaMetalView alloc] initWithFrame:rect];
358  [m_metalView setWantsLayer:YES];
359  [m_metalView setLayer:m_metalLayer];
360  [m_metalView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
361  view = m_metalView;
362  }
363  else {
364  // Fallback to OpenGL view if there is no Metal support
365  m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect];
366  [m_openGLView setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
367  view = m_openGLView;
368  }
369 
371  // Needs to happen early when building with the 10.14 SDK, otherwise
372  // has no effect until resizeing the window.
373  if ([view respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)]) {
374  [view setWantsBestResolutionOpenGLSurface:YES];
375  }
376  }
377 
378  [m_window setContentView:view];
379  [m_window setInitialFirstResponder:view];
380 
381  [m_window makeKeyAndOrderFront:nil];
382 
386 
387  setTitle(title);
388 
390 
391  CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
392  [windowDelegate setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
393  [m_window setDelegate:windowDelegate];
394 
395  [m_window setAcceptsMouseMovedEvents:YES];
396 
397  NSView *contentview = [m_window contentView];
398  [contentview setAllowedTouchTypes:(NSTouchTypeMaskDirect | NSTouchTypeMaskIndirect)];
399 
400  [m_window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
401  NSStringPboardType,
402  NSTIFFPboardType,
403  nil]];
404 
405  if (is_dialog && parentWindow) {
406  [parentWindow->getCocoaWindow() addChildWindow:m_window ordered:NSWindowAbove];
407  [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
408  }
409  else {
410  [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
411  }
412 
415 
417 
418  [pool drain];
419 }
420 
422 {
423  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
424 
425  if (m_customCursor) {
426  [m_customCursor release];
427  m_customCursor = nil;
428  }
429 
431 
432  if (m_openGLView) {
433  [m_openGLView release];
434  m_openGLView = nil;
435  }
436  if (m_metalView) {
437  [m_metalView release];
438  m_metalView = nil;
439  }
440  if (m_metalLayer) {
441  [m_metalLayer release];
442  m_metalLayer = nil;
443  }
444 
445  if (m_window) {
446  [m_window close];
447  }
448 
449  // Check for other blender opened windows and make the frontmost key
450  // Note: for some reason the closed window is still in the list
451  NSArray *windowsList = [NSApp orderedWindows];
452  for (int a = 0; a < [windowsList count]; a++) {
453  if (m_window != (CocoaWindow *)[windowsList objectAtIndex:a]) {
454  [[windowsList objectAtIndex:a] makeKeyWindow];
455  break;
456  }
457  }
458  m_window = nil;
459 
460  [pool drain];
461 }
462 
463 #pragma mark accessors
464 
465 bool GHOST_WindowCocoa::getValid() const
466 {
467  NSView *view = (m_openGLView) ? m_openGLView : m_metalView;
468  return GHOST_Window::getValid() && m_window != NULL && view != NULL;
469 }
470 
471 void *GHOST_WindowCocoa::getOSWindow() const
472 {
473  return (void *)m_window;
474 }
475 
476 void GHOST_WindowCocoa::setTitle(const char *title)
477 {
478  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setTitle(): window invalid");
479  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
480 
481  NSString *windowTitle = [[NSString alloc] initWithCString:title encoding:NSUTF8StringEncoding];
482 
483  // Set associated file if applicable
484  if (windowTitle && [windowTitle hasPrefix:@"Blender"]) {
485  NSRange fileStrRange;
486  NSString *associatedFileName;
487  int len;
488 
489  fileStrRange.location = [windowTitle rangeOfString:@"["].location + 1;
490  len = [windowTitle rangeOfString:@"]"].location - fileStrRange.location;
491 
492  if (len > 0) {
493  fileStrRange.length = len;
494  associatedFileName = [windowTitle substringWithRange:fileStrRange];
495  [m_window setTitle:[associatedFileName lastPathComponent]];
496 
497  @try {
498  [m_window setRepresentedFilename:associatedFileName];
499  }
500  @catch (NSException *e) {
501  printf("\nInvalid file path given in window title");
502  }
503  }
504  else {
505  [m_window setTitle:windowTitle];
506  [m_window setRepresentedFilename:@""];
507  }
508  }
509  else {
510  [m_window setTitle:windowTitle];
511  [m_window setRepresentedFilename:@""];
512  }
513 
514  [windowTitle release];
515  [pool drain];
516 }
517 
518 std::string GHOST_WindowCocoa::getTitle() const
519 {
520  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getTitle(): window invalid");
521 
522  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
523 
524  NSString *windowTitle = [m_window title];
525 
526  std::string title;
527  if (windowTitle != nil) {
528  title = [windowTitle UTF8String];
529  }
530 
531  [pool drain];
532 
533  return title;
534 }
535 
537 {
538  NSRect rect;
539  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getWindowBounds(): window invalid");
540 
541  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
542 
543  NSRect screenSize = [[m_window screen] visibleFrame];
544 
545  rect = [m_window frame];
546 
547  bounds.m_b = screenSize.size.height - (rect.origin.y - screenSize.origin.y);
548  bounds.m_l = rect.origin.x - screenSize.origin.x;
549  bounds.m_r = rect.origin.x - screenSize.origin.x + rect.size.width;
550  bounds.m_t = screenSize.size.height - (rect.origin.y + rect.size.height - screenSize.origin.y);
551 
552  [pool drain];
553 }
554 
556 {
557  NSRect rect;
558  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getClientBounds(): window invalid");
559 
560  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
561 
562  NSRect screenSize = [[m_window screen] visibleFrame];
563 
564  // Max window contents as screen size (excluding title bar...)
565  NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
566  styleMask:[m_window styleMask]];
567 
568  rect = [m_window contentRectForFrameRect:[m_window frame]];
569 
570  bounds.m_b = contentRect.size.height - (rect.origin.y - contentRect.origin.y);
571  bounds.m_l = rect.origin.x - contentRect.origin.x;
572  bounds.m_r = rect.origin.x - contentRect.origin.x + rect.size.width;
573  bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height - contentRect.origin.y);
574  [pool drain];
575 }
576 
578 {
579  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientWidth(): window invalid");
580  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
581  GHOST_Rect cBnds, wBnds;
582  getClientBounds(cBnds);
583  if (((GHOST_TUns32)cBnds.getWidth()) != width) {
584  NSSize size;
585  size.width = width;
586  size.height = cBnds.getHeight();
587  [m_window setContentSize:size];
588  }
589  [pool drain];
590  return GHOST_kSuccess;
591 }
592 
594 {
595  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientHeight(): window invalid");
596  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
597  GHOST_Rect cBnds, wBnds;
598  getClientBounds(cBnds);
599  if (((GHOST_TUns32)cBnds.getHeight()) != height) {
600  NSSize size;
601  size.width = cBnds.getWidth();
602  size.height = height;
603  [m_window setContentSize:size];
604  }
605  [pool drain];
606  return GHOST_kSuccess;
607 }
608 
610 {
611  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientSize(): window invalid");
612  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
613  GHOST_Rect cBnds, wBnds;
614  getClientBounds(cBnds);
615  if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
616  (((GHOST_TUns32)cBnds.getHeight()) != height)) {
617  NSSize size;
618  size.width = width;
619  size.height = height;
620  [m_window setContentSize:size];
621  }
622  [pool drain];
623  return GHOST_kSuccess;
624 }
625 
627 {
628  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getState(): window invalid");
629  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
631 
632  NSUInteger masks = [m_window styleMask];
633 
634  if (masks & NSWindowStyleMaskFullScreen) {
635  // Lion style fullscreen
636  if (!m_immediateDraw) {
638  }
639  else {
641  }
642  }
643  else if ([m_window isMiniaturized]) {
645  }
646  else if ([m_window isZoomed]) {
648  }
649  else {
650  if (m_immediateDraw) {
652  }
653  else {
655  }
656  }
657  [pool drain];
658  return state;
659 }
660 
663  GHOST_TInt32 &outX,
664  GHOST_TInt32 &outY) const
665 {
666  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::screenToClient(): window invalid");
667 
668  screenToClientIntern(inX, inY, outX, outY);
669 
670  /* switch y to match ghost convention */
671  GHOST_Rect cBnds;
672  getClientBounds(cBnds);
673  outY = (cBnds.getHeight() - 1) - outY;
674 }
675 
678  GHOST_TInt32 &outX,
679  GHOST_TInt32 &outY) const
680 {
681  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::clientToScreen(): window invalid");
682 
683  /* switch y to match ghost convention */
684  GHOST_Rect cBnds;
685  getClientBounds(cBnds);
686  inY = (cBnds.getHeight() - 1) - inY;
687 
688  clientToScreenIntern(inX, inY, outX, outY);
689 }
690 
693  GHOST_TInt32 &outX,
694  GHOST_TInt32 &outY) const
695 {
696  NSRect screenCoord;
697  NSRect baseCoord;
698 
699  screenCoord.origin.x = inX;
700  screenCoord.origin.y = inY;
701 
702  baseCoord = [m_window convertRectFromScreen:screenCoord];
703 
704  outX = baseCoord.origin.x;
705  outY = baseCoord.origin.y;
706 }
707 
710  GHOST_TInt32 &outX,
711  GHOST_TInt32 &outY) const
712 {
713  NSRect screenCoord;
714  NSRect baseCoord;
715 
716  baseCoord.origin.x = inX;
717  baseCoord.origin.y = inY;
718 
719  screenCoord = [m_window convertRectToScreen:baseCoord];
720 
721  outX = screenCoord.origin.x;
722  outY = screenCoord.origin.y;
723 }
724 
726 {
727  return [m_window screen];
728 }
729 
730 /* called for event, when window leaves monitor to another */
732 {
733  NSView *view = (m_openGLView) ? m_openGLView : m_metalView;
734  NSRect backingBounds = [view convertRectToBacking:[view bounds]];
735 
736  GHOST_Rect rect;
737  getClientBounds(rect);
738 
739  m_nativePixelSize = (float)backingBounds.size.width / (float)rect.getWidth();
740 }
741 
750 {
751  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setState(): window invalid");
752  switch (state) {
754  [m_window miniaturize:nil];
755  break;
757  [m_window zoom:nil];
758  break;
759 
761  NSUInteger masks = [m_window styleMask];
762 
763  if (!(masks & NSWindowStyleMaskFullScreen)) {
764  [m_window toggleFullScreen:nil];
765  }
766  break;
767  }
769  default:
770  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
771  NSUInteger masks = [m_window styleMask];
772 
773  if (masks & NSWindowStyleMaskFullScreen) {
774  // Lion style fullscreen
775  [m_window toggleFullScreen:nil];
776  }
777  else if ([m_window isMiniaturized])
778  [m_window deminiaturize:nil];
779  else if ([m_window isZoomed])
780  [m_window zoom:nil];
781  [pool drain];
782  break;
783  }
784 
785  return GHOST_kSuccess;
786 }
787 
789 {
790  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
791 
792  [m_window setDocumentEdited:isUnsavedChanges];
793 
794  [pool drain];
795  return GHOST_Window::setModifiedState(isUnsavedChanges);
796 }
797 
799 {
800  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
801 
802  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setOrder(): window invalid");
803  if (order == GHOST_kWindowOrderTop) {
804  [NSApp activateIgnoringOtherApps:YES];
805  [m_window makeKeyAndOrderFront:nil];
806  }
807  else {
808  NSArray *windowsList;
809 
810  [m_window orderBack:nil];
811 
812  // Check for other blender opened windows and make the frontmost key
813  windowsList = [NSApp orderedWindows];
814  if ([windowsList count]) {
815  [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
816  }
817  }
818 
819  [pool drain];
820  return GHOST_kSuccess;
821 }
822 
823 #pragma mark Drawing context
824 
826 {
828 
831 
832  if (context->initializeDrawingContext())
833  return context;
834  else
835  delete context;
836  }
837 
838  return NULL;
839 }
840 
841 #pragma mark invalidate
842 
844 {
845  GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::invalidate(): window invalid");
846  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
847  NSView *view = (m_openGLView) ? m_openGLView : m_metalView;
848  [view setNeedsDisplay:YES];
849  [pool drain];
850  return GHOST_kSuccess;
851 }
852 
853 #pragma mark Progress bar
854 
856 {
857  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
858 
859  if ((progress >= 0.0) && (progress <= 1.0)) {
860  NSImage *dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128, 128)];
861 
862  [dockIcon lockFocus];
863 
864  [[NSImage imageNamed:@"NSApplicationIcon"] drawAtPoint:NSZeroPoint
865  fromRect:NSZeroRect
866  operation:NSCompositingOperationSourceOver
867  fraction:1.0];
868 
869  NSRect progressRect = {{8, 8}, {112, 14}};
870  NSBezierPath *progressPath;
871 
872  /* Draw white track. */
873  [[[NSColor whiteColor] colorWithAlphaComponent:0.6] setFill];
874  progressPath = [NSBezierPath bezierPathWithRoundedRect:progressRect xRadius:7 yRadius:7];
875  [progressPath fill];
876 
877  /* Black progress fill. */
878  [[[NSColor blackColor] colorWithAlphaComponent:0.7] setFill];
879  progressRect = NSInsetRect(progressRect, 2, 2);
880  progressRect.size.width *= progress;
881  progressPath = [NSBezierPath bezierPathWithRoundedRect:progressRect xRadius:5 yRadius:5];
882  [progressPath fill];
883 
884  [dockIcon unlockFocus];
885 
886  [NSApp setApplicationIconImage:dockIcon];
887  [dockIcon release];
888 
889  m_progressBarVisible = true;
890  }
891 
892  [pool drain];
893  return GHOST_kSuccess;
894 }
895 
896 static void postNotification()
897 {
898  NSUserNotification *notification = [[NSUserNotification alloc] init];
899  notification.title = @"Blender Progress Notification";
900  notification.informativeText = @"Calculation is finished.";
901  notification.soundName = NSUserNotificationDefaultSoundName;
902  [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
903  [notification release];
904 }
905 
907 {
909  return GHOST_kFailure;
910  m_progressBarVisible = false;
911 
912  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
913 
914  NSImage *dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128, 128)];
915  [dockIcon lockFocus];
916  [[NSImage imageNamed:@"NSApplicationIcon"] drawAtPoint:NSZeroPoint
917  fromRect:NSZeroRect
918  operation:NSCompositingOperationSourceOver
919  fraction:1.0];
920  [dockIcon unlockFocus];
921  [NSApp setApplicationIconImage:dockIcon];
922 
923  // We use notifications to inform the user when the progress reached 100%
924  // Atm. just fire this when the progressbar ends, the behavior is controlled
925  // in the NotificationCenter If Blender is not frontmost window, a message
926  // pops up with sound, in any case an entry in notifications
927  if ([NSUserNotificationCenter respondsToSelector:@selector(defaultUserNotificationCenter)]) {
929  }
930 
931  [dockIcon release];
932 
933  [pool drain];
934  return GHOST_kSuccess;
935 }
936 
937 #pragma mark Cursor handling
938 
939 static NSCursor *getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSPoint hotspot)
940 {
941  static NSCursor *cursors[(int)GHOST_kStandardCursorNumCursors] = {0};
942  static bool loaded[(int)GHOST_kStandardCursorNumCursors] = {false};
943 
944  const int index = (int)shape;
945  if (!loaded[index]) {
946  /* Load image from file in application Resources folder. */
947  /* clang-format off */
948  @autoreleasepool {
949  /* clang-format on */
950  NSImage *image = [NSImage imageNamed:name];
951  if (image != NULL) {
952  cursors[index] = [[NSCursor alloc] initWithImage:image hotSpot:hotspot];
953  }
954  }
955 
956  loaded[index] = true;
957  }
958 
959  return cursors[index];
960 }
961 
963 {
964  switch (shape) {
966  if (m_customCursor) {
967  return m_customCursor;
968  }
969  else {
970  return NULL;
971  }
973  return [NSCursor disappearingItemCursor];
975  return [NSCursor IBeamCursor];
977  return [NSCursor crosshairCursor];
979  return [NSCursor resizeUpDownCursor];
981  return [NSCursor resizeLeftRightCursor];
983  return [NSCursor resizeUpCursor];
985  return [NSCursor resizeDownCursor];
987  return [NSCursor resizeLeftCursor];
989  return [NSCursor resizeRightCursor];
991  return [NSCursor dragCopyCursor];
993  return [NSCursor operationNotAllowedCursor];
995  return [NSCursor pointingHandCursor];
997  return [NSCursor arrowCursor];
999  return getImageCursor(shape, @"knife.pdf", NSMakePoint(6, 24));
1001  return getImageCursor(shape, @"eraser.pdf", NSMakePoint(6, 24));
1003  return getImageCursor(shape, @"pen.pdf", NSMakePoint(6, 24));
1005  return getImageCursor(shape, @"eyedropper.pdf", NSMakePoint(6, 24));
1007  return getImageCursor(shape, @"zoomin.pdf", NSMakePoint(8, 7));
1009  return getImageCursor(shape, @"zoomout.pdf", NSMakePoint(8, 7));
1011  return getImageCursor(shape, @"scrollnsew.pdf", NSMakePoint(16, 16));
1013  return getImageCursor(shape, @"scrollns.pdf", NSMakePoint(16, 16));
1015  return getImageCursor(shape, @"scrollew.pdf", NSMakePoint(16, 16));
1017  return getImageCursor(shape, @"arrowup.pdf", NSMakePoint(16, 16));
1019  return getImageCursor(shape, @"arrowdown.pdf", NSMakePoint(16, 16));
1021  return getImageCursor(shape, @"arrowleft.pdf", NSMakePoint(16, 16));
1023  return getImageCursor(shape, @"arrowright.pdf", NSMakePoint(16, 16));
1025  return getImageCursor(shape, @"splitv.pdf", NSMakePoint(16, 16));
1027  return getImageCursor(shape, @"splith.pdf", NSMakePoint(16, 16));
1029  return getImageCursor(shape, @"paint_cursor_cross.pdf", NSMakePoint(16, 15));
1031  return getImageCursor(shape, @"paint_cursor_dot.pdf", NSMakePoint(16, 15));
1033  return getImageCursor(shape, @"crossc.pdf", NSMakePoint(16, 16));
1034  default:
1035  return NULL;
1036  }
1037 }
1038 
1039 void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor shape) const
1041  static bool systemCursorVisible = true;
1042  if (visible != systemCursorVisible) {
1043  if (visible) {
1044  [NSCursor unhide];
1045  systemCursorVisible = true;
1046  }
1047  else {
1048  [NSCursor hide];
1049  systemCursorVisible = false;
1050  }
1051  }
1052 
1053  NSCursor *cursor = getStandardCursor(shape);
1054  if (cursor == NULL) {
1056  }
1057 
1058  [cursor set];
1059 }
1060 
1061 bool GHOST_WindowCocoa::isDialog() const
1063  return m_is_dialog;
1064 }
1065 
1068  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1069 
1070  if ([m_window isVisible]) {
1071  loadCursor(visible, getCursorShape());
1072  }
1073 
1074  [pool drain];
1075  return GHOST_kSuccess;
1076 }
1077 
1081 
1082  if (mode != GHOST_kGrabDisable) {
1083  // No need to perform grab without warp as it is always on in OS X
1084  if (mode != GHOST_kGrabNormal) {
1085  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1086 
1088  setCursorGrabAccum(0, 0);
1089 
1090  if (mode == GHOST_kGrabHide) {
1092  }
1093 
1094  // Make window key if it wasn't to get the mouse move events
1095  [m_window makeKeyWindow];
1096 
1097  [pool drain];
1098  }
1099  }
1100  else {
1101  if (m_cursorGrab == GHOST_kGrabHide) {
1104  }
1105 
1106  /* Almost works without but important otherwise the mouse GHOST location
1107  * can be incorrect on exit. */
1108  setCursorGrabAccum(0, 0);
1109  m_cursorGrabBounds.m_l = m_cursorGrabBounds.m_r = -1; /* disable */
1110  }
1111  return err;
1112 }
1113 
1116  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1117 
1118  if ([m_window isVisible]) {
1119  loadCursor(getCursorVisibility(), shape);
1120  }
1121 
1122  [pool drain];
1123  return GHOST_kSuccess;
1124 }
1125 
1128  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1130  [pool drain];
1131  return success;
1132 }
1133 
1134 /* Reverse the bits in a GHOST_TUns8 */
1135 #if 0
1137 {
1138  ch= ((ch >> 1) & 0x55) | ((ch << 1) & 0xAA);
1139  ch= ((ch >> 2) & 0x33) | ((ch << 2) & 0xCC);
1140  ch= ((ch >> 4) & 0x0F) | ((ch << 4) & 0xF0);
1141  return ch;
1142 }
1143 #endif
1144 
1148  shrt = ((shrt >> 1) & 0x5555) | ((shrt << 1) & 0xAAAA);
1149  shrt = ((shrt >> 2) & 0x3333) | ((shrt << 2) & 0xCCCC);
1150  shrt = ((shrt >> 4) & 0x0F0F) | ((shrt << 4) & 0xF0F0);
1151  shrt = ((shrt >> 8) & 0x00FF) | ((shrt << 8) & 0xFF00);
1152  return shrt;
1153 }
1154 
1157  int sizex,
1158  int sizey,
1159  int hotX,
1160  int hotY,
1161  bool canInvertColor)
1162 {
1163  int y, nbUns16;
1164  NSPoint hotSpotPoint;
1165  NSBitmapImageRep *cursorImageRep;
1166  NSImage *cursorImage;
1167  NSSize imSize;
1168  GHOST_TUns16 *cursorBitmap;
1169 
1170  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1171 
1172  if (m_customCursor) {
1173  [m_customCursor release];
1174  m_customCursor = nil;
1175  }
1176 
1177  cursorImageRep = [[NSBitmapImageRep alloc]
1178  initWithBitmapDataPlanes:nil
1179  pixelsWide:sizex
1180  pixelsHigh:sizey
1181  bitsPerSample:1
1182  samplesPerPixel:2
1183  hasAlpha:YES
1184  isPlanar:YES
1185  colorSpaceName:NSDeviceWhiteColorSpace
1186  bytesPerRow:(sizex / 8 + (sizex % 8 > 0 ? 1 : 0))
1187  bitsPerPixel:1];
1188 
1189  cursorBitmap = (GHOST_TUns16 *)[cursorImageRep bitmapData];
1190  nbUns16 = [cursorImageRep bytesPerPlane] / 2;
1191 
1192  for (y = 0; y < nbUns16; y++) {
1193 #if !defined(__LITTLE_ENDIAN__)
1194  cursorBitmap[y] = uns16ReverseBits((bitmap[2 * y] << 0) | (bitmap[2 * y + 1] << 8));
1195  cursorBitmap[nbUns16 + y] = uns16ReverseBits((mask[2 * y] << 0) | (mask[2 * y + 1] << 8));
1196 #else
1197  cursorBitmap[y] = uns16ReverseBits((bitmap[2 * y + 1] << 0) | (bitmap[2 * y] << 8));
1198  cursorBitmap[nbUns16 + y] = uns16ReverseBits((mask[2 * y + 1] << 0) | (mask[2 * y] << 8));
1199 #endif
1200 
1201  /* Flip white cursor with black outline to black cursor with white outline
1202  * to match macOS platform conventions. */
1203  if (canInvertColor) {
1204  cursorBitmap[y] = ~cursorBitmap[y];
1205  }
1206  }
1207 
1208  imSize.width = sizex;
1209  imSize.height = sizey;
1210  cursorImage = [[NSImage alloc] initWithSize:imSize];
1211  [cursorImage addRepresentation:cursorImageRep];
1212 
1213  hotSpotPoint.x = hotX;
1214  hotSpotPoint.y = hotY;
1215 
1216  // foreground and background color parameter is not handled for now (10.6)
1217  m_customCursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:hotSpotPoint];
1218 
1219  [cursorImageRep release];
1220  [cursorImage release];
1221 
1222  if ([m_window isVisible]) {
1224  }
1225  [pool drain];
1226  return GHOST_kSuccess;
1227 }
typedef float(TangentPoint)[2]
static AppView * view
#define GHOST_ASSERT(x, info)
Definition: GHOST_Debug.h:79
static const std::unordered_map< GHOST_TStandardCursor, std::string > cursors
GHOST_TWindowState
Definition: GHOST_Types.h:144
@ GHOST_kWindowStateMinimized
Definition: GHOST_Types.h:147
@ GHOST_kWindowStateMaximized
Definition: GHOST_Types.h:146
@ GHOST_kWindowStateNormal
Definition: GHOST_Types.h:145
@ GHOST_kWindowStateFullScreen
Definition: GHOST_Types.h:148
GHOST_TStandardCursor
Definition: GHOST_Types.h:222
@ GHOST_kStandardCursorZoomIn
Definition: GHOST_Types.h:244
@ GHOST_kStandardCursorVerticalSplit
Definition: GHOST_Types.h:239
@ GHOST_kStandardCursorCopy
Definition: GHOST_Types.h:261
@ GHOST_kStandardCursorHorizontalSplit
Definition: GHOST_Types.h:240
@ GHOST_kStandardCursorTopSide
Definition: GHOST_Types.h:253
@ GHOST_kStandardCursorStop
Definition: GHOST_Types.h:250
@ GHOST_kStandardCursorCrosshair
Definition: GHOST_Types.h:232
@ GHOST_kStandardCursorCustom
Definition: GHOST_Types.h:262
@ GHOST_kStandardCursorNSEWScroll
Definition: GHOST_Types.h:247
@ GHOST_kStandardCursorLeftRight
Definition: GHOST_Types.h:252
@ GHOST_kStandardCursorPencil
Definition: GHOST_Types.h:236
@ GHOST_kStandardCursorNSScroll
Definition: GHOST_Types.h:248
@ GHOST_kStandardCursorCrosshairA
Definition: GHOST_Types.h:233
@ GHOST_kStandardCursorUpDown
Definition: GHOST_Types.h:251
@ GHOST_kStandardCursorUpArrow
Definition: GHOST_Types.h:237
@ GHOST_kStandardCursorBottomSide
Definition: GHOST_Types.h:254
@ GHOST_kStandardCursorEyedropper
Definition: GHOST_Types.h:243
@ GHOST_kStandardCursorKnife
Definition: GHOST_Types.h:242
@ GHOST_kStandardCursorMove
Definition: GHOST_Types.h:246
@ GHOST_kStandardCursorCrosshairB
Definition: GHOST_Types.h:234
@ GHOST_kStandardCursorDownArrow
Definition: GHOST_Types.h:238
@ GHOST_kStandardCursorEraser
Definition: GHOST_Types.h:241
@ GHOST_kStandardCursorDefault
Definition: GHOST_Types.h:224
@ GHOST_kStandardCursorEWScroll
Definition: GHOST_Types.h:249
@ GHOST_kStandardCursorRightSide
Definition: GHOST_Types.h:256
@ GHOST_kStandardCursorRightArrow
Definition: GHOST_Types.h:225
@ GHOST_kStandardCursorDestroy
Definition: GHOST_Types.h:228
@ GHOST_kStandardCursorCrosshairC
Definition: GHOST_Types.h:235
@ GHOST_kStandardCursorZoomOut
Definition: GHOST_Types.h:245
@ GHOST_kStandardCursorLeftSide
Definition: GHOST_Types.h:255
@ GHOST_kStandardCursorText
Definition: GHOST_Types.h:231
@ GHOST_kStandardCursorLeftArrow
Definition: GHOST_Types.h:226
unsigned int GHOST_TUns32
Definition: GHOST_Types.h:64
@ GHOST_kEventWindowClose
Definition: GHOST_Types.h:197
@ GHOST_kEventWindowMove
Definition: GHOST_Types.h:202
@ GHOST_kEventWindowSize
Definition: GHOST_Types.h:201
@ GHOST_kEventDraggingDropDone
Definition: GHOST_Types.h:208
@ GHOST_kEventDraggingExited
Definition: GHOST_Types.h:207
@ GHOST_kEventNativeResolutionChange
Definition: GHOST_Types.h:211
@ GHOST_kEventDraggingUpdated
Definition: GHOST_Types.h:206
@ GHOST_kEventDraggingEntered
Definition: GHOST_Types.h:205
@ GHOST_kEventWindowActivate
Definition: GHOST_Types.h:198
@ GHOST_kEventWindowUpdate
Definition: GHOST_Types.h:200
@ GHOST_kEventWindowDeactivate
Definition: GHOST_Types.h:199
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
Definition: GHOST_Types.h:119
int GHOST_TInt32
Definition: GHOST_Types.h:63
unsigned short GHOST_TUns16
Definition: GHOST_Types.h:62
GHOST_TDrawingContextType
Definition: GHOST_Types.h:156
@ GHOST_kDrawingContextTypeOpenGL
Definition: GHOST_Types.h:158
GHOST_TWindowOrder
Definition: GHOST_Types.h:154
@ GHOST_kWindowOrderTop
Definition: GHOST_Types.h:154
GHOST_TSuccess
Definition: GHOST_Types.h:91
@ GHOST_kFailure
Definition: GHOST_Types.h:91
@ GHOST_kSuccess
Definition: GHOST_Types.h:91
GHOST_TGrabCursorMode
Definition: GHOST_Types.h:412
@ GHOST_kGrabDisable
Definition: GHOST_Types.h:414
@ GHOST_kGrabHide
Definition: GHOST_Types.h:420
@ GHOST_kGrabNormal
Definition: GHOST_Types.h:416
GHOST_TDragnDropTypes
Definition: GHOST_Types.h:477
@ GHOST_kDragnDropTypeUnknown
Definition: GHOST_Types.h:478
@ GHOST_kDragnDropTypeFilenames
Definition: GHOST_Types.h:479
@ GHOST_kDragnDropTypeBitmap
Definition: GHOST_Types.h:481
@ GHOST_kDragnDropTypeString
Definition: GHOST_Types.h:480
unsigned char GHOST_TUns8
Definition: GHOST_Types.h:60
static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
static NSCursor * getImageCursor(GHOST_TStandardCursor shape, NSString *name, NSPoint hotspot)
static void postNotification()
associatedWindow
static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition: btDbvt.cpp:299
virtual GHOST_TInt32 getWidth() const
Definition: GHOST_Rect.h:182
GHOST_TInt32 m_l
Definition: GHOST_Rect.h:169
GHOST_TInt32 m_r
Definition: GHOST_Rect.h:173
virtual GHOST_TInt32 getHeight() const
Definition: GHOST_Rect.h:187
GHOST_TSuccess handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa *window)
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowCocoa *window, int mouseX, int mouseY, void *data)
GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
GHOST_TSuccess getCursorPosition(GHOST_TInt32 &x, GHOST_TInt32 &y) const
void dispatchEvents()
bool m_nativePixel
Definition: GHOST_System.h:168
void clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
GHOST_TSuccess setClientWidth(GHOST_TUns32 width)
GHOST_WindowCocoa(GHOST_SystemCocoa *systemCocoa, const char *title, GHOST_TInt32 left, GHOST_TInt32 bottom, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type=GHOST_kDrawingContextTypeNone, const bool stereoVisual=false, bool is_debug=false, bool dialog=false, GHOST_WindowCocoa *parentWindow=0)
GHOST_SystemCocoa * m_systemCocoa
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor shape)
void setImmediateDraw(bool value)
void setTitle(const char *title)
std::string getTitle() const
void clientToScreenIntern(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
GHOST_Context * newDrawingContext(GHOST_TDrawingContextType type)
GHOST_TSuccess setWindowCursorVisibility(bool visible)
CocoaOpenGLView * m_openGLView
CAMetalLayer * m_metalLayer
CocoaWindow * m_window
GHOST_TSuccess setOrder(GHOST_TWindowOrder order)
NSCursor * getStandardCursor(GHOST_TStandardCursor cursor) const
GHOST_TWindowState getState() const
GHOST_TabletData m_tablet
void getWindowBounds(GHOST_Rect &bounds) const
GHOST_TSuccess setClientSize(GHOST_TUns32 width, GHOST_TUns32 height)
void getClientBounds(GHOST_Rect &bounds) const
void * getOSWindow() const
void screenToClientIntern(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
GHOST_TSuccess setModifiedState(bool isUnsavedChanges)
GHOST_TSuccess setState(GHOST_TWindowState state)
void setNativePixelSize(void)
void screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32 &outX, GHOST_TInt32 &outY) const
GHOST_TSuccess invalidate()
CocoaMetalView * m_metalView
GHOST_TSuccess setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
GHOST_TSuccess setClientHeight(GHOST_TUns32 height)
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape)
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode)
void loadCursor(bool visible, GHOST_TStandardCursor cursor) const
GHOST_TSuccess setProgressBar(float progress)
GHOST_TSuccess endProgressBar()
GHOST_Rect m_cursorGrabBounds
Definition: GHOST_Window.h:378
bool getCursorVisibility() const
Definition: GHOST_Window.h:415
GHOST_TGrabCursorMode m_cursorGrab
Definition: GHOST_Window.h:366
bool m_wantStereoVisual
Definition: GHOST_Window.h:396
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type)
GHOST_TSuccess releaseNativeHandles()
virtual GHOST_TSuccess setModifiedState(bool isUnsavedChanges)
bool canAcceptDragOperation() const
GHOST_TInt32 m_cursorGrabInitPos[2]
Definition: GHOST_Window.h:372
virtual bool getValid() const
Definition: GHOST_Window.h:92
void setCursorGrabAccum(GHOST_TInt32 x, GHOST_TInt32 y)
Definition: GHOST_Window.h:447
float m_nativePixelSize
Definition: GHOST_Window.h:404
void setAcceptDragOperation(bool canAccept)
GHOST_TSuccess updateDrawingContext()
bool m_progressBarVisible
Definition: GHOST_Window.h:384
virtual GHOST_TSuccess activateDrawingContext()
GHOST_TStandardCursor getCursorShape() const
Definition: GHOST_Window.h:453
static FT_Error err
Definition: freetypefont.c:52
GHOST_WindowCocoa * associatedWindow
void setSystemAndWindowCocoa:windowCocoa:(GHOST_SystemCocoa *sysCocoa,[windowCocoa] GHOST_WindowCocoa *winCocoa)
GHOST_SystemCocoa * systemCocoa
GHOST_SystemCocoa * systemCocoa
GHOST_WindowCocoa * associatedWindow
void setSystemAndWindowCocoa:windowCocoa:(GHOST_SystemCocoa *sysCocoa,[windowCocoa] GHOST_WindowCocoa *winCocoa)
GHOST_TDragnDropTypes m_draggedObjectType
int count
static char ** types
Definition: makesdna.c:164
static ulong state[N]
static int left
static unsigned a[3]
Definition: RandGen.cpp:92
struct SELECTID_Context context
Definition: select_engine.c:47
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
uint len