commit 326962475352554024dde6f05f64c6807d8453f5
parent 374c8f14ca034b073d3bc9a2d7205a82e2cbb43c
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sun, 21 Apr 2024 16:54:56 +0200
Merge branch 'oss/osTIrus' into oss/main
# Conflicts:
# source/virusJucePlugin/Leds.cpp
# source/virusJucePlugin/Leds.h
Diffstat:
6 files changed, 105 insertions(+), 9 deletions(-)
diff --git a/doc/changelog.txt b/doc/changelog.txt
@@ -8,8 +8,12 @@ Framework:
OsTIrus:
+- [Imp] Add ability to turn off pulsating logo animation, either click on the logo or
+ toggle it via context menu
+
- [Fix] Delay Time knob is now disabled if not applicable
- [Fix] Invalid bytes embedded in sysex messages
+- [Fix] Some patch parameters might have shown incorrect values after copying a part
Vavra:
diff --git a/source/jucePluginEditorLib/pluginEditorState.h b/source/jucePluginEditorLib/pluginEditorState.h
@@ -83,12 +83,12 @@ namespace jucePluginEditorLib
Processor& m_processor;
pluginLib::ParameterBinding m_parameterBinding;
+ genericUI::Editor* getEditor() const;
+
private:
void loadSkin(const Skin& _skin);
void setGuiScale(int _scale) const;
- genericUI::Editor* getEditor() const;
-
std::unique_ptr<juce::Component> m_editor;
Skin m_currentSkin;
float m_rootScale = 1.0f;
diff --git a/source/virusJucePlugin/Leds.cpp b/source/virusJucePlugin/Leds.cpp
@@ -6,9 +6,11 @@
namespace genericVirusUI
{
+ constexpr const char* const g_logoAnimKey = "logoAnimation";
+
constexpr const char* g_lfoNames[3] = {"Lfo1LedOn", "Lfo2LedOn", "Lfo3LedOn"};
- Leds::Leds(const genericUI::Editor& _editor, VirusProcessor& _processor)
+ Leds::Leds(const genericUI::Editor& _editor, AudioPluginAudioProcessor& _processor) : m_processor(_processor), m_logoAnimationEnabled(_processor.getConfig().getBoolValue(g_logoAnimKey, true))
{
for(size_t i=0; i<m_lfos.size(); ++i)
{
@@ -28,12 +30,16 @@ namespace genericVirusUI
}
}
- if(auto* comp = _editor.findComponentT<juce::Component>("logolight", false))
+ if(auto* logoAnim = _editor.findComponentT<juce::Component>("logolight", false))
{
- m_logo.reset(new jucePluginEditorLib::Led(comp));
+ m_logoAnim = logoAnim;
+
+ m_logoLed.reset(new jucePluginEditorLib::Led(logoAnim));
- m_logo->setSourceCallback([&_processor]
+ m_logoLed->setSourceCallback([this, &_processor]
{
+ if(!m_logoAnimationEnabled)
+ return 0.0f;
auto* d = dynamic_cast<virusLib::Device*>(_processor.getPlugin().getDevice());
if(!d)
@@ -45,6 +51,19 @@ namespace genericVirusUI
return std::pow(1.0f - v, 0.2f);
});
+
+ m_logoClickListener.reset(new LogoMouseListener(*this));
+
+ m_logoAnim->addMouseListener(m_logoClickListener.get(), false);
+ m_logoAnim->setInterceptsMouseClicks(true, true);
+
+ m_logo = _editor.findComponent("logo", false);
+
+ if(m_logo)
+ {
+ m_logo->addMouseListener(m_logoClickListener.get(), false);
+ m_logo->setInterceptsMouseClicks(true, true);
+ }
}
}
@@ -52,5 +71,20 @@ namespace genericVirusUI
{
for (auto& led : m_lfos)
led.reset();
+
+ if(m_logo)
+ m_logo->removeMouseListener(m_logoClickListener.get());
+ if(m_logoAnim)
+ m_logoAnim->removeMouseListener(m_logoClickListener.get());
+
+ m_logoClickListener.reset();
+ }
+
+ void Leds::toggleLogoAnimation()
+ {
+ m_logoAnimationEnabled = !m_logoAnimationEnabled;
+
+ m_processor.getConfig().setValue(g_logoAnimKey, m_logoAnimationEnabled);
+ m_processor.getConfig().saveIfNeeded();
}
}
diff --git a/source/virusJucePlugin/Leds.h b/source/virusJucePlugin/Leds.h
@@ -5,7 +5,14 @@
#include "../../jucePluginEditorLib/led.h"
-class VirusProcessor;
+#include "juce_gui_basics/juce_gui_basics.h"
+
+namespace juce
+{
+ class MouseListener;
+}
+
+class AudioPluginAudioProcessor;
namespace genericUI
{
@@ -17,11 +24,42 @@ namespace genericVirusUI
class Leds
{
public:
- Leds(const genericUI::Editor& _editor, VirusProcessor& _processor);
+ class LogoMouseListener final : public juce::MouseListener
+ {
+ public:
+ LogoMouseListener(Leds& _leds) : m_leds(_leds)
+ {
+ }
+ void mouseDown(const juce::MouseEvent& e) override
+ {
+ if(e.mods.isPopupMenu())
+ return;
+ m_leds.toggleLogoAnimation();
+ }
+
+ private:
+ Leds& m_leds;
+ };
+
+ Leds(const genericUI::Editor& _editor, AudioPluginAudioProcessor& _processor);
~Leds();
+ void toggleLogoAnimation();
+
+ bool supportsLogoAnimation() const { return m_logoLed.get(); }
+ bool isLogoAnimationEnabled() const { return m_logoAnimationEnabled; }
+
private:
+ AudioPluginAudioProcessor& m_processor;
+ bool m_logoAnimationEnabled = true;
+
std::array<std::unique_ptr<jucePluginEditorLib::Led>, 3> m_lfos;
- std::unique_ptr<jucePluginEditorLib::Led> m_logo;
+
+ std::unique_ptr<jucePluginEditorLib::Led> m_logoLed;
+
+ juce::Component* m_logo = nullptr;
+ juce::Component* m_logoAnim = nullptr;
+
+ std::unique_ptr<LogoMouseListener> m_logoClickListener;
};
}
diff --git a/source/virusJucePlugin/VirusEditor.h b/source/virusJucePlugin/VirusEditor.h
@@ -61,6 +61,8 @@ namespace genericVirusUI
genericUI::Button<juce::TextButton>* createJuceComponent(genericUI::Button<juce::TextButton>*, genericUI::UiObject& _object) override;
juce::Component* createJuceComponent(juce::Component*, genericUI::UiObject& _object) override;
+ const auto& getLeds() const { return m_leds; }
+
private:
void onProgramChange(int _part);
void onPlayModeChanged();
diff --git a/source/virusJucePlugin/VirusEditorState.cpp b/source/virusJucePlugin/VirusEditorState.cpp
@@ -35,6 +35,24 @@ void VirusEditorState::initContextMenu(juce::PopupMenu& _menu)
_menu.addSubMenu("Output Gain", gainMenu);
}
+
+ if(const auto* editor = dynamic_cast<genericVirusUI::VirusEditor*>(getEditor()))
+ {
+ const auto& leds = editor->getLeds();
+
+ if(leds && leds->supportsLogoAnimation())
+ {
+ _menu.addItem("Enable Logo Animation", true, leds->isLogoAnimationEnabled(), [this]
+ {
+ const auto* editor = dynamic_cast<genericVirusUI::VirusEditor*>(getEditor());
+ if(editor)
+ {
+ const auto& leds = editor->getLeds();
+ leds->toggleLogoAnimation();
+ }
+ });
+ }
+ }
}
bool VirusEditorState::initAdvancedContextMenu(juce::PopupMenu& _menu, bool _enabled)