Created
March 28, 2021 14:04
-
-
Save mazbox/26d14cd185bb00045cac365bef7b5a62 to your computer and use it in GitHub Desktop.
auv3 resize diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/IPlug/AUv3/IPlugAUAudioUnit.h b/IPlug/AUv3/IPlugAUAudioUnit.h | |
index e9f179623..7678f1547 100644 | |
--- a/IPlug/AUv3/IPlugAUAudioUnit.h | |
+++ b/IPlug/AUv3/IPlugAUAudioUnit.h | |
@@ -29,6 +29,7 @@ | |
- (void) populateChannelCapabilitesArray: (NSMutableArray*) pArray; | |
- (NSInteger) width; | |
- (NSInteger) height; | |
+- (void) hostResized:(CGSize) newSize; | |
- (PLATFORM_VIEW*) openWindow: (PLATFORM_VIEW*) pParent; | |
//- (void)resize: (CGRect) bounds; | |
- (void) closeWindow; | |
diff --git a/IPlug/AUv3/IPlugAUAudioUnit.mm b/IPlug/AUv3/IPlugAUAudioUnit.mm | |
index f31fd36d4..313032220 100644 | |
--- a/IPlug/AUv3/IPlugAUAudioUnit.mm | |
+++ b/IPlug/AUv3/IPlugAUAudioUnit.mm | |
@@ -823,6 +823,9 @@ - (NSInteger)width | |
{ | |
return mPlug->GetEditorWidth(); | |
} | |
+- (void) hostResized:(CGSize) newSize { | |
+ mPlug->OnParentWindowResize(newSize.width, newSize.height); | |
+} | |
- (NSInteger)height | |
{ | |
diff --git a/IPlug/AUv3/IPlugAUViewController.mm b/IPlug/AUv3/IPlugAUViewController.mm | |
index 9477629a9..3c5a8925a 100644 | |
--- a/IPlug/AUv3/IPlugAUViewController.mm | |
+++ b/IPlug/AUv3/IPlugAUViewController.mm | |
@@ -65,6 +65,14 @@ - (void) viewDidLoad | |
[super viewDidLoad]; | |
} | |
+- (void)viewDidLayoutSubviews { | |
+#if PLUG_HOST_RESIZE | |
+ if(self.audioUnit) { | |
+ [self.audioUnit hostResized: self.view.window.frame.size]; | |
+ } | |
+#endif | |
+} | |
+ | |
- (void) viewWillAppear:(BOOL)animated | |
{ | |
[super viewWillAppear:animated]; | |
@@ -91,6 +99,7 @@ - (void) viewDidDisappear:(BOOL)animated | |
[self.audioUnit closeWindow]; | |
} | |
} | |
+ | |
@end | |
#else // macOS | |
diff --git a/IPlug/Extras/WebView/IPlugWebViewEditorDelegate.h b/IPlug/Extras/WebView/IPlugWebViewEditorDelegate.h | |
index e5ccc2ddd..6a4070e55 100644 | |
--- a/IPlug/Extras/WebView/IPlugWebViewEditorDelegate.h | |
+++ b/IPlug/Extras/WebView/IPlugWebViewEditorDelegate.h | |
@@ -48,7 +48,7 @@ public: | |
int sizeOfBase64 = static_cast<int>(4. * std::ceil((static_cast<double>(dataSize)/3.))); | |
base64.Resize(sizeOfBase64); | |
wdl_base64encode(reinterpret_cast<const unsigned char*>(pData), base64.GetFast(), dataSize); | |
- str.SetFormatted(50, "SCMFD(%i, %i, %i, %s)", ctrlTag, msgTag, dataSize, base64.GetFast()); | |
+ str.SetFormatted(sizeOfBase64 + 50, "SCMFD(%i, %i, %i, '%s')", ctrlTag, msgTag, dataSize, base64.GetFast()); | |
EvaluateJavaScript(str.Get()); | |
} | |
@@ -88,9 +88,36 @@ public: | |
} | |
else if (json["msg"] == "SAMFUI") | |
{ | |
- SendArbitraryMsgFromUI(json["msgTag"], json["ctrlTag"], json["dataSize"], /*dataSize > 0 ? json["data"] :*/ nullptr); | |
+ | |
+ int size = 0; | |
+ WDL_TypedBuf<unsigned char> data; | |
+ | |
+ if(json.count("data")>0 && json["data"].is_string()) { | |
+ | |
+ auto dStr = json["data"].get<std::string>(); | |
+ int dSize = dStr.size(); | |
+ | |
+ // calculate the exact size of the decoded b64 data | |
+ int numPaddingBytes = 0; | |
+ | |
+ if(dSize>=2 && dStr[dSize-2]=='=') { | |
+ numPaddingBytes = 2; | |
+ } else if(dSize>=1 && dStr[dSize-1]=='=') { | |
+ numPaddingBytes = 1; | |
+ } | |
+ | |
+ size = (dSize*3)/4 - numPaddingBytes; | |
+ data.Resize(size); | |
+ wdl_base64decode(dStr.c_str(), data.GetFast(), size); | |
+ } | |
+ | |
+ SendArbitraryMsgFromUI(json["msgTag"], json["ctrlTag"], size, data.GetFast()); | |
} | |
} | |
+ void OnParentWindowResize(int width, int height) override | |
+ { | |
+ Resize(width, height); | |
+ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment