Browse Source

Hook more web-ui calls, fix linux build

Signed-off-by: falkTX <falktx@falktx.com>
web-ui
falkTX 1 year ago
parent
commit
2dab68f7ca
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 53 additions and 1 deletions
  1. +2
    -0
      Makefile.plugins.mk
  2. +37
    -1
      distrho/src/DistrhoUI.cpp
  3. +13
    -0
      examples/WebMeters/ExampleUIWebMeters.cpp
  4. +1
    -0
      examples/WebMeters/index.html

+ 2
- 0
Makefile.plugins.mk View File

@@ -244,6 +244,8 @@ DGL_LIBS += -framework WebKit
else ifeq ($(WINDOWS),true)
# DGL_FLAGS += -std=gnu++17
DGL_LIBS += -lole32 -luuid
else
DGL_LIBS += -lrt
endif
DGL_LIB = $(DGL_BUILD_DIR)/libdgl-web.a
HAVE_DGL = true


+ 37
- 1
distrho/src/DistrhoUI.cpp View File

@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -230,14 +230,17 @@ UI::PrivateData::createNextWindow(UI* const ui, uint width, uint height, const b

UI::UI(const uint width, const uint height, const bool automaticallyScaleAndSetAsMinimumSize)
: UIWidget(UI::PrivateData::createNextWindow(this,
// width
#ifdef DISTRHO_UI_DEFAULT_WIDTH
width == 0 ? DISTRHO_UI_DEFAULT_WIDTH :
#endif
width,
// height
#ifdef DISTRHO_UI_DEFAULT_HEIGHT
height == 0 ? DISTRHO_UI_DEFAULT_HEIGHT :
#endif
height,
// adjustForScaleFactor
#ifdef DISTRHO_UI_DEFAULT_WIDTH
width == 0
#else
@@ -271,6 +274,10 @@ UI::UI(const uint width, const uint height, const bool automaticallyScaleAndSetA
"setParameterValue=function(index,value){window.webkit.messageHandlers.external.postMessage('setparam '+index+' '+value)};"
#if DISTRHO_PLUGIN_WANT_STATE
"setState=function(key,value){window.webkit.messageHandlers.external.postMessage('setstate '+key+' '+value)};"
"requestStateFile=function(key){window.webkit.messageHandlers.external.postMessage('reqstatefile '+key)};"
#endif
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
"sendNote=function(channel,note,velocity){window.webkit.messageHandlers.external.postMessage('sendnote '+channel+' '+note+' '+velocity)};"
#endif
);
#endif
@@ -594,6 +601,35 @@ void UI::onMessage(char* const message)
setState(key, value);
return;
}

if (std::strncmp(message, "reqstatefile ", 13) == 0)
{
const char* const key = message + 13;
requestStateFile(key);
return;
}
#endif

#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
if (std::strncmp(message, "sendnote ", 9) == 0)
{
const char* const strchannel = message + 9;
char* strnote = nullptr;
char* strvelocity = nullptr;
char* end = nullptr;

const ulong channel = std::strtoul(strchannel, &strnote, 10);
DISTRHO_SAFE_ASSERT_RETURN(strnote != nullptr && strchannel != strnote,);

const ulong note = std::strtoul(strnote, &strvelocity, 10);
DISTRHO_SAFE_ASSERT_RETURN(strvelocity != nullptr && strchannel != strvelocity,);

const ulong velocity = std::strtoul(strvelocity, &end, 10);
DISTRHO_SAFE_ASSERT_RETURN(end != nullptr && strvelocity != end,);

sendNote(channel, note, started);
return;
}
#endif

d_stderr("UI received unknown message %s", message);


+ 13
- 0
examples/WebMeters/ExampleUIWebMeters.cpp View File

@@ -26,6 +26,19 @@ public:
ExampleUIMeters()
: UI()
{
/*
const double scaleFactor = getScaleFactor();

if (d_isNotEqual(scaleFactor, 1.0))
{
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor);
setSize(DISTRHO_UI_DEFAULT_WIDTH * scaleFactor, DISTRHO_UI_DEFAULT_HEIGHT * scaleFactor);
}
else
{
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT);
}
*/
}

private:


+ 1
- 0
examples/WebMeters/index.html View File

@@ -57,6 +57,7 @@
repaint();
}
function parameterChanged(index, value) {
// console.log("paramChanged", index, value)
switch (index) {
case 0: // color
updateColor(parseInt(Math.round(value)));


Loading…
Cancel
Save