MCPcopy Create free account
hub / github.com/DISTRHO/DPF / webViewMessageCallback

Method webViewMessageCallback

distrho/src/DistrhoUI.cpp:243–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241
242#if DISTRHO_UI_USE_WEB_VIEW
243void UI::PrivateData::webViewMessageCallback(void* const arg, char* const msg)
244{
245 UI::PrivateData* const uiData = static_cast<UI::PrivateData*>(arg);
246
247 if (std::strncmp(msg, "setparam ", 9) == 0)
248 {
249 const char* const strindex = msg + 9;
250 char* strvalue = nullptr;
251 const ulong index = std::strtoul(strindex, &strvalue, 10);
252 DISTRHO_SAFE_ASSERT_RETURN(strvalue != nullptr && strindex != strvalue,);
253
254 float value;
255 {
256 const ScopedSafeLocale ssl;
257 value = std::atof(strvalue);
258 }
259 uiData->setParamCallback(index + uiData->parameterOffset, value);
260 return;
261 }
262
263 if (std::strncmp(msg, "editparam ", 10) == 0)
264 {
265 const char* const strindex = msg + 10;
266 char* strvalue = nullptr;
267 const ulong index = std::strtoul(strindex, &strvalue, 10);
268 DISTRHO_SAFE_ASSERT_RETURN(strvalue != nullptr && strindex != strvalue,);
269
270 const bool started = strvalue[0] != '0';
271 uiData->editParamCallback(index + uiData->parameterOffset, started);
272 return;
273 }
274
275 #if DISTRHO_PLUGIN_WANT_STATE
276 if (std::strncmp(msg, "setstate ", 9) == 0)
277 {
278 char* const key = msg + 9;
279 char* const sep = std::strchr(key, ' ');
280 DISTRHO_SAFE_ASSERT_RETURN(sep != nullptr,);
281 *sep = '\0';
282 char* const value = sep + 1;
283
284 uiData->setStateCallback(key, value);
285 return;
286 }
287
288 if (std::strncmp(msg, "reqstatefile ", 13) == 0)
289 {
290 const char* const key = msg + 13;
291 uiData->fileRequestCallback(key);
292 return;
293 }
294 #endif
295
296 #if DISTRHO_PLUGIN_WANT_MIDI_INPUT
297 if (std::strncmp(msg, "sendnote ", 9) == 0)
298 {
299 const char* const strchannel = msg + 9;
300 char* strnote = nullptr;

Callers

nothing calls this directly

Calls 6

d_stderrFunction · 0.85
setParamCallbackMethod · 0.80
editParamCallbackMethod · 0.80
setStateCallbackMethod · 0.45
fileRequestCallbackMethod · 0.45
sendNoteCallbackMethod · 0.45

Tested by

no test coverage detected