iPlug2 - C++ Audio Plug-in Framework
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 
18 BEGIN_IPLUG_NAMESPACE
19 BEGIN_IGRAPHICS_NAMESPACE
20 
23 class IGraphicsMac final : public IGRAPHICS_DRAW_CLASS
24 {
25 public:
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 
31  void* OpenWindow(void* pWindow) override;
32  void CloseWindow() override;
33  bool WindowIsOpen() override;
34  void PlatformResize(bool parentHasResized) override;
35  void AttachPlatformView(const IRECT& r, void* pView) override;
36  void RemovePlatformView(void* pView) override;
37 
38  void HideMouseCursor(bool hide, bool lock) override;
39  void MoveMouseCursor(float x, float y) override;
40  ECursor SetMouseCursor(ECursor cursorType) override;
41 
42  void GetMouseLocation(float& x, float&y) const override;
43 
44  void DoCursorLock(float x, float y, float& prevX, float& prevY);
45 
46  EMsgBoxResult ShowMessageBox(const char* str, const char* caption, EMsgBoxType type, IMsgBoxCompletionHanderFunc completionHandler) override;
47  void ForceEndUserEdit() override;
48 
49  const char* GetPlatformAPIStr() override;
50 
51  void UpdateTooltips() override;
52 
53  bool RevealPathInExplorerOrFinder(WDL_String& path, bool select) override;
54  void PromptForFile(WDL_String& fileName, WDL_String& path, EFileAction action, const char* ext) override;
55  void PromptForDirectory(WDL_String& dir) override;
56  bool PromptForColor(IColor& color, const char* str, IColorPickerHandlerFunc func) override;
57 
58  bool OpenURL(const char* url, const char* msgWindowTitle, const char* confirmMsg, const char* errMsgOnFailure) override;
59 
60  void* GetWindow() override;
61 
62  const char* GetBundleID() override { return mBundleID.Get(); }
63  static int GetUserOSVersion();
64 
65  bool GetTextFromClipboard(WDL_String& str) override;
66  bool SetTextInClipboard(const char* str) override;
67 
68  float MeasureText(const IText& text, const char* str, IRECT& bounds) const override;
69 
70 protected:
71  void CreatePlatformImGui() override;
72 
73  IPopupMenu* CreatePlatformPopupMenu(IPopupMenu& menu, const IRECT& bounds, bool& isAsync) override;
74  void CreatePlatformTextEntry(int paramIdx, const IText& text, const IRECT& bounds, int length, const char* str) override;
75 private:
76  void PointToScreen(float& x, float& y) const;
77  void ScreenToPoint(float& x, float& y) const;
78 
79  PlatformFontPtr LoadPlatformFont(const char* fontID, const char* fileNameOrResID) override;
80  PlatformFontPtr LoadPlatformFont(const char* fontID, const char* fontName, ETextStyle style) override;
81  PlatformFontPtr LoadPlatformFont(const char* fontID, void* pData, int dataSize) override;
82  void CachePlatformFont(const char* fontID, const PlatformFontPtr& font) override;
83 
84  void RepositionCursor(CGPoint point);
85  void StoreCursorPosition();
86 
87  void* mView = nullptr;
88  void* mImGuiView = nullptr;
89  CGPoint mCursorLockPosition;
90  WDL_String mBundleID;
91  friend int GetMouseOver(IGraphicsMac* pGraphics);
92 };
93 
94 END_IGRAPHICS_NAMESPACE
95 END_IPLUG_NAMESPACE
Used to manage a rectangular area, independent of draw class/platform.
Used for choosing a drawing backend.
Used to manage color data, independent of draw class/platform.
IGraphics platform class for macOS.
Definition: IGraphicsMac.h:23
An editor delegate base class for a SOMETHING that uses IGraphics for it&#39;s UI.
A class for setting the contents of a pop up menu.
IText is used to manage font and text/text entry style for a piece of text on the UI...