From 80eb73f4cb41169c5bf83b5f165667209ee0fa14 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Wed, 3 Feb 2021 11:39:26 +0100 Subject: [PATCH] Also receive CC default value --- editor/src/editor/Editor.cpp | 12 ++++++++++++ editor/src/editor/GUIComponents.cpp | 12 ++++++++++++ editor/src/editor/GUIComponents.h | 1 + 3 files changed, 25 insertions(+) diff --git a/editor/src/editor/Editor.cpp b/editor/src/editor/Editor.cpp index 3390e290..21462e79 100644 --- a/editor/src/editor/Editor.cpp +++ b/editor/src/editor/Editor.cpp @@ -156,6 +156,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener { void updateCCUsed(unsigned cc, bool used); void updateCCValue(unsigned cc, float value); + void updateCCDefaultValue(unsigned cc, float value); void updateCCLabel(unsigned cc, const char* label); // edition of CC by UI @@ -412,6 +413,8 @@ void Editor::Impl::uiReceiveMessage(const char* path, const char* sig, const sfi char pathBuf[256]; sprintf(pathBuf, "/cc%u/value", cc); sendQueuedOSC(pathBuf, "", nullptr); + sprintf(pathBuf, "/cc%u/default", cc); + sendQueuedOSC(pathBuf, "", nullptr); sprintf(pathBuf, "/cc%u/label", cc); sendQueuedOSC(pathBuf, "", nullptr); } @@ -420,6 +423,9 @@ void Editor::Impl::uiReceiveMessage(const char* path, const char* sig, const sfi else if (matchMessage("/cc&/value", path, indices) && !strcmp(sig, "f")) { updateCCValue(indices[0], args[0].f); } + else if (matchMessage("/cc&/default", path, indices) && !strcmp(sig, "f")) { + updateCCDefaultValue(indices[0], args[0].f); + } else if (matchMessage("/cc&/label", path, indices) && !strcmp(sig, "s")) { updateCCLabel(indices[0], args[0].s); } @@ -1203,6 +1209,12 @@ void Editor::Impl::updateCCValue(unsigned cc, float value) panel->setControlValue(cc, value); } +void Editor::Impl::updateCCDefaultValue(unsigned cc, float value) +{ + if (SControlsPanel* panel = controlsPanel_) + panel->setControlDefaultValue(cc, value); +} + void Editor::Impl::updateCCLabel(unsigned cc, const char* label) { if (SControlsPanel* panel = controlsPanel_) diff --git a/editor/src/editor/GUIComponents.cpp b/editor/src/editor/GUIComponents.cpp index 5f7f7e0f..24efe68b 100644 --- a/editor/src/editor/GUIComponents.cpp +++ b/editor/src/editor/GUIComponents.cpp @@ -603,6 +603,18 @@ void SControlsPanel::setControlValue(uint32_t index, float value) slot->knob->setValue(value); } +void SControlsPanel::setControlDefaultValue(uint32_t index, float value) +{ + if (index >= slots_.size()) + return; + + ControlSlot* slot = slots_[index].get(); + if (!slot) + return; + + slot->knob->setDefaultValue(value); +} + void SControlsPanel::setControlLabelText(uint32_t index, UTF8StringPtr text) { if (index >= slots_.size()) diff --git a/editor/src/editor/GUIComponents.h b/editor/src/editor/GUIComponents.h index a5899550..5ba9a6df 100644 --- a/editor/src/editor/GUIComponents.h +++ b/editor/src/editor/GUIComponents.h @@ -223,6 +223,7 @@ public: void setControlUsed(uint32_t index, bool used); void setControlValue(uint32_t index, float value); + void setControlDefaultValue(uint32_t index, float value); void setControlLabelText(uint32_t index, UTF8StringPtr text); std::function ValueChangeFunction;