iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IPlugPlatformView.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#if !__has_feature(objc_arc)
12#error This file must be compiled with Arc. Use -fobjc-arc flag
13#endif
14
15#include "IPlugPlatformView.h"
16#include "IPlugPaths.h"
17
18using namespace iplug;
19
20IPlatformView::IPlatformView(bool opaque)
21: mOpaque(opaque)
22{
23}
24
25IPlatformView::~IPlatformView()
26{
27 RemovePlatformView();
28}
29
30void* IPlatformView::CreatePlatformView(void* pParent, float x, float y, float w, float h, float scale)
31{
32 @autoreleasepool {
33 PLATFORM_VIEW* platformView = [[PLATFORM_VIEW alloc] initWithFrame:MAKERECT(x,y,w,h)];
34 mPlatformView = (__bridge_retained void*) platformView;
35 }
36
37 return mPlatformView;
38}
39
40void IPlatformView::RemovePlatformView()
41{
42 @autoreleasepool {
43 PLATFORM_VIEW* platformView = (__bridge_transfer PLATFORM_VIEW*) mPlatformView;
44 [platformView removeFromSuperview];
45 }
46
47 mPlatformView = nullptr;
48}
49
50void IPlatformView::SetChildViewBounds(float x, float y, float w, float h, float scale)
51{
52 [(__bridge PLATFORM_VIEW*) mPlatformView setFrame: MAKERECT(x, y, w, h) ];
53}
Common paths useful for plug-ins.