Add a floating value label near the cursor while dragging a knob, giving immediate feedback without altering slider behaviour. Inherit SettableTooltipClient on ToggleButton so setTooltip works consistently with knobs and combos. Introduce a shared layout constants namespace in PluginEditor so every panel, row and control position derives from one spacing system. Add tooltips to all knobs, combos, toggles, and buttons. Add Tab/Shift+Tab tab cycling via keyPressed, with a TooltipWindow for hover hints.
45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <JuceHeader.h>
|
|
#include "../Resources.h"
|
|
|
|
namespace serum
|
|
{
|
|
|
|
// ===========================================================================
|
|
// LED-style toggle (power) button that drives a float parameter (0/1) or an
|
|
// optional callback (used by RAVE).
|
|
//
|
|
// Inherits SettableTooltipClient so setTooltip() works exactly like it does on
|
|
// juce::Button / juce::Slider / juce::ComboBox (juce::Component itself has no
|
|
// tooltip support).
|
|
// ===========================================================================
|
|
class ToggleButton : public juce::Component,
|
|
public juce::SettableTooltipClient
|
|
{
|
|
public:
|
|
explicit ToggleButton (const juce::String& label = {});
|
|
|
|
void attach (juce::AudioProcessorValueTreeState& apvts, const juce::String& paramId);
|
|
void setOnClick (std::function<void (bool)> cb) { onClick = std::move (cb); }
|
|
|
|
void setOnColour (juce::Colour c) { onColour = c; repaint(); }
|
|
void setLabel (const juce::String& lbl) { label = lbl; repaint(); }
|
|
|
|
void setToggleState (bool s);
|
|
bool getToggleState() const noexcept { return state; }
|
|
|
|
void paint (juce::Graphics& g) override;
|
|
void mouseDown (const juce::MouseEvent&) override;
|
|
|
|
private:
|
|
bool state = false;
|
|
juce::String label;
|
|
juce::RangedAudioParameter* param = nullptr;
|
|
std::unique_ptr<juce::ParameterAttachment> attachment;
|
|
std::function<void (bool)> onClick;
|
|
juce::Colour onColour = theme::accent;
|
|
};
|
|
|
|
} // namespace serum
|