iPlug2 - C++ Audio Plug-in Framework
IGraphicsIOS_view.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 #import <UIKit/UIKit.h>
12 #include "IGraphicsIOS.h"
13 
14 BEGIN_IPLUG_NAMESPACE
15 BEGIN_IGRAPHICS_NAMESPACE
16 
17 inline CGRect ToCGRect(IGraphics* pGraphics, const IRECT& bounds)
18 {
19  float scale = pGraphics->GetDrawScale();
20  float x = floor(bounds.L * scale);
21  float y = floor(bounds.T * scale);
22  float x2 = ceil(bounds.R * scale);
23  float y2 = ceil(bounds.B * scale);
24 
25  return CGRectMake(x, y, x2 - x, y2 - y);
26 }
27 
28 inline UIColor* ToUIColor(const IColor& c)
29 {
30  return [UIColor colorWithRed:(double) c.R / 255.0 green:(double) c.G / 255.0 blue:(double) c.B / 255.0 alpha:(double) c.A / 255.0];
31 }
32 
33 inline IColor FromUIColor(const UIColor* c)
34 {
35  CGFloat r,g,b,a;
36  [c getRed:&r green:&g blue:&b alpha:&a];
37  return IColor(a * 255., r * 255., g * 255., b * 255.);
38 }
39 
40 END_IGRAPHICS_NAMESPACE
41 END_IPLUG_NAMESPACE
42 
43 using namespace iplug;
44 using namespace igraphics;
45 
46 @interface IGRAPHICS_UITABLEVC : UIViewController<UITableViewDataSource, UITableViewDelegate> // UITableViewController
47 {
48  IPopupMenu* mMenu;
49  IGraphicsIOS* mGraphics;
50 }
51 @property (strong, nonatomic) UITableView* tableView;
52 @property (strong, nonatomic) NSMutableArray* items;
53 - (id) initWithIPopupMenuAndIGraphics: (IPopupMenu*) pMenu : (IGraphicsIOS*) pGraphics;
54 
55 @end
56 
57 @interface IGRAPHICS_VIEW : UIScrollView <UITextFieldDelegate, UIScrollViewDelegate, UIPopoverPresentationControllerDelegate, UIGestureRecognizerDelegate
58 #ifdef __IPHONE_14_0
59 , UIColorPickerViewControllerDelegate
60 #endif
61 >
62 {
63 @public
64  IGraphicsIOS* mGraphics;
65  IGRAPHICS_UITABLEVC* mMenuTableController;
66  UINavigationController* mMenuNavigationController;
67  UITextField* mTextField;
68  CAMetalLayer* mMTLLayer;
69  int mTextFieldLength;
70  IColorPickerHandlerFunc mColorPickerHandlerFunc;
71  float mPrevX, mPrevY;
72 }
73 - (id) initWithIGraphics: (IGraphicsIOS*) pGraphics;
74 - (BOOL) isOpaque;
75 - (BOOL) acceptsFirstResponder;
76 - (BOOL) delaysContentTouches;
77 - (void) removeFromSuperview;
78 - (IPopupMenu*) createPopupMenu: (IPopupMenu&) menu : (CGRect) bounds;
79 - (void) createTextEntry: (int) paramIdx : (const IText&) text : (const char*) str : (int) length : (CGRect) areaRect;
80 - (void) endUserInput;
81 - (void) showMessageBox: (const char*) str : (const char*) caption : (EMsgBoxType) type : (IMsgBoxCompletionHanderFunc) completionHandler;
82 - (BOOL) promptForColor: (IColor&) color : (const char*) str : (IColorPickerHandlerFunc) func;
83 - (void) presentationControllerDidDismiss: (UIPresentationController*) presentationController;
84 
85 #ifdef __IPHONE_14_0
86 - (void) colorPickerViewControllerDidSelectColor:(UIColorPickerViewController*) viewController;
87 - (void) colorPickerViewControllerDidFinish:(UIColorPickerViewController*) viewController;
88 #endif
89 
90 //gestures
91 - (void) attachGestureRecognizer: (EGestureType) type;
92 -(BOOL) gestureRecognizer:(UIGestureRecognizer*) gestureRecognizer shouldReceiveTouch:(UITouch*)touch;
93 - (void) onTapGesture: (UITapGestureRecognizer*) recognizer;
94 - (void) onLongPressGesture: (UILongPressGestureRecognizer*) recognizer;
95 - (void) onSwipeGesture: (UISwipeGestureRecognizer*) recognizer;
96 - (void) onPinchGesture: (UIPinchGestureRecognizer*) recognizer;
97 - (void) onRotateGesture: (UIRotationGestureRecognizer*) recognizer;
98 
99 - (void) getLastTouchLocation: (float&) x : (float&) y;
100 
101 @property (readonly) CAMetalLayer* metalLayer;
102 @property (nonatomic, strong) CADisplayLink *displayLink;
103 
104 @end
105 
106 #ifdef IGRAPHICS_IMGUI
107 #import <MetalKit/MetalKit.h>
108 
109 @interface IGRAPHICS_IMGUIVIEW : MTKView
110 {
111  IGraphicsIOS_View* mView;
112 }
113 @property (nonatomic, strong) id <MTLCommandQueue> commandQueue;
114 - (id) initWithIGraphicsView: (IGraphicsIOS_View*) pView;
115 @end
116 #endif
Used to manage a rectangular area, independent of draw class/platform.
Used to manage color data, independent of draw class/platform.
float R
Right side of the rectangle (X + W)
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...
float GetDrawScale() const
Gets the graphics context scaling factor.
Definition: IGraphics.h:1064
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
IGraphics platform class for IOS.
Definition: IGraphicsIOS.h:24
float L
Left side of the rectangle (X)
float T
Top of the rectangle (Y)
float B
Bottom of the rectangle (Y + H)