iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
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#ifdef IGRAPHICS_GL
15#import <libEGL/libEGL.h>
16#import <libGLESv2/angle_gl.h>
17#endif
18
19BEGIN_IPLUG_NAMESPACE
20BEGIN_IGRAPHICS_NAMESPACE
21
22inline CGRect ToCGRect(IGraphics* pGraphics, const IRECT& bounds)
23{
24 float scale = pGraphics->GetDrawScale();
25 float x = floor(bounds.L * scale);
26 float y = floor(bounds.T * scale);
27 float x2 = ceil(bounds.R * scale);
28 float y2 = ceil(bounds.B * scale);
29
30 return CGRectMake(x, y, x2 - x, y2 - y);
31}
32
33inline UIColor* ToUIColor(const IColor& c)
34{
35 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];
36}
37
38inline IColor FromUIColor(const UIColor* c)
39{
40 CGFloat r,g,b,a;
41 [c getRed:&r green:&g blue:&b alpha:&a];
42 return IColor(a * 255., r * 255., g * 255., b * 255.);
43}
44
45END_IGRAPHICS_NAMESPACE
46END_IPLUG_NAMESPACE
47
48using namespace iplug;
49using namespace igraphics;
50
51@interface IGRAPHICS_UITABLEVC : UIViewController<UITableViewDataSource, UITableViewDelegate> // UITableViewController
52{
53 IPopupMenu* mMenu;
54 IGraphicsIOS* mGraphics;
55}
56@property (strong, nonatomic) UITableView* tableView;
57@property (strong, nonatomic) NSMutableArray* items;
58- (id) initWithIPopupMenuAndIGraphics: (IPopupMenu*) pMenu : (IGraphicsIOS*) pGraphics;
59
60@end
61
62@interface IGRAPHICS_VIEW : UIView
63<
64UITextFieldDelegate,
65UIPopoverPresentationControllerDelegate,
66UIGestureRecognizerDelegate,
67UITraitEnvironment,
68UIDocumentPickerDelegate,
69UIColorPickerViewControllerDelegate
70>
71{
72@public
73 IGraphicsIOS* mGraphics;
74 IGRAPHICS_UITABLEVC* mMenuTableController;
75 UINavigationController* mMenuNavigationController;
76 UITextField* mTextField;
77 UIAlertController* mAlertController;
78 int mTextFieldLength;
79 IColorPickerHandlerFunc mColorPickerHandlerFunc;
80 IFileDialogCompletionHandlerFunc mFileDialogFunc;
81 float mPrevX, mPrevY;
82
83#ifdef IGRAPHICS_GL
84 EGLDisplay mEGLDisplay;
85 EGLSurface mEGLSurface;
86 EGLContext mEGLContext;
87#endif
88}
89- (id) initWithIGraphics: (IGraphicsIOS*) pGraphics;
90- (BOOL) isOpaque;
91- (BOOL) acceptsFirstResponder;
92- (BOOL) delaysContentTouches;
93- (void) removeFromSuperview;
94- (IPopupMenu*) createPopupMenu: (IPopupMenu&) menu : (CGRect) bounds;
95- (void) createTextEntry: (int) paramIdx : (const IText&) text : (const char*) str : (int) length : (CGRect) areaRect;
96- (void) endUserInput;
97- (void) showMessageBox: (const char*) str : (const char*) title : (EMsgBoxType) type : (IMsgBoxCompletionHandlerFunc) completionHandler;
98- (void) promptForFile: (NSString*) fileName : (NSString*) path : (EFileAction) action : (NSArray*) contentTypes : (IFileDialogCompletionHandlerFunc) completionHandler;
99- (void) promptForDirectory: (NSString*) path : (IFileDialogCompletionHandlerFunc) completionHandler;
100- (BOOL) promptForColor: (IColor&) color : (const char*) str : (IColorPickerHandlerFunc) func;
101- (void) presentationControllerDidDismiss: (UIPresentationController*) presentationController;
102
103//UIDocumentPickerDelegate,
104- (void) documentPicker:(UIDocumentPickerViewController*) controller didPickDocumentsAtURLs:(NSArray <NSURL *>*)urls;
105- (void) documentPickerWasCancelled:(UIDocumentPickerViewController*) controller;
106
107//UIColorPickerViewControllerDelegate
108- (void) colorPickerViewControllerDidSelectColor:(UIColorPickerViewController*) viewController;
109- (void) colorPickerViewControllerDidFinish:(UIColorPickerViewController*) viewController;
110
111//gestures
112- (void) attachGestureRecognizer: (EGestureType) type;
113- (BOOL) gestureRecognizer:(UIGestureRecognizer*) gestureRecognizer shouldReceiveTouch:(UITouch*)touch;
114- (void) onTapGesture: (UITapGestureRecognizer*) recognizer;
115- (void) onLongPressGesture: (UILongPressGestureRecognizer*) recognizer;
116- (void) onSwipeGesture: (UISwipeGestureRecognizer*) recognizer;
117- (void) onPinchGesture: (UIPinchGestureRecognizer*) recognizer;
118- (void) onRotateGesture: (UIRotationGestureRecognizer*) recognizer;
119
120- (void) getLastTouchLocation: (float&) x : (float&) y;
121
122- (void) traitCollectionDidChange: (UITraitCollection*) previousTraitCollection;
123
124// only used for GLES via ANGLE
125- (void) activateGLContext;
126- (void) deactivateGLContext;
127- (void) swapBuffers;
128@property (nonatomic, strong) CADisplayLink *displayLink;
129
130@end
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
float GetDrawScale() const
Gets the graphics context scaling factor.
Definition: IGraphics.h:1118
IGraphics platform class for IOS.
Definition: IGraphicsIOS.h:25
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,...