Skip to content

Commit

Permalink
WebViewPluginDemo: Implement AudioProcessorEditor::getControlParamete…
Browse files Browse the repository at this point in the history
…rIndex
  • Loading branch information
szarvas committed Jun 6, 2024
1 parent 3339843 commit 2540c80
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
8 changes: 8 additions & 0 deletions examples/Plugins/WebViewPluginDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ class WebViewPluginAudioProcessorEditor : public AudioProcessorEditor, private
void paint (Graphics&) override;
void resized() override;

int getControlParameterIndex (Component&) override
{
return controlParameterIndexReceiver.getControlParameterIndex();
}

void timerCallback() override
{
static constexpr size_t numFramesBuffered = 5;
Expand Down Expand Up @@ -437,6 +442,8 @@ class WebViewPluginAudioProcessorEditor : public AudioProcessorEditor, private
WebToggleButtonRelay muteToggleRelay { webComponent, "muteToggle" };
WebComboBoxRelay filterTypeComboRelay { webComponent, "filterTypeCombo" };

WebControlParameterIndexReceiver controlParameterIndexReceiver;

SinglePageBrowser webComponent { WebBrowserComponent::Options{}
.withBackend (WebBrowserComponent::Options::Backend::webview2)
.withWinWebView2Options (WebBrowserComponent::Options::WinWebView2{}
Expand All @@ -445,6 +452,7 @@ class WebViewPluginAudioProcessorEditor : public AudioProcessorEditor, private
.withOptionsFrom (cutoffSliderRelay)
.withOptionsFrom (muteToggleRelay)
.withOptionsFrom (filterTypeComboRelay)
.withOptionsFrom (controlParameterIndexReceiver)
.withNativeFunction ("sayHello", [](auto& var, auto complete)
{
complete ("Hello " + var[0].toString());
Expand Down
32 changes: 29 additions & 3 deletions examples/Plugins/WebViewPluginDemoGUI/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ import * as Juce from "juce-framework-frontend";

import "./App.css";

// Custom attributes in React must be in all lower case
const controlParameterIndexAnnotation = "controlparameterindex";

function JuceSlider({ identifier, title }) {
JuceSlider.propTypes = {
identifier: PropTypes.string,
Expand Down Expand Up @@ -94,7 +97,12 @@ function JuceSlider({ identifier, title }) {
}

return (
<Box>
<Box
{...{
[controlParameterIndexAnnotation]:
sliderState.properties.parameterIndex,
}}
>
<Typography sx={{ mt: 1.5 }}>
{properties.name}: {sliderState.getScaledValue()} {properties.label}
</Typography>
Expand Down Expand Up @@ -146,7 +154,12 @@ function JuceCheckbox({ identifier }) {
const cb = <Checkbox checked={value} onChange={handleChange} />;

return (
<Box>
<Box
{...{
[controlParameterIndexAnnotation]:
checkboxState.properties.parameterIndex,
}}
>
<FormGroup>
<FormControlLabel control={cb} label={properties.name} />
</FormGroup>
Expand Down Expand Up @@ -185,7 +198,12 @@ function JuceComboBox({ identifier }) {
});

return (
<Box>
<Box
{...{
[controlParameterIndexAnnotation]:
comboBoxState.properties.parameterIndex,
}}
>
<FormControl fullWidth>
<InputLabel id={identifier}>{properties.name}</InputLabel>
<Select
Expand Down Expand Up @@ -360,6 +378,14 @@ function FreqBandInfo() {
}

function App() {
const controlParameterIndexUpdater = new Juce.ControlParameterIndexUpdater(
controlParameterIndexAnnotation
);

document.addEventListener("mousemove", (event) => {
controlParameterIndexUpdater.handleMouseMove(event);
});

const [open, setOpen] = useState(false);
const [snackbarMessage, setMessage] = useState("No message received yet");

Expand Down

0 comments on commit 2540c80

Please sign in to comment.