iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IGraphicsMac.h
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#pragma once
12
13#include <CoreGraphics/CoreGraphics.h>
14
15#include "IGraphics_select.h"
16#include "IGraphicsCoreText.h"
17
18BEGIN_IPLUG_NAMESPACE
19BEGIN_IGRAPHICS_NAMESPACE
20
23class IGraphicsMac final : public IGRAPHICS_DRAW_CLASS
24{
25public:
26 IGraphicsMac(IGEditorDelegate& dlg, int w, int h, int fps, float scale);
27 virtual ~IGraphicsMac();
28
29 void SetBundleID(const char* bundleID) { mBundleID.Set(bundleID); }
30 void SetAppGroupID(const char* appGroupID) { mAppGroupID.Set(appGroupID); }
31
32 void* OpenWindow(void* pWindow) override;
33 void CloseWindow() override;
34 bool WindowIsOpen() override;
35 void PlatformResize(bool parentHasResized) override;
36 void AttachPlatformView(const IRECT& r, void* pView) override;
37 void RemovePlatformView(void* pView) override;
38 void HidePlatformView(void* pView, bool hide) override;
39
40 void HideMouseCursor(bool hide, bool lock) override;
41 void MoveMouseCursor(float x, float y) override;
42 ECursor SetMouseCursor(ECursor cursorType) override;
43
44 void GetMouseLocation(float& x, float&y) const override;
45
46 void DoCursorLock(float x, float y, float& prevX, float& prevY);
47
48 EMsgBoxResult ShowMessageBox(const char* str, const char* title, EMsgBoxType type, IMsgBoxCompletionHandlerFunc completionHandler) override;
49 void ForceEndUserEdit() override;
50
51 const char* GetPlatformAPIStr() override;
52
53 void UpdateTooltips() override;
54
55 bool RevealPathInExplorerOrFinder(WDL_String& path, bool select) override;
56 void PromptForFile(WDL_String& fileName, WDL_String& path, EFileAction action, const char* ext, IFileDialogCompletionHandlerFunc completionHandler) override;
57 void PromptForDirectory(WDL_String& dir, IFileDialogCompletionHandlerFunc completionHandler) override;
58 bool PromptForColor(IColor& color, const char* str, IColorPickerHandlerFunc func) override;
59
60 bool OpenURL(const char* url, const char* msgWindowTitle, const char* confirmMsg, const char* errMsgOnFailure) override;
61
62 void* GetWindow() override;
63
64 const char* GetBundleID() const override { return mBundleID.Get(); }
65 const char* GetAppGroupID() const override { return mAppGroupID.Get(); }
66 static int GetUserOSVersion();
67
68 bool GetTextFromClipboard(WDL_String& str) override;
69 bool SetTextInClipboard(const char* str) override;
70 bool SetFilePathInClipboard(const char* path) override;
71
72 bool InitiateExternalFileDragDrop(const char* path, const IRECT& iconBounds) override API_AVAILABLE(macos(10.13));
73
74 float MeasureText(const IText& text, const char* str, IRECT& bounds) const override;
75
76 EUIAppearance GetUIAppearance() const override;
77protected:
78
79 IPopupMenu* CreatePlatformPopupMenu(IPopupMenu& menu, const IRECT bounds, bool& isAsync) override;
80 void CreatePlatformTextEntry(int paramIdx, const IText& text, const IRECT& bounds, int length, const char* str) override;
81private:
82 void PointToScreen(float& x, float& y) const;
83 void ScreenToPoint(float& x, float& y) const;
84
85 PlatformFontPtr LoadPlatformFont(const char* fontID, const char* fileNameOrResID) override;
86 PlatformFontPtr LoadPlatformFont(const char* fontID, const char* fontName, ETextStyle style) override;
87 PlatformFontPtr LoadPlatformFont(const char* fontID, void* pData, int dataSize) override;
88 void CachePlatformFont(const char* fontID, const PlatformFontPtr& font) override;
89
90 void RepositionCursor(CGPoint point);
91 void StoreCursorPosition();
92
93 void* mView = nullptr;
94 CGPoint mCursorLockPosition;
95 WDL_String mBundleID, mAppGroupID;
96 friend int GetMouseOver(IGraphicsMac* pGraphics);
97};
98
99END_IGRAPHICS_NAMESPACE
100END_IPLUG_NAMESPACE
Used for choosing a drawing backend.
An editor delegate base class for a SOMETHING that uses IGraphics for it's UI.
IGraphics platform class for macOS.
Definition: IGraphicsMac.h:24
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.
IText is used to manage font and text/text entry style for a piece of text on the UI,...