From b8f0310e7c45d153a6c3e9add66a5d3ea3f33e47 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 10 Feb 2025 16:33:51 +0000 Subject: [PATCH 1/3] Added additional broadcaster eq event types, BandMoved, QChanged, MouseOver --- .../audio_components/EqComponent.cpp | 32 ++++++++++++++++--- .../scripting/api/ScriptBroadcaster.cpp | 2 +- .../json_dialog/broadcaster/broadcaster.json | 4 +-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/hi_core/hi_components/audio_components/EqComponent.cpp b/hi_core/hi_components/audio_components/EqComponent.cpp index e2c1214b31..7101aaf142 100644 --- a/hi_core/hi_components/audio_components/EqComponent.cpp +++ b/hi_core/hi_components/audio_components/EqComponent.cpp @@ -1015,6 +1015,9 @@ void FilterDragOverlay::FilterDragComponent::mouseDrag(const MouseEvent& e) { CHECK_MIDDLE_MOUSE_DRAG(e); + auto* broadcasterValue = new DynamicObject(); + broadcasterValue->setProperty("Index", index); + if (e.mods.isShiftDown()) { auto deltaNormalised = (float)e.getDistanceFromDragStartY() / (float)getParentComponent()->getHeight(); @@ -1030,6 +1033,9 @@ void FilterDragOverlay::FilterDragComponent::mouseDrag(const MouseEvent& e) parent.setEqAttribute(CurveEq::BandParameter::Q, index, qRange.convertFrom0to1(newValue)); + broadcasterValue->setProperty("Q", qRange.convertFrom0to1(newValue)); + parent.eq->sendBroadcasterMessage("QChanged", broadcasterValue); + return; } else @@ -1073,15 +1079,19 @@ void FilterDragOverlay::FilterDragComponent::mouseDrag(const MouseEvent& e) parent.setEqAttribute(CurveEq::BandParameter::Freq, index, freq); parent.setEqAttribute(CurveEq::BandParameter::Gain, index, gain); -} - - + broadcasterValue->setProperty("Frequency", freq); + broadcasterValue->setProperty("Gain", gain); + parent.eq->sendBroadcasterMessage("BandMoved", broadcasterValue); +} void FilterDragOverlay::FilterDragComponent::mouseWheelMove(const MouseEvent &e, const MouseWheelDetails &d) { if (parent.eq == nullptr) return; + + auto* broadcasterValue = new DynamicObject(); + broadcasterValue->setProperty("Index", index); if (e.mods.isCtrlDown() || parent.isInFloatingTile) { @@ -1099,6 +1109,8 @@ void FilterDragOverlay::FilterDragComponent::mouseWheelMove(const MouseEvent &e, q = jlimit(0.1, 8.0, q * amp); parent.setEqAttribute(CurveEq::BandParameter::Q, index, q); + broadcasterValue->setProperty("Q", q); + parent.eq->sendBroadcasterMessage("QChanged", broadcasterValue); } else { @@ -1106,8 +1118,6 @@ void FilterDragOverlay::FilterDragComponent::mouseWheelMove(const MouseEvent &e, } } - - void FilterDragOverlay::FilterDragComponent::mouseDoubleClick(const MouseEvent& e) { if (parent.eq == nullptr) @@ -1148,12 +1158,24 @@ void FilterDragOverlay::FilterDragComponent::setConstrainer(ComponentBoundsConst void FilterDragOverlay::FilterDragComponent::mouseEnter(const MouseEvent& e) { over = true; + + auto* broadcasterValue = new DynamicObject(); + broadcasterValue->setProperty("Index", index); + broadcasterValue->setProperty("Over", true); + parent.eq->sendBroadcasterMessage("MouseOver", broadcasterValue); + parent.repaint(); } void FilterDragOverlay::FilterDragComponent::mouseExit(const MouseEvent& e) { over = false; + + auto* broadcasterValue = new DynamicObject(); + broadcasterValue->setProperty("Index", index); + broadcasterValue->setProperty("Over", false); + parent.eq->sendBroadcasterMessage("MouseOver", broadcasterValue); + parent.repaint(); } diff --git a/hi_scripting/scripting/api/ScriptBroadcaster.cpp b/hi_scripting/scripting/api/ScriptBroadcaster.cpp index b954449302..602587b6f0 100644 --- a/hi_scripting/scripting/api/ScriptBroadcaster.cpp +++ b/hi_scripting/scripting/api/ScriptBroadcaster.cpp @@ -4375,7 +4375,7 @@ void ScriptBroadcaster::attachToEqEvents(var moduleIds, var events, var optional } StringArray eventTypes; - StringArray legitEventTypes = { "BandAdded", "BandRemoved", "BandSelected", "FFTEnabled" }; + StringArray legitEventTypes = { "BandAdded", "BandRemoved", "BandSelected", "BandMoved", "QChanged", "MouseOver", "FFTEnabled" }; if (events.isString() && events.toString().isNotEmpty()) { diff --git a/tools/json_dialog/broadcaster/broadcaster.json b/tools/json_dialog/broadcaster/broadcaster.json index 033542ff34..c418498dc8 100644 --- a/tools/json_dialog/broadcaster/broadcaster.json +++ b/tools/json_dialog/broadcaster/broadcaster.json @@ -445,8 +445,8 @@ "ID": "eqEventTypes", "EmptyText": "Enter event types (BandAdded, BandRemoved, etc)...", "Required": true, - "Items": "BandAdded\nBandRemoved\nBandSelected\nFFTEnabled", - "Help": "Set the event type that the broadcaster should react too. This can be multiple items from this list:\n\n- `BandAdded`\n- `BandRemoved`\n- `BandSelected`\n- `FFTEnabled`", + "Items": "BandAdded\nBandRemoved\nBandSelected\nBandMoved\nQChanged\nMouseOver\nFFTEnabled", + "Help": "Set the event type that the broadcaster should react too. This can be multiple items from this list:\n\n- `BandAdded`\n- `BandRemoved`\n- `BandSelected`\n- `BandMoved`\n- `QChanged`\n- `MouseOver`\n- `FFTEnabled`", "UseInitValue": "", "Height": 80, "ParseArray": true From 82fa3a1b5da881bdd569d12c96df52c1e733d695 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 10 Feb 2025 16:26:33 +0000 Subject: [PATCH 2/3] Added HandleSize property for draggable filter tile - reduces maximum range of values, needs solving --- .../hi_components/audio_components/EqComponent.cpp | 12 ++++++++++-- hi_core/hi_components/audio_components/EqComponent.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hi_core/hi_components/audio_components/EqComponent.cpp b/hi_core/hi_components/audio_components/EqComponent.cpp index 7101aaf142..0b221fb392 100644 --- a/hi_core/hi_components/audio_components/EqComponent.cpp +++ b/hi_core/hi_components/audio_components/EqComponent.cpp @@ -310,6 +310,7 @@ struct FilterDragOverlay::Panel : public PanelWithProcessorConnection ResetOnDoubleClick, AllowContextMenu, GainRange, + HandleSize, numSpecialProperties }; @@ -331,6 +332,7 @@ struct FilterDragOverlay::Panel : public PanelWithProcessorConnection RETURN_DEFAULT_PROPERTY_ID(index, SpecialProperties::ResetOnDoubleClick, "ResetOnDoubleClick"); RETURN_DEFAULT_PROPERTY_ID(index, SpecialProperties::AllowContextMenu, "AllowContextMenu"); RETURN_DEFAULT_PROPERTY_ID(index, SpecialProperties::GainRange, "GainRange"); + RETURN_DEFAULT_PROPERTY_ID(index, SpecialProperties::HandleSize, "HandleSize"); jassertfalse; return {}; @@ -347,6 +349,7 @@ struct FilterDragOverlay::Panel : public PanelWithProcessorConnection RETURN_DEFAULT_PROPERTY(index, SpecialProperties::ResetOnDoubleClick, var(false)); RETURN_DEFAULT_PROPERTY(index, SpecialProperties::AllowContextMenu, var(true)); RETURN_DEFAULT_PROPERTY(index, SpecialProperties::GainRange, var(24.0)); + RETURN_DEFAULT_PROPERTY(index, SpecialProperties::HandleSize, var(24)); jassertfalse; @@ -364,6 +367,8 @@ struct FilterDragOverlay::Panel : public PanelWithProcessorConnection auto u = (bool)getPropertyWithDefault(object, (int)SpecialProperties::UseUndoManager); auto rd = (bool)getPropertyWithDefault(object, (int)SpecialProperties::ResetOnDoubleClick); + + auto hs = (int)getPropertyWithDefault(object, (int)SpecialProperties::HandleSize); if (u) fd->setUndoManager(getMainController()->getControlUndoManager()); @@ -378,6 +383,7 @@ struct FilterDragOverlay::Panel : public PanelWithProcessorConnection fd->setResetOnDoubleClick(rd); fd->setAllowFilterResizing(r); fd->setSpectrumVisibility((SpectrumVisibility)s); + fd->setHandleSize(hs); } } @@ -395,6 +401,8 @@ struct FilterDragOverlay::Panel : public PanelWithProcessorConnection storePropertyInObject(obj, (int)SpecialProperties::GainRange, fd->gainRange); storePropertyInObject(obj, (int)SpecialProperties::AllowContextMenu, fd->allowContextMenu); + + storePropertyInObject(obj, (int)SpecialProperties::HandleSize, fd->handleSize); } return obj; @@ -564,7 +572,7 @@ void FilterDragOverlay::checkEnabledBands() void FilterDragOverlay::resized() { - constrainer->setMinimumOnscreenAmounts(24, 24, 24, 24); + constrainer->setMinimumOnscreenAmounts(handleSize, handleSize, handleSize, handleSize); fftAnalyser.setBounds(getLocalBounds().reduced(offset)); filterGraph.setBounds(getLocalBounds().reduced(offset)); @@ -668,7 +676,7 @@ void FilterDragOverlay::updatePositions(bool forceUpdate) Rectangle b(point, point); - dragComponents[i]->setBounds(b.withSizeKeepingCentre(24, 24)); + dragComponents[i]->setBounds(b.withSizeKeepingCentre(handleSize, handleSize)); } } diff --git a/hi_core/hi_components/audio_components/EqComponent.h b/hi_core/hi_components/audio_components/EqComponent.h index f4bdfb6e6d..69dfb0e90b 100644 --- a/hi_core/hi_components/audio_components/EqComponent.h +++ b/hi_core/hi_components/audio_components/EqComponent.h @@ -150,6 +150,8 @@ class FilterDragOverlay : public Component, void setResetOnDoubleClick(bool shouldReset) { resetOnDoubleClick = shouldReset; } + void setHandleSize(int newSize) { handleSize = newSize; } + void setAllowContextMenu(bool shouldAllow) { allowContextMenu = shouldAllow; @@ -250,6 +252,7 @@ class FilterDragOverlay : public Component, bool allowContextMenu = true; double gainRange = 24.0; + int handleSize = 24; bool resetOnDoubleClick = false; bool allowFilterResizing = true; From 518f27823ab654b9d2193090ff8a07d72ad325db Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 10 Feb 2025 21:00:32 +0000 Subject: [PATCH 3/3] Include Q with bandmoved broadcaster --- hi_core/hi_components/audio_components/EqComponent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hi_core/hi_components/audio_components/EqComponent.cpp b/hi_core/hi_components/audio_components/EqComponent.cpp index 0b221fb392..da35ec31c8 100644 --- a/hi_core/hi_components/audio_components/EqComponent.cpp +++ b/hi_core/hi_components/audio_components/EqComponent.cpp @@ -1050,6 +1050,7 @@ void FilterDragOverlay::FilterDragComponent::mouseDrag(const MouseEvent& e) { auto pi = parent.eq->getParameterIndex(index, CurveEq::BandParameter::Q); dragQStart = parent.eq->getAttribute(pi); + broadcasterValue->setProperty("Q", dragQStart); } auto te = e.getEventRelativeTo(this);