diff --git a/Source/Application/AnlApplicationInstance.cpp b/Source/Application/AnlApplicationInstance.cpp index 86c9dd16..731352ae 100644 --- a/Source/Application/AnlApplicationInstance.cpp +++ b/Source/Application/AnlApplicationInstance.cpp @@ -101,8 +101,8 @@ void Application::Instance::initialise(juce::String const& commandLine) mDownloader = std::make_unique(); AppQuitIfInvalidPointer(mDownloader); - mOscZoomDispatcher = std::make_unique(getOscSender()); - AppQuitIfInvalidPointer(mOscZoomDispatcher); + mOscTrackDispatcher = std::make_unique(getOscSender()); + AppQuitIfInvalidPointer(mOscTrackDispatcher); mOscTransportDispatcher = std::make_unique(getOscSender()); AppQuitIfInvalidPointer(mOscTransportDispatcher); @@ -318,7 +318,7 @@ void Application::Instance::shutdown() mOscMouseDispatcher.reset(); mOscTransportDispatcher.reset(); - mOscZoomDispatcher.reset(); + mOscTrackDispatcher.reset(); mDownloader.reset(); mMainMenuModel.reset(); mWindow.reset(); diff --git a/Source/Application/AnlApplicationInstance.h b/Source/Application/AnlApplicationInstance.h index 737c5646..06bd0d85 100644 --- a/Source/Application/AnlApplicationInstance.h +++ b/Source/Application/AnlApplicationInstance.h @@ -109,7 +109,7 @@ namespace Application std::unique_ptr mMainMenuModel; std::unique_ptr mCommandLine; std::unique_ptr mDownloader; - std::unique_ptr mOscZoomDispatcher; + std::unique_ptr mOscTrackDispatcher; std::unique_ptr mOscTransportDispatcher; std::unique_ptr mOscMouseDispatcher; diff --git a/Source/Application/AnlApplicationOsc.cpp b/Source/Application/AnlApplicationOsc.cpp index 33b0dd4f..011b1904 100644 --- a/Source/Application/AnlApplicationOsc.cpp +++ b/Source/Application/AnlApplicationOsc.cpp @@ -342,7 +342,7 @@ Application::Osc::SettingsPanel::~SettingsPanel() setContent("", nullptr); } -Application::Osc::ZoomDispatcher::ZoomDispatcher(Sender& sender) +Application::Osc::TrackDispatcher::TrackDispatcher(Sender& sender) : mSender(sender) , mLayoutNotifier(typeid(*this).name(), Instance::get().getDocumentAccessor(), [this]() { @@ -398,22 +398,77 @@ Application::Osc::ZoomDispatcher::ZoomDispatcher(Sender& sender) } }; + mTrackListener.onAttrChanged = [this](Track::Accessor const& accessor, Track::AttrType attribute) + { + switch(attribute) + { + case Track::AttrType::identifier: + case Track::AttrType::name: + case Track::AttrType::file: + case Track::AttrType::results: + case Track::AttrType::edit: + case Track::AttrType::description: + case Track::AttrType::key: + case Track::AttrType::input: + case Track::AttrType::state: + case Track::AttrType::sampleRate: + case Track::AttrType::height: + case Track::AttrType::colours: + case Track::AttrType::font: + case Track::AttrType::lineWidth: + case Track::AttrType::unit: + case Track::AttrType::labelLayout: + case Track::AttrType::channelsLayout: + case Track::AttrType::showInGroup: + case Track::AttrType::sendViaOsc: + case Track::AttrType::zoomValueMode: + case Track::AttrType::zoomLogScale: + case Track::AttrType::zoomLink: + case Track::AttrType::zoomAcsr: + case Track::AttrType::graphics: + case Track::AttrType::warnings: + case Track::AttrType::processing: + case Track::AttrType::focused: + case Track::AttrType::grid: + case Track::AttrType::hasPluginColourMap: + break; + case Track::AttrType::extraThresholds: + { + juce::OSCMessage message("/" + accessor.getAttr()); + message.addString("thresholds"); + auto const& extraThresholds = accessor.getAttr(); + for(auto const& extraThreshold : extraThresholds) + { + if(extraThreshold.has_value()) + { + message.addFloat32(extraThreshold.value()); + } + } + if(!extraThresholds.empty()) + { + mSender.send(message); + } + break; + }; + } + }; + synchosize(mSender.isConnected()); } -Application::Osc::ZoomDispatcher::~ZoomDispatcher() +Application::Osc::TrackDispatcher::~TrackDispatcher() { mSender.removeChangeListener(this); synchosize(false); } -void Application::Osc::ZoomDispatcher::changeListenerCallback([[maybe_unused]] juce::ChangeBroadcaster* source) +void Application::Osc::TrackDispatcher::changeListenerCallback([[maybe_unused]] juce::ChangeBroadcaster* source) { MiscWeakAssert(source == std::addressof(mSender)); synchosize(mSender.isConnected()); } -void Application::Osc::ZoomDispatcher::synchosize(bool connect) +void Application::Osc::TrackDispatcher::synchosize(bool connect) { auto& documentAcsr = Instance::get().getDocumentAccessor(); for(auto& trackAcsr : documentAcsr.getAcsrs()) @@ -423,6 +478,7 @@ void Application::Osc::ZoomDispatcher::synchosize(bool connect) auto& binZoom = trackAcsr.get().getAcsr(); if(trackConnected) { + trackAcsr.get().addListener(mTrackListener, NotificationType::synchronous); switch(Track::Tools::getFrameType(trackAcsr.get()).value_or(Track::FrameType::label)) { case Track::FrameType::label: @@ -449,6 +505,7 @@ void Application::Osc::ZoomDispatcher::synchosize(bool connect) { valueZoom.removeListener(mZoomListener); binZoom.removeListener(mZoomListener); + trackAcsr.get().removeListener(mTrackListener); } } } diff --git a/Source/Application/AnlApplicationOsc.h b/Source/Application/AnlApplicationOsc.h index bdac7360..622ac201 100644 --- a/Source/Application/AnlApplicationOsc.h +++ b/Source/Application/AnlApplicationOsc.h @@ -102,12 +102,12 @@ namespace Application SettingsContent mContent; }; - class ZoomDispatcher + class TrackDispatcher : public juce::ChangeListener { public: - ZoomDispatcher(Sender& sender); - ~ZoomDispatcher() override; + TrackDispatcher(Sender& sender); + ~TrackDispatcher() override; private: // juce::ChangeListener @@ -117,9 +117,10 @@ namespace Application Sender& mSender; Document::LayoutNotifier mLayoutNotifier; + Track::Accessor::Listener mTrackListener{typeid(*this).name()}; Zoom::Accessor::Listener mZoomListener{typeid(*this).name()}; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ZoomDispatcher) + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TrackDispatcher) }; class TransportDispatcher