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