22# pragma clang diagnostic ignored "-Wdeprecated-declarations"
25#ifdef WITH_METAL_BACKEND
29#ifdef WITH_VULKAN_BACKEND
37#include "AssertMacros.h"
39#import <Cocoa/Cocoa.h>
42#include <Carbon/Carbon.h>
44#include <sys/sysctl.h>
48#include <mach/mach_time.h>
138 case kVK_ANSI_Keypad0:
140 case kVK_ANSI_Keypad1:
142 case kVK_ANSI_Keypad2:
144 case kVK_ANSI_Keypad3:
146 case kVK_ANSI_Keypad4:
148 case kVK_ANSI_Keypad5:
150 case kVK_ANSI_Keypad6:
152 case kVK_ANSI_Keypad7:
154 case kVK_ANSI_Keypad8:
156 case kVK_ANSI_Keypad9:
158 case kVK_ANSI_KeypadDecimal:
160 case kVK_ANSI_KeypadEnter:
162 case kVK_ANSI_KeypadPlus:
164 case kVK_ANSI_KeypadMinus:
166 case kVK_ANSI_KeypadMultiply:
168 case kVK_ANSI_KeypadDivide:
170 case kVK_ANSI_KeypadClear:
227 case kVK_ForwardDelete:
268 if ((recvChar >=
'A') && (recvChar <=
'Z')) {
272 if ((recvChar >=
'a') && (recvChar <=
'z')) {
277 const TISInputSourceRef kbdTISHandle = TISCopyCurrentKeyboardLayoutInputSource();
279 const CFDataRef uchrHandle =
static_cast<CFDataRef
>(
280 TISGetInputSourceProperty(kbdTISHandle, kTISPropertyUnicodeKeyLayoutData));
281 CFRelease(kbdTISHandle);
287 UInt32 deadKeyState = 0;
288 UniCharCount actualStrLength = 0;
290 UCKeyTranslate((UCKeyboardLayout *)CFDataGetBytePtr(uchrHandle),
295 kUCKeyTranslateNoDeadKeysMask,
341#define FIRSTFILEBUFLG 512
371- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
372- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
373- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
374- (void)applicationWillTerminate:(NSNotification *)aNotification;
375- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
376- (void)toggleFullScreen:(NSNotification *)notification;
377- (void)windowWillClose:(NSNotification *)notification;
379- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
394 selector:@selector(windowWillClose:)
395 name:NSWindowWillCloseNotification
407 [
center removeObserver:
self name:NSWindowWillCloseNotification object:nil];
412- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
414 if (m_systemCocoa->m_windowFocus) {
419 [
NSApp activateIgnoringOtherApps:YES];
422 [
NSEvent setMouseCoalescingEnabled:NO];
425- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
427 return m_systemCocoa->handleOpenDocumentRequest(filename);
430- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
435 m_systemCocoa->handleQuitRequest();
436 return NSTerminateCancel;
442- (void)applicationWillTerminate:(NSNotification *)aNotification
449- (void)applicationWillBecomeActive:(NSNotification *)aNotification
451 m_systemCocoa->handleApplicationBecomeActiveEvent();
454- (void)toggleFullScreen:(NSNotification *)notification
475- (void)windowWillClose:(NSNotification *)notification
478 NSWindow *closing_window = (NSWindow *)[notification
object];
480 if (![closing_window isKeyWindow]) {
491 const NSInteger index = [[
NSApp orderedWindows] indexOfObject:closing_window];
492 if (index != NSNotFound) {
496 for (NSWindow *current_window
in [NSApp orderedWindows]) {
497 if (current_window == closing_window) {
500 if (current_window.isOnActiveSpace && current_window.canBecomeKeyWindow) {
506 for (NSNumber *window_number
in [NSWindow windowNumbersWithOptions:0]) {
507 NSWindow *current_window = [
NSApp windowWithWindowNumber:[
window_number integerValue]];
508 if (current_window == closing_window) {
511 if ([current_window canBecomeKeyWindow]) {
527- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
560 [
NSApp setDelegate:nil];
571#ifdef WITH_INPUT_NDOF
579 if (!GetCurrentProcess(&psn)) {
580 TransformProcessType(&psn, kProcessTransformToForegroundApplication);
581 SetFrontProcess(&psn);
588 if ([NSApp mainMenu] == nil) {
589 NSMenu *mainMenubar = [[
NSMenu alloc] init];
590 NSMenuItem *menuItem;
595 appMenu = [[
NSMenu alloc] initWithTitle:@"Blender"];
597 [
appMenu addItemWithTitle:@"About Blender"
598 action:@selector(orderFrontStandardAboutPanel:)
602 menuItem = [
appMenu addItemWithTitle:@"Hide Blender"
603 action:@selector(hide:)
605 menuItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
607 menuItem = [
appMenu addItemWithTitle:@"Hide Others"
608 action:@selector(hideOtherApplications:)
610 menuItem.keyEquivalentModifierMask = (NSEventModifierFlagOption |
611 NSEventModifierFlagCommand);
613 [
appMenu addItemWithTitle:@"Show All"
614 action:@selector(unhideAllApplications:)
617 menuItem = [
appMenu addItemWithTitle:@"Quit Blender"
618 action:@selector(terminate:)
620 menuItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
623 menuItem.submenu = appMenu;
630 windowMenu = [[
NSMenu alloc] initWithTitle:@"Window"];
632 menuItem = [
windowMenu addItemWithTitle:@"Minimize"
633 action:@selector(performMiniaturize:)
635 menuItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
637 [
windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
639 menuItem = [
windowMenu addItemWithTitle:@"Enter Full Screen"
640 action:@selector(toggleFullScreen:)
642 menuItem.keyEquivalentModifierMask = NSEventModifierFlagControl |
643 NSEventModifierFlagCommand;
645 menuItem = [
windowMenu addItemWithTitle:@"Close"
646 action:@selector(performClose:)
648 menuItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
651 menuItem.submenu = windowMenu;
656 [
NSApp setMainMenu:mainMenubar];
657 [
NSApp setWindowsMenu:windowMenu];
661 if ([NSApp delegate] == nil) {
663 [
NSApp setDelegate:appDelegate];
669 NSWindow.allowsAutomaticWindowTabbing = NO;
671 [
NSApp finishLaunching];
701 const NSRect contentRect = [
NSWindow
702 contentRectForFrameRect:frame
703 styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
704 NSWindowStyleMaskMiniaturizable)];
706 width = contentRect.size.width;
707 height = contentRect.size.height;
725 const bool is_dialog,
731 const NSRect primaryScreenFrame = [
GHOST_WindowCocoa::getPrimaryScreen() visibleFrame];
732 const NSRect primaryScreenContentRect = [
NSWindow
733 contentRectForFrameRect:primaryScreenFrame
734 styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
735 NSWindowStyleMaskMiniaturizable)];
737 const int32_t bottom = primaryScreenContentRect.size.height -
top - height;
764 GHOST_PRINT(
"GHOST_SystemCocoa::createWindow(): window invalid\n");
782#ifdef WITH_VULKAN_BACKEND
783 case GHOST_kDrawingContextTypeVulkan: {
786 if (context->initializeDrawingContext()) {
794#ifdef WITH_METAL_BACKEND
795 case GHOST_kDrawingContextTypeMetal: {
798 if (context->initializeDrawingContext()) {
826 const NSPoint scr_co = NSMakePoint(
x,
y);
829 const int windowNumberAtPoint = [
NSWindow windowNumberAtPoint:scr_co
830 belowWindowWithWindowNumber:0];
831 NSWindow *nswindow = [
NSApp windowWithWindowNumber:windowNumberAtPoint];
833 if (nswindow == nil) {
837 return m_windowManager->getWindowAssociatedWithOSWindow((
const void *)nswindow);
846 const NSPoint mouseLoc = [
NSEvent mouseLocation];
866 CGAssociateMouseAndMouseCursorPosition(
false);
868 CGAssociateMouseAndMouseCursorPosition(
true);
882 __block BOOL selectCompleted = NO;
883 __block BOOL samplingSucceeded = NO;
885 [
sampler showSamplerWithSelectionHandler:^(NSColor *selectedColor) {
886 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)),
887 dispatch_get_main_queue(),
889 if (selectedColor != nil) {
891 colorUsingColorSpace:[
NSColorSpace deviceRGBColorSpace]];
894 r_color[1] = [
rgbColor greenComponent];
895 r_color[2] = [
rgbColor blueComponent];
897 samplingSucceeded = YES;
899 selectCompleted = YES;
903 while (!selectCompleted) {
904 [[
NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
905 beforeDate:[
NSDate dateWithTimeIntervalSinceNow:0.05]];
914 float xf = float(
x), yf = float(
y);
921 NSScreen *windowScreen = window->
getScreen();
922 const NSRect screenRect = windowScreen.frame;
925 xf -= screenRect.origin.x;
926 yf -= screenRect.origin.y;
929 yf = screenRect.size.height - yf;
931 CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription]
932 objectForKey:
@"NSScreenNumber"] unsignedIntValue],
933 CGPointMake(xf, yf));
940 CGAssociateMouseAndMouseCursorPosition(
true);
959 const UInt32 button_state = GetCurrentEventButtonState();
991 bool anyProcessed =
false;
1004 timeOut = kEventDurationForever;
1012 ::ReceiveNextEvent(0,
nullptr, timeOut,
false, &event);
1016 anyProcessed =
true;
1021 event = [
NSApp nextEventMatchingMask:NSEventMaskAny
1022 untilDate:[
NSDate distantPast]
1023 inMode:NSDefaultRunLoopMode
1029 anyProcessed =
true;
1039 if (event.type == NSEventTypeKeyDown && event.keyCode == kVK_Tab &&
1040 (event.modifierFlags & NSEventModifierFlagControl))
1048 if (event.type == NSEventTypeKeyUp &&
1049 (event.modifierFlags & (NSEventModifierFlagCommand | NSEventModifierFlagOption)))
1054 [
NSApp sendEvent:event];
1057 }
while (event != nil);
1059 }
while (waitForEvent && !anyProcessed);
1073 return anyProcessed;
1083 [
window->getViewWindow() makeKeyAndOrderFront:nil];
1098 const unsigned int modifiers = [[[
NSApplication sharedApplication] currentEvent]
1101 if ((modifiers & NSEventModifierFlagShift) != (
m_modifierMask & NSEventModifierFlagShift)) {
1109 if ((modifiers & NSEventModifierFlagControl) != (
m_modifierMask & NSEventModifierFlagControl))
1118 if ((modifiers & NSEventModifierFlagOption) != (
m_modifierMask & NSEventModifierFlagOption)) {
1126 if ((modifiers & NSEventModifierFlagCommand) != (
m_modifierMask & NSEventModifierFlagCommand))
1166 switch (eventType) {
1230 NSImageRep *imageRepresentation = [[image representations] firstObject];
1231 return NSMakeSize(imageRepresentation.pixelsWide, imageRepresentation.pixelsHigh);
1250 NSBitmapImageRep *bitmapImage = nil;
1251 for (NSImageRep *representation
in [image representations]) {
1252 if ([representation isKindOfClass:[NSBitmapImageRep
class]]) {
1253 bitmapImage = (NSBitmapImageRep *)representation;
1258 if (bitmapImage == nil || bitmapImage.bitsPerPixel != 32 || bitmapImage.isPlanar ||
1259 bitmapImage.bitmapFormat & (NSBitmapFormatAlphaFirst | NSBitmapFormatFloatingPointSamples))
1265 uint8_t *bmp_data = (uint8_t *)bitmapImage.bitmapData;
1269 const int row_byte_count = 4 *
imageSize.width;
1270 const int ibuf_off = (
imageSize.height -
y - 1) * row_byte_count;
1271 const int bmp_off =
y * row_byte_count;
1272 memcpy(ibuf_data + ibuf_off, bmp_data + bmp_off, row_byte_count);
1290 switch (eventType) {
1296 getMilliSeconds(), eventType, draggedObjectType, window, mouseX, mouseY,
nullptr));
1306 switch (draggedObjectType) {
1308 NSArray *droppedArray = (NSArray *)
data;
1316 strArray->
count = droppedArray.count;
1317 if (strArray->
count == 0) {
1322 strArray->
strings = (uint8_t **)malloc(strArray->
count *
sizeof(uint8_t *));
1324 for (
int i = 0;
i < strArray->
count;
i++) {
1327 lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1328 uint8_t *temp_buff = (uint8_t *)malloc(pastedTextSize + 1);
1336 [droppedStr cStringUsingEncoding:NSUTF8StringEncoding],
1340 strArray->
strings[i] = temp_buff;
1347 NSString *droppedStr = (NSString *)
data;
1349 lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1350 uint8_t *temp_buff = (uint8_t *)malloc(pastedTextSize + 1);
1352 if (temp_buff ==
nullptr) {
1357 temp_buff, [droppedStr cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
1364 NSImage *droppedImg =
static_cast<NSImage *
>(
data);
1380 getMilliSeconds(), eventType, draggedObjectType, window, mouseX, mouseY, eventData));
1407 NSString *filepath = (NSString *)filepathStr;
1413 NSArray *windowsList = [
NSApp orderedWindows];
1414 if ([windowsList
count]) {
1415 [[
windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
1432 const size_t filenameTextSize = [
filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1433 char *temp_buff = (
char *)malloc(filenameTextSize + 1);
1435 if (temp_buff ==
nullptr) {
1439 memcpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize);
1452 NSEvent *
event = (NSEvent *)eventPtr;
1455 (
const void *)event.window);
1463 switch (eventType) {
1464 case NSEventTypeTabletPoint:
1474 ct.
Xtilt =
event.tilt.x;
1478 ct.
Ytilt = -
event.tilt.y;
1481 case NSEventTypeTabletProximity:
1484 if (event.isEnteringProximity) {
1486 switch (event.pointingDeviceType) {
1487 case NSPointingDeviceTypePen:
1490 case NSPointingDeviceTypeEraser:
1493 case NSPointingDeviceTypeCursor:
1494 case NSPointingDeviceTypeUnknown:
1502 GHOST_ASSERT(
FALSE,
"GHOST_SystemCocoa::handleTabletEvent : unknown event received");
1511 NSEvent *
event = (NSEvent *)eventPtr;
1513 switch (event.subtype) {
1514 case NSEventSubtypeTabletPoint:
1517 case NSEventSubtypeTabletProximity:
1528 NSEvent *
event = (NSEvent *)eventPtr;
1534 ->getWindowAssociatedWithOSWindow((
const void *)event.window);
1543 switch (event.type) {
1544 case NSEventTypeLeftMouseDown:
1552 case NSEventTypeRightMouseDown:
1560 case NSEventTypeOtherMouseDown:
1568 case NSEventTypeLeftMouseUp:
1576 case NSEventTypeRightMouseUp:
1584 case NSEventTypeOtherMouseUp:
1592 case NSEventTypeLeftMouseDragged:
1593 case NSEventTypeRightMouseDragged:
1594 case NSEventTypeOtherMouseDragged:
1597 case NSEventTypeMouseMoved: {
1601 bool is_tablet =
false;
1607 switch (grab_mode) {
1610 int32_t x_warp, y_warp, x_accum, y_accum,
x,
y;
1617 x_accum +=
event.deltaX;
1618 y_accum += -
event.deltaY;
1632 const NSTimeInterval timestamp =
event.timestamp;
1651 correctedBounds.
m_b = (windowBounds.
m_b - windowBounds.
m_t) - correctedBounds.
m_b;
1652 correctedBounds.
m_t = (windowBounds.
m_b - windowBounds.
m_t) - correctedBounds.
m_t;
1658 const NSPoint mousePos =
event.locationInWindow;
1660 const int32_t x_mouse = mousePos.x;
1661 const int32_t y_mouse = mousePos.y;
1664 int32_t warped_x_mouse = x_mouse;
1665 int32_t warped_y_mouse = y_mouse;
1670 if (x_mouse != warped_x_mouse || y_mouse != warped_y_mouse) {
1675 y_accum + (y_mouse - warped_y_mouse));
1694 const NSPoint mousePos =
event.locationInWindow;
1709 case NSEventTypeScrollWheel: {
1710 const NSEventPhase momentumPhase =
event.momentumPhase;
1711 const NSEventPhase phase =
event.phase;
1717 if (momentumPhase) {
1732 else if (phase == NSEventPhaseEnded) {
1739 if (event.deltaX != 0.0) {
1740 const int32_t delta =
event.deltaX > 0.0 ? 1 : -1;
1744 if (event.deltaY != 0.0) {
1745 const int32_t delta =
event.deltaY > 0.0 ? 1 : -1;
1751 const NSPoint mousePos =
event.locationInWindow;
1754 double dx =
event.scrollingDeltaX;
1755 double dy =
event.scrollingDeltaY;
1759 if (phase == NSEventPhaseNone && momentumPhase == NSEventPhaseNone) {
1771 convertPointToBacking:NSMakePoint(dx, dy)];
1779 event.isDirectionInvertedFromDevice));
1784 case NSEventTypeMagnify: {
1785 const NSPoint mousePos =
event.locationInWindow;
1793 event.magnification * 125.0 + 0.1,
1798 case NSEventTypeSmartMagnify: {
1799 const NSPoint mousePos =
event.locationInWindow;
1806 case NSEventTypeRotate: {
1807 const NSPoint mousePos =
event.locationInWindow;
1815 event.rotation * -5.0,
1828 NSEvent *
event = (NSEvent *)eventPtr;
1830 (
const void *)event.window);
1837 switch (event.type) {
1838 case NSEventTypeKeyDown:
1839 case NSEventTypeKeyUp: {
1842 char utf8_buf[6] = {
'\0'};
1845 NSString *charsIgnoringModifiers =
event.charactersIgnoringModifiers;
1846 if (charsIgnoringModifiers.length > 0) {
1847 keyCode =
convertKey(event.keyCode, [charsIgnoringModifiers characterAtIndex:0]);
1853 NSString *characters =
event.characters;
1854 if ([characters
length] > 0) {
1855 NSData *convertedCharacters = [
characters dataUsingEncoding:NSUTF8StringEncoding];
1857 for (
int x = 0;
x < convertedCharacters.length;
x++) {
1858 utf8_buf[x] = ((
char *)convertedCharacters.bytes)[x];
1882 if (event.type == NSEventTypeKeyDown) {
1890 printf(
"Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n",
1892 charsIgnoringModifiers.length > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
1902 printf(
"Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u utf8=%s\n",
1904 charsIgnoringModifiers.length > 0 ? [charsIgnoringModifiers characterAtIndex:0] :
1913 case NSEventTypeFlagsChanged: {
1914 const unsigned int modifiers =
event.modifierFlags;
1916 if ((modifiers & NSEventModifierFlagShift) != (
m_modifierMask & NSEventModifierFlagShift)) {
1924 if ((modifiers & NSEventModifierFlagControl) !=
1928 event.timestamp * 1000,
1934 if ((modifiers & NSEventModifierFlagOption) != (
m_modifierMask & NSEventModifierFlagOption))
1937 event.timestamp * 1000,
1943 if ((modifiers & NSEventModifierFlagCommand) !=
1947 event.timestamp * 1000,
1973 NSPasteboard *pasteBoard = [
NSPasteboard generalPasteboard];
1974 NSString *textPasted = [
pasteBoard stringForType:NSPasteboardTypeString];
1976 if (textPasted == nil) {
1980 const size_t pastedTextSize = [
textPasted lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
1982 char *temp_buff = (
char *)malloc(pastedTextSize + 1);
1984 if (temp_buff ==
nullptr) {
1988 memcpy(temp_buff, [textPasted cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
2005 NSPasteboard *pasteBoard = NSPasteboard.generalPasteboard;
2008 NSString *textToCopy = [
NSString stringWithCString:buffer encoding:NSUTF8StringEncoding];
2009 [
pasteBoard setString:textToCopy forType:NSPasteboardTypeString];
2015 NSURL *pasteboardImageFile = nil;
2018 NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
2019 NSDictionary *pasteboardFilteringOptions = @{
2020 NSPasteboardURLReadingFileURLsOnlyKey : @YES,
2021 NSPasteboardURLReadingContentsConformToTypesKey : [NSImage imageTypes]
2024 NSArray *pasteboardMatches = [pasteboard readObjectsForClasses:@[ [NSURL class] ]
2025 options:pasteboardFilteringOptions];
2027 if (!pasteboardMatches || !pasteboardMatches.count) {
2031 pasteboardImageFile = [[pasteboardMatches firstObject] copy];
2034 return [pasteboardImageFile autorelease];
2040 NSPasteboard *pasteboard = [
NSPasteboard generalPasteboard];
2041 NSArray *supportedTypes = [
NSArray
2042 arrayWithObjects:NSPasteboardTypeFileURL, NSPasteboardTypeTIFF, NSPasteboardTypePNG, nil];
2044 NSPasteboardType availableType = [
pasteboard availableTypeFromArray:supportedTypes];
2046 if (!availableType) {
2051 if ([pasteboard availableTypeFromArray:@[ NSPasteboardTypeFileURL ]] &&
2068 NSPasteboard *pasteboard = [
NSPasteboard generalPasteboard];
2070 NSImage *clipboardImage = nil;
2073 clipboardImage = [[[
NSImage alloc] initWithContentsOfURL:pasteboardImageFile] autorelease];
2077 clipboardImage = [[[
NSImage alloc] initWithPasteboard:pasteboard] autorelease];
2080 if (!clipboardImage) {
2088 const size_t byteCount = clipboardImageSize.width * clipboardImageSize.height * 4;
2089 uint *rgba = (
uint *)malloc(byteCount);
2099 *r_width = clipboardImageSize.width;
2100 *r_height = clipboardImageSize.height;
2112 const size_t rowByteCount = width * 4;
2115 initWithBitmapDataPlanes:nil
2122 colorSpaceName:NSDeviceRGBColorSpace
2123 bytesPerRow:rowByteCount
2127 uint8_t *srcBuffer =
reinterpret_cast<uint8_t *
>(rgba);
2128 uint8_t *dstBuffer =
static_cast<uint8_t *
>([
imageRep bitmapData]);
2130 for (
int y = 0;
y < height;
y++) {
2131 const int dstOff = (height -
y - 1) * rowByteCount;
2132 const int srcOff =
y * rowByteCount;
2133 memcpy(dstBuffer + dstOff, srcBuffer + srcOff, rowByteCount);
2136 NSImage *image = [[[
NSImage alloc] initWithSize:NSMakeSize(width, height)] autorelease];
2137 [
image addRepresentation:imageRep];
2139 NSPasteboard *pasteboard = [
NSPasteboard generalPasteboard];
2144 if (!pasteSuccess) {
2152 const char *message,
2153 const char *help_label,
2154 const char *continue_label,
2159 NSAlert *alert = [[[
NSAlert alloc] init] autorelease];
2160 alert.accessoryView = [[[
NSView alloc] initWithFrame:NSMakeRect(0, 0, 500, 0)] autorelease];
2162 NSString *titleString = [
NSString stringWithCString:title];
2163 NSString *messageString = [
NSString stringWithCString:message];
2164 NSString *continueString = [
NSString stringWithCString:continue_label];
2165 NSString *helpString = [
NSString stringWithCString:help_label];
2168 alert.alertStyle = NSAlertStyleCritical;
2171 alert.alertStyle = NSAlertStyleWarning;
2174 alert.alertStyle = NSAlertStyleInformational;
2177 alert.messageText = titleString;
2178 alert.informativeText = messageString;
2180 [
alert addButtonWithTitle:continueString];
2181 if (link && strlen(link)) {
2182 [
alert addButtonWithTitle:helpString];
2185 const NSModalResponse response = [
alert runModal];
2186 if (response == NSAlertSecondButtonReturn) {
2187 NSString *linkString = [
NSString stringWithCString:link];
void BLI_kdtree_nd_ free(KDTree *tree)
#define GHOST_ASSERT(x, info)
static GHOST_TKey convertKey(int rawCode, unichar recvChar)
static ImBuf * NSImageToImBuf(NSImage *image)
int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
static char g_firstFileBuf[FIRSTFILEBUFLG]
static NSSize getNSImagePixelSize(NSImage *image)
static bool g_hasFirstFile
static GHOST_TButton convertButton(int button)
static NSURL * NSPasteboardGetImageFile()
@ GHOST_kEventWheelAxisVertical
@ GHOST_kEventWheelAxisHorizontal
@ GHOST_kTrackpadEventMagnify
@ GHOST_kTrackpadEventSmartMagnify
@ GHOST_kTrackpadEventRotate
@ GHOST_kTrackpadEventScroll
@ GHOST_kEventWindowClose
@ GHOST_kEventDraggingDropDone
@ GHOST_kEventDraggingExited
@ GHOST_kEventNativeResolutionChange
@ GHOST_kEventDraggingUpdated
@ GHOST_kEventOpenMainFile
@ GHOST_kEventDraggingEntered
@ GHOST_kEventWindowActivate
@ GHOST_kEventWindowUpdate
@ GHOST_kEventWindowDeactivate
@ GHOST_kEventQuitRequest
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
@ GHOST_kTabletModeEraser
@ GHOST_kTabletModeStylus
@ GHOST_kCapabilityKeyboardHyperKey
@ GHOST_kCapabilityPrimaryClipboard
void * GHOST_TDragnDropDataPtr
#define GHOST_CAPABILITY_FLAG_ALL
@ GHOST_kKeyNumpadAsterisk
const void * GHOST_TEventDataPtr
@ GHOST_kModifierKeyLeftControl
@ GHOST_kModifierKeyLeftAlt
@ GHOST_kModifierKeyLeftShift
@ GHOST_kModifierKeyLeftOS
@ GHOST_kDragnDropTypeFilenames
@ GHOST_kDragnDropTypeBitmap
@ GHOST_kDragnDropTypeString
@ GHOST_kButtonMaskButton4
@ GHOST_kButtonMaskButton7
@ GHOST_kButtonMaskButton6
@ GHOST_kButtonMaskButton5
@ GHOST_kButtonMaskMiddle
void IMB_freeImBuf(ImBuf *ibuf)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
BMesh const char void * data
unsigned long long int uint64_t
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
virtual bool getValid() const =0
virtual void wrapPoint(int32_t &x, int32_t &y, int32_t ofs, GHOST_TAxisFlag axis)
bool processEvents(bool waitForEvent) override
uint * getClipboardImage(int *r_width, int *r_height) const override
GHOST_TSuccess disposeContext(GHOST_IContext *context) override
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override
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)
bool m_needDelayedApplicationBecomeActiveEventProcessing
GHOST_TSuccess handleApplicationBecomeActiveEvent()
GHOST_TSuccess hasClipboardImage() const override
GHOST_TSuccess handleMouseEvent(void *eventPtr)
double m_last_warp_timestamp
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpuSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=nullptr) override
void notifyExternalEventProcessed()
GHOST_TSuccess handleKeyEvent(void *eventPtr)
~GHOST_SystemCocoa() override
GHOST_TSuccess init() override
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const override
uint64_t getMilliSeconds() const override
GHOST_TCapabilityFlag getCapabilities() const override
GHOST_TSuccess showMessageBox(const char *title, const char *message, const char *help_label, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options) const override
uint8_t getNumDisplays() const override
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override
bool m_ignoreWindowSizedMessages
GHOST_TSuccess handleTabletEvent(void *eventPtr, short eventType)
bool m_ignoreMomentumScroll
bool handleOpenDocumentRequest(void *filepathStr)
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override
bool m_outsideLoopEventProcessed
char * getClipboard(bool selection) const override
GHOST_TSuccess setMouseCursorPosition(int32_t x, int32_t y)
void putClipboard(const char *buffer, bool selection) const override
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override
GHOST_IWindow * getWindowUnderCursor(int32_t x, int32_t y) override
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpuSettings) override
GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const override
bool m_multitouchGestures
GHOST_TSuccess init() override
GHOST_TimerManager * getTimerManager() const
bool validWindow(GHOST_IWindow *window) override
GHOST_WindowManager * m_windowManager
bool fireTimers(uint64_t time)
bool isDialog() const override
NSScreen * getScreen() const
void clientToScreenIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
void * getOSWindow() const override
GHOST_TabletData & GetCocoaTabletData()
void getClientBounds(GHOST_Rect &bounds) const override
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
void screenToClientIntern(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const
void setNativePixelSize()
void loadCursor(bool visible, GHOST_TStandardCursor cursor) const
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds) const override
void setCursorGrabAccum(int32_t x, int32_t y)
void getCursorGrabInitPos(int32_t &x, int32_t &y) const
GHOST_TAxisFlag getCursorGrabAxis() const
GHOST_TStandardCursor getCursorShape() const override
bool getCursorVisibility() const override
GHOST_TGrabCursorMode getCursorGrabMode() const
GHOST_TSuccess updateDrawingContext()
bool getCursorGrabModeIsWarp() const
void getCursorGrabAccum(int32_t &x, int32_t &y) const
IMG_TEMPLATE SizeVec imageSize(const T &) RET
float length(VecOp< float, D >) RET
GHOST_SystemCocoa * systemCocoa
GHOST_TDrawingContextType context_type
GHOST_GPUDevice preferred_device
void set(GHOST_TModifierKey mask, bool down)
ImBufByteBuffer byte_buffer
void WM_exit(bContext *C, const int exit_code)