iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IGraphicsMac.mm
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#include "IGraphicsMac.h"
12#import "IGraphicsMac_view.h"
13
14#if defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
15#import <libEGL/libEGL.h>
16#endif
17
18#include "IControl.h"
19#include "IPopupMenuControl.h"
20
21#pragma clang diagnostic ignored "-Wdeprecated-declarations"
22
23using namespace iplug;
24using namespace igraphics;
25
26static int GetSystemVersion()
27{
28 static int32_t v;
29 if (!v)
30 {
31 if (NSAppKitVersionNumber >= 1266.0)
32 {
33 if (NSAppKitVersionNumber >= 1404.0)
34 v = 0x10b0;
35 else
36 v = 0x10a0; // 10.10+ Gestalt(gsv) return 0x109x, so we bump this to 0x10a0
37 }
38 else
39 {
40 SInt32 a = 0x1040;
41 Gestalt(gestaltSystemVersion,&a);
42 v=a;
43 }
44 }
45 return v;
46}
47
48StaticStorage<CoreTextFontDescriptor> sFontDescriptorCache;
49
50#pragma mark -
51
52IGraphicsMac::IGraphicsMac(IGEditorDelegate& dlg, int w, int h, int fps, float scale)
53: IGRAPHICS_DRAW_CLASS(dlg, w, h, fps, scale)
54{
55 NSApplicationLoad();
56 StaticStorage<CoreTextFontDescriptor>::Accessor storage(sFontDescriptorCache);
57 storage.Retain();
58}
59
60IGraphicsMac::~IGraphicsMac()
61{
62 StaticStorage<CoreTextFontDescriptor>::Accessor storage(sFontDescriptorCache);
63 storage.Release();
64
65 CloseWindow();
66}
67
68PlatformFontPtr IGraphicsMac::LoadPlatformFont(const char* fontID, const char* fileNameOrResID)
69{
70 return CoreTextHelpers::LoadPlatformFont(fontID, fileNameOrResID, GetBundleID(), GetSharedResourcesSubPath());
71}
72
73PlatformFontPtr IGraphicsMac::LoadPlatformFont(const char* fontID, const char* fontName, ETextStyle style)
74{
75 return CoreTextHelpers::LoadPlatformFont(fontID, fontName, style);
76}
77
78PlatformFontPtr IGraphicsMac::LoadPlatformFont(const char* fontID, void* pData, int dataSize)
79{
80 return CoreTextHelpers::LoadPlatformFont(fontID, pData, dataSize);
81}
82
83void IGraphicsMac::CachePlatformFont(const char* fontID, const PlatformFontPtr& font)
84{
85 CoreTextHelpers::CachePlatformFont(fontID, font, sFontDescriptorCache);
86}
87
88float IGraphicsMac::MeasureText(const IText& text, const char* str, IRECT& bounds) const
89{
90 return IGRAPHICS_DRAW_CLASS::MeasureText(text, str, bounds);
91}
92
93void* IGraphicsMac::OpenWindow(void* pParent)
94{
95 TRACE
96 CloseWindow();
97 IGRAPHICS_VIEW* pView = [[IGRAPHICS_VIEW alloc] initWithIGraphics: this];
98 mView = (void*) pView;
99
100 ActivateGLContext();
101 OnViewInitialized([pView layer]);
102 SetScreenScale([[NSScreen mainScreen] backingScaleFactor]);
103 GetDelegate()->LayoutUI(this);
104 UpdateTooltips();
105 GetDelegate()->OnUIOpen();
106
107 if (pParent)
108 {
109 [(NSView*) pParent addSubview: pView];
110 }
111
112 return mView;
113}
114
115void IGraphicsMac::AttachPlatformView(const IRECT& r, void* pView)
116{
117 NSView* pNewSubView = (NSView*) pView;
118 [pNewSubView setFrame:ToNSRect(this, r)];
119
120 [(IGRAPHICS_VIEW*) mView addSubview:(NSView*) pNewSubView];
121}
122
123void IGraphicsMac::RemovePlatformView(void* pView)
124{
125 [(NSView*) pView removeFromSuperview];
126}
127
128void IGraphicsMac::HidePlatformView(void* pView, bool hide)
129{
130 [(NSView*) pView setHidden:hide];
131}
132
133void IGraphicsMac::CloseWindow()
134{
135 if (mView)
136 {
137 IGRAPHICS_VIEW* pView = (IGRAPHICS_VIEW*) mView;
138
139#if defined IGRAPHICS_GL2 || defined IGRAPHICS_GL3
140 [[pView pixelFormat] release];
141 [[pView openGLContext] release];
142#elif defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
143 [pView deactivateGLContext];
144 eglDestroySurface([pView getEGLDisplay], [pView getEGLSurface]);
145 eglDestroyContext([pView getEGLDisplay], [pView getEGLContext]);
146 eglTerminate([pView getEGLDisplay]);
147#endif
148
149 [pView removeAllToolTips];
150 [pView killTimer];
151 [pView removeFromSuperview];
152 [pView release];
153
154 mView = nullptr;
155 OnViewDestroyed();
156 }
157}
158
159bool IGraphicsMac::WindowIsOpen()
160{
161 return mView;
162}
163
164void IGraphicsMac::PlatformResize(bool parentHasResized)
165{
166 if (mView)
167 {
168 NSSize size = { static_cast<CGFloat>(WindowWidth()), static_cast<CGFloat>(WindowHeight()) };
169
170 [NSAnimationContext beginGrouping]; // Prevent animated resizing
171 [[NSAnimationContext currentContext] setDuration:0.0];
172 [(IGRAPHICS_VIEW*) mView setFrameSize: size ];
173
174 [NSAnimationContext endGrouping];
175 }
176
177 UpdateTooltips();
178}
179
180void IGraphicsMac::PointToScreen(float& x, float& y) const
181{
182 if (mView)
183 {
184 x *= GetDrawScale();
185 y *= GetDrawScale();
186 NSWindow* pWindow = [(IGRAPHICS_VIEW*) mView window];
187 NSPoint wndpt = [(IGRAPHICS_VIEW*) mView convertPoint:NSMakePoint(x, y) toView:nil];
188 NSPoint pt = [pWindow convertRectToScreen: NSMakeRect(wndpt.x, wndpt.y, 0.0, 0.0)].origin;
189
190 x = pt.x;
191 y = pt.y;
192 }
193}
194
195void IGraphicsMac::ScreenToPoint(float& x, float& y) const
196{
197 if (mView)
198 {
199 NSWindow* pWindow = [(IGRAPHICS_VIEW*) mView window];
200 NSPoint wndpt = [pWindow convertRectFromScreen: NSMakeRect(x, y, 0.0, 0.0)].origin;
201 NSPoint pt = [(IGRAPHICS_VIEW*) mView convertPoint:NSMakePoint(wndpt.x, wndpt.y) fromView:nil];
202
203 x = pt.x / GetDrawScale();
204 y = pt.y / GetDrawScale();
205 }
206}
207
208void IGraphicsMac::HideMouseCursor(bool hide, bool lock)
209{
210#if defined AU_API
211 if (!IsXPCAuHost())
212#elif defined AUv3_API
213 if (!IsOOPAuv3AppExtension())
214#endif
215 {
216 if (mCursorHidden == hide)
217 return;
218
219 mCursorHidden = hide;
220
221 if (hide)
222 {
223 StoreCursorPosition();
224 CGDisplayHideCursor(kCGDirectMainDisplay);
225 mCursorLock = lock;
226 }
227 else
228 {
229 DoCursorLock(mCursorX, mCursorY, mCursorX, mCursorY);
230 CGDisplayShowCursor(kCGDirectMainDisplay);
231 mCursorLock = false;
232 }
233 }
234}
235
236void IGraphicsMac::MoveMouseCursor(float x, float y)
237{
238 if (mTabletInput)
239 return;
240
241 PointToScreen(x, y);
242 RepositionCursor(CGPoint{x, y});
243 StoreCursorPosition();
244}
245
246void IGraphicsMac::DoCursorLock(float x, float y, float& prevX, float& prevY)
247{
248 if (mCursorHidden && mCursorLock && !mTabletInput)
249 {
250 RepositionCursor(mCursorLockPosition);
251 prevX = mCursorX;
252 prevY = mCursorY;
253 }
254 else
255 {
256 mCursorX = prevX = x;
257 mCursorY = prevY = y;
258 }
259}
260
261void IGraphicsMac::RepositionCursor(CGPoint point)
262{
263 point = CGPoint{point.x, CGDisplayPixelsHigh(CGMainDisplayID()) - point.y};
264 CGAssociateMouseAndMouseCursorPosition(false);
265 CGDisplayMoveCursorToPoint(CGMainDisplayID(), point);
266 CGAssociateMouseAndMouseCursorPosition(true);
267}
268
269void IGraphicsMac::StoreCursorPosition()
270{
271 // Get position in screen coordinates
272 NSPoint mouse = [NSEvent mouseLocation];
273 mCursorX = mouse.x = std::round(mouse.x);
274 mCursorY = mouse.y = std::round(mouse.y);
275 mCursorLockPosition = CGPoint{mouse.x, mouse.y};
276
277 // Convert to IGraphics coordinates
278 ScreenToPoint(mCursorX, mCursorY);
279}
280
281void IGraphicsMac::GetMouseLocation(float& x, float&y) const
282{
283 // Get position in screen coordinates
284 NSPoint mouse = [NSEvent mouseLocation];
285 x = mouse.x;
286 y = mouse.y;
287
288 // Convert to IGraphics coordinates
289 ScreenToPoint(x, y);
290}
291
292EMsgBoxResult IGraphicsMac::ShowMessageBox(const char* str, const char* title, EMsgBoxType type, IMsgBoxCompletionHandlerFunc completionHandler)
293{
294 ReleaseMouseCapture();
295
296 NSString* messageContent = @(str ? str : "");
297 NSString* alertTitle = @(title ? title : "");
298
299 NSAlert* alert = [[NSAlert alloc] init];
300 [alert setMessageText:alertTitle];
301 [alert setInformativeText:messageContent];
302
303 EMsgBoxResult result = kCANCEL;
304
305 switch (type)
306 {
307 case kMB_OK:
308 [alert addButtonWithTitle:@"OK"];
309 result = kOK;
310 break;
311 case kMB_OKCANCEL:
312 [alert addButtonWithTitle:@"OK"];
313 [alert addButtonWithTitle:@"Cancel"];
314 result = kCANCEL;
315 break;
316 case kMB_YESNO:
317 [alert addButtonWithTitle:@"Yes"];
318 [alert addButtonWithTitle:@"No"];
319 result = kNO;
320 break;
321 case kMB_RETRYCANCEL:
322 [alert addButtonWithTitle:@"Retry"];
323 [alert addButtonWithTitle:@"Cancel"];
324 result = kCANCEL;
325 break;
326 case kMB_YESNOCANCEL:
327 [alert addButtonWithTitle:@"Yes"];
328 [alert addButtonWithTitle:@"No"];
329 [alert addButtonWithTitle:@"Cancel"];
330 result = kCANCEL;
331 break;
332 }
333
334 NSModalResponse response = [alert runModal];
335
336 switch (type)
337 {
338 case kMB_OK:
339 result = kOK;
340 break;
341 case kMB_OKCANCEL:
342 result = (response == NSAlertFirstButtonReturn) ? kOK : kCANCEL;
343 break;
344 case kMB_YESNO:
345 result = (response == NSAlertFirstButtonReturn) ? kYES : kNO;
346 break;
347 case kMB_RETRYCANCEL:
348 result = (response == NSAlertFirstButtonReturn) ? kRETRY : kCANCEL;
349 break;
350 case kMB_YESNOCANCEL:
351 if (response == NSAlertFirstButtonReturn) result = kYES;
352 else if (response == NSAlertSecondButtonReturn) result = kNO;
353 else result = kCANCEL;
354 break;
355 }
356
357 if (completionHandler)
358 {
359 completionHandler(result);
360 }
361
362 [alert release];
363
364 return result;
365}
366
367void IGraphicsMac::ForceEndUserEdit()
368{
369 if (mView)
370 {
371 [(IGRAPHICS_VIEW*) mView endUserInput];
372 }
373}
374
375void IGraphicsMac::UpdateTooltips()
376{
377 if (!(mView && TooltipsEnabled()))
378 return;
379
380 @autoreleasepool {
381
382 [(IGRAPHICS_VIEW*) mView removeAllToolTips];
383
384 if (GetPopupMenuControl() && GetPopupMenuControl()->GetState() > IPopupMenuControl::kCollapsed)
385 {
386 return;
387 }
388
389 auto func = [this](IControl* pControl)
390 {
391 if (pControl->GetTooltip() && !pControl->IsHidden())
392 {
393 IRECT pR = pControl->GetTargetRECT();
394 if (!pR.Empty())
395 {
396 [(IGRAPHICS_VIEW*) mView registerToolTip: pR];
397 }
398 }
399 };
400
401 ForStandardControlsFunc(func);
402
403 }
404}
405
406const char* IGraphicsMac::GetPlatformAPIStr()
407{
408 return "Cocoa";
409}
410
411bool IGraphicsMac::RevealPathInExplorerOrFinder(WDL_String& path, bool select)
412{
413 BOOL success = FALSE;
414
415 @autoreleasepool {
416
417 if(path.GetLength())
418 {
419 NSString* pPath = [NSString stringWithUTF8String:path.Get()];
420
421 if([[NSFileManager defaultManager] fileExistsAtPath : pPath] == YES)
422 {
423 if (select)
424 {
425 NSString* pParentDirectoryPath = [pPath stringByDeletingLastPathComponent];
426
427 if (pParentDirectoryPath)
428 {
429 success = [[NSWorkspace sharedWorkspace] openFile:pParentDirectoryPath];
430
431 if (success)
432 success = [[NSWorkspace sharedWorkspace] selectFile: pPath inFileViewerRootedAtPath:pParentDirectoryPath];
433 }
434 }
435 else {
436 success = [[NSWorkspace sharedWorkspace] openFile:pPath];
437 }
438
439 }
440 }
441
442 }
443 return (bool) success;
444}
445
446void IGraphicsMac::PromptForFile(WDL_String& fileName, WDL_String& path, EFileAction action, const char* ext, IFileDialogCompletionHandlerFunc completionHandler)
447{
448 if (!WindowIsOpen())
449 {
450 fileName.Set("");
451 return;
452 }
453
454 NSString* pDefaultFileName = nil;
455 NSString* pDefaultPath = nil;
456 NSArray* pFileTypes = nil;
457
458 if (fileName.GetLength())
459 pDefaultFileName = [NSString stringWithUTF8String:fileName.Get()];
460 else
461 pDefaultFileName = @"";
462
463 if (path.GetLength())
464 pDefaultPath = [NSString stringWithUTF8String:path.Get()];
465 else
466 pDefaultPath = @"";
467
468 fileName.Set(""); // reset it
469
470 if (CStringHasContents(ext))
471 pFileTypes = [[NSString stringWithUTF8String:ext] componentsSeparatedByString: @" "];
472
473 auto doHandleResponse = [](NSPanel* pPanel, NSModalResponse response, WDL_String& fileName, WDL_String& path, IFileDialogCompletionHandlerFunc completionHandler){
474 if (response == NSOKButton)
475 {
476 NSString* pFullPath = [(NSSavePanel*) pPanel filename] ;
477 fileName.Set([pFullPath UTF8String]);
478
479 NSString* pTruncatedPath = [pFullPath stringByDeletingLastPathComponent];
480
481 if (pTruncatedPath)
482 {
483 path.Set([pTruncatedPath UTF8String]);
484 path.Append("/");
485 }
486 }
487
488 if (completionHandler)
489 completionHandler(fileName, path);
490 };
491
492 NSPanel* pPanel = nullptr;
493
494 if (action == EFileAction::Save)
495 {
496 pPanel = [NSSavePanel savePanel];
497
498 [(NSSavePanel*) pPanel setAllowedFileTypes: pFileTypes];
499 [(NSSavePanel*) pPanel setDirectoryURL: [NSURL fileURLWithPath: pDefaultPath]];
500 [(NSSavePanel*) pPanel setNameFieldStringValue: pDefaultFileName];
501 [(NSSavePanel*) pPanel setAllowsOtherFileTypes: NO];
502 }
503 else
504 {
505 pPanel = [NSOpenPanel openPanel];
506
507 [(NSOpenPanel*) pPanel setAllowedFileTypes: pFileTypes];
508 [(NSOpenPanel*) pPanel setDirectoryURL: [NSURL fileURLWithPath: pDefaultPath]];
509 [(NSOpenPanel*) pPanel setCanChooseFiles:YES];
510 [(NSOpenPanel*) pPanel setCanChooseDirectories:NO];
511 [(NSOpenPanel*) pPanel setResolvesAliases:YES];
512 }
513 [pPanel setFloatingPanel: YES];
514
515 if (completionHandler)
516 {
517 NSWindow* pWindow = [(IGRAPHICS_VIEW*) mView window];
518
519 [(NSSavePanel*) pPanel beginSheetModalForWindow:pWindow completionHandler:^(NSModalResponse response) {
520 WDL_String fileNameAsync, pathAsync;
521 doHandleResponse(pPanel, response, fileNameAsync, pathAsync, completionHandler);
522 }];
523 }
524 else
525 {
526 NSModalResponse response = [(NSSavePanel*) pPanel runModal];
527 doHandleResponse(pPanel, response, fileName, path, nullptr);
528 }
529}
530
531void IGraphicsMac::PromptForDirectory(WDL_String& dir, IFileDialogCompletionHandlerFunc completionHandler)
532{
533 NSString* defaultPath;
534
535 if (dir.GetLength())
536 {
537 defaultPath = [NSString stringWithUTF8String:dir.Get()];
538 }
539 else
540 {
541 defaultPath = [NSString stringWithUTF8String:DEFAULT_PATH];
542 dir.Set(DEFAULT_PATH);
543 }
544
545 NSOpenPanel* panelOpen = [NSOpenPanel openPanel];
546
547 [panelOpen setTitle:@"Choose a Directory"];
548 [panelOpen setCanChooseFiles:NO];
549 [panelOpen setCanChooseDirectories:YES];
550 [panelOpen setResolvesAliases:YES];
551 [panelOpen setCanCreateDirectories:YES];
552 [panelOpen setFloatingPanel: YES];
553 [panelOpen setDirectoryURL: [NSURL fileURLWithPath: defaultPath]];
554
555 auto doHandleResponse = [](NSOpenPanel* pPanel, NSModalResponse response, WDL_String& pathAsync, IFileDialogCompletionHandlerFunc completionHandler){
556 if (response == NSOKButton)
557 {
558 NSString* fullPath = [pPanel filename] ;
559 pathAsync.Set([fullPath UTF8String]);
560 pathAsync.Append("/");
561 }
562 else
563 {
564 pathAsync.Set("");
565 }
566
567 if (completionHandler)
568 {
569 WDL_String fileNameAsync; // not used
570 completionHandler(fileNameAsync, pathAsync);
571 }
572 };
573
574 if (completionHandler)
575 {
576 NSWindow* pWindow = [(IGRAPHICS_VIEW*) mView window];
577
578 [panelOpen beginSheetModalForWindow:pWindow completionHandler:^(NSModalResponse response) {
579 WDL_String pathAsync;
580 doHandleResponse(panelOpen, response, pathAsync, completionHandler);
581 }];
582 }
583 else
584 {
585 NSModalResponse response = [panelOpen runModal];
586 doHandleResponse(panelOpen, response, dir, nullptr);
587 }
588}
589
590bool IGraphicsMac::PromptForColor(IColor& color, const char* str, IColorPickerHandlerFunc func)
591{
592 if (mView)
593 return [(IGRAPHICS_VIEW*) mView promptForColor:color : func];
594
595 return false;
596}
597
598IPopupMenu* IGraphicsMac::CreatePlatformPopupMenu(IPopupMenu& menu, const IRECT bounds, bool& isAsync)
599{
600 isAsync = true;
601
602 dispatch_async(dispatch_get_main_queue(), ^{
603 IPopupMenu* pReturnMenu = nullptr;
604
605 if (mView)
606 {
607 NSRect areaRect = ToNSRect(this, bounds);
608 pReturnMenu = [(IGRAPHICS_VIEW*) mView createPopupMenu: menu: areaRect];
609 }
610
611 if (pReturnMenu && pReturnMenu->GetFunction())
612 pReturnMenu->ExecFunction();
613
614 this->SetControlValueAfterPopupMenu(pReturnMenu);
615 });
616
617 return nullptr;
618}
619
620void IGraphicsMac::CreatePlatformTextEntry(int paramIdx, const IText& text, const IRECT& bounds, int length, const char* str)
621{
622 if (mView)
623 {
624 NSRect areaRect = ToNSRect(this, bounds);
625 [(IGRAPHICS_VIEW*) mView createTextEntry: paramIdx : text: str: length: areaRect];
626 }
627}
628
629ECursor IGraphicsMac::SetMouseCursor(ECursor cursorType)
630{
631 if (mView)
632 [(IGRAPHICS_VIEW*) mView setMouseCursor: cursorType];
633
634 return IGraphics::SetMouseCursor(cursorType);
635}
636
637bool IGraphicsMac::OpenURL(const char* url, const char* msgWindowTitle, const char* confirmMsg, const char* errMsgOnFailure)
638{
639 #pragma REMINDER("Warning and error messages for OpenURL not implemented")
640 NSURL* pNSURL = nullptr;
641 if (strstr(url, "http"))
642 pNSURL = [NSURL URLWithString:[NSString stringWithUTF8String:url]];
643 else
644 pNSURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:url]];
645
646 if (pNSURL)
647 {
648 bool ok = ([[NSWorkspace sharedWorkspace] openURL:pNSURL]);
649 return ok;
650 }
651 return true;
652}
653
654void* IGraphicsMac::GetWindow()
655{
656 if (mView) return mView;
657 else return 0;
658}
659
660// static
661int IGraphicsMac::GetUserOSVersion() // Returns a number like 0x1050 (10.5).
662{
663 return (int) GetSystemVersion();
664}
665
666bool IGraphicsMac::GetTextFromClipboard(WDL_String& str)
667{
668 NSString* pTextOnClipboard = [[NSPasteboard generalPasteboard] stringForType: NSStringPboardType];
669
670 if (pTextOnClipboard == nil)
671 {
672 str.Set("");
673 return false;
674 }
675 else
676 {
677 str.Set([pTextOnClipboard UTF8String]);
678 return true;
679 }
680}
681
682bool IGraphicsMac::SetTextInClipboard(const char* str)
683{
684 NSString* pTextForClipboard = [NSString stringWithUTF8String:str];
685 [[NSPasteboard generalPasteboard] clearContents];
686 return [[NSPasteboard generalPasteboard] setString:pTextForClipboard forType:NSStringPboardType];
687}
688
689bool IGraphicsMac::SetFilePathInClipboard(const char* path)
690{
691 NSPasteboard* pPasteboard = [NSPasteboard generalPasteboard];
692 [pPasteboard clearContents]; // clear pasteboard to take ownership
693 NSURL* pFileURL = [NSURL fileURLWithPath: [NSString stringWithUTF8String:path]];
694 BOOL success = [pPasteboard writeObjects: [NSArray arrayWithObject:pFileURL]];
695 return (bool)success;
696}
697
698bool IGraphicsMac::InitiateExternalFileDragDrop(const char* path, const IRECT& iconBounds)
699{
700 NSPasteboardItem* pasteboardItem = [[NSPasteboardItem alloc] init];
701 NSURL* fileURL = [NSURL fileURLWithPath: [NSString stringWithUTF8String:path]];
702 [pasteboardItem setString:fileURL.absoluteString forType:NSPasteboardTypeFileURL];
703
704 NSDraggingItem* draggingItem = [[NSDraggingItem alloc] initWithPasteboardWriter:pasteboardItem];
705 NSRect draggingFrame = ToNSRect(this, iconBounds);
706 NSImage* iconImage = [[NSWorkspace sharedWorkspace] iconForFile:fileURL.path];
707 [iconImage setSize:NSMakeSize(64, 64)];
708 [draggingItem setDraggingFrame:draggingFrame contents: iconImage];
709
710 IGRAPHICS_VIEW* view = (IGRAPHICS_VIEW*) mView;
711 NSDraggingSession* draggingSession = [view beginDraggingSessionWithItems:@[draggingItem] event:[NSApp currentEvent] source: view];
712 draggingSession.animatesToStartingPositionsOnCancelOrFail = YES;
713 draggingSession.draggingFormation = NSDraggingFormationNone;
714
715 ReleaseMouseCapture();
716
717 return true;
718}
719
720EUIAppearance IGraphicsMac::GetUIAppearance() const
721{
722 if (@available(macOS 10.14, *)) {
723 if(mView)
724 {
725 IGRAPHICS_VIEW* pView = (IGRAPHICS_VIEW*) mView;
726 BOOL isDarkMode = [[[pView effectiveAppearance] name] isEqualToString: (NSAppearanceNameDarkAqua)];
727 return isDarkMode ? EUIAppearance::Dark : EUIAppearance::Light;
728 }
729 }
730
731 return EUIAppearance::Light;
732}
733
734void IGraphicsMac::ActivateGLContext()
735{
736 IGRAPHICS_VIEW* pView = (IGRAPHICS_VIEW*) mView;
737 [pView activateGLContext];
738}
739
740void IGraphicsMac::DeactivateGLContext()
741{
742 IGRAPHICS_VIEW* pView = (IGRAPHICS_VIEW*) mView;
743 [pView deactivateGLContext];
744}
745
746#if defined IGRAPHICS_NANOVG
747 #include "IGraphicsNanoVG.cpp"
748#elif defined IGRAPHICS_SKIA
749 #include "IGraphicsSkia.cpp"
750#else
751 #error Either NO_IGRAPHICS or one and only one choice of graphics library must be defined!
752#endif
This file contains the base IControl implementation, along with some base classes for specific types ...
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
An editor delegate base class that uses IGraphics for the UI.
virtual ECursor SetMouseCursor(ECursor cursorType=ECursor::ARROW)
Sets the mouse cursor to one of ECursor (implementations should return the result of the base impleme...
Definition: IGraphics.h:828
A class for setting the contents of a pop up menu.
Used to manage color data, independent of draw class/platform.
Used to manage a rectangular area, independent of draw class/platform.
bool Empty() const
IText is used to manage font and text/text entry style for a piece of text on the UI,...