Files
serumalt/Source/GUI/Knob.h
T
biggy a50666355c feat(gui): add knob value popup, tooltips, tab cycling, and layout system
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.
2026-09-09 13:24:40 +02:00

42 lines
1.3 KiB
C++

#pragma once
#include <JuceHeader.h>
#include <memory>
#include "../Resources.h"
namespace serum
{
// ===========================================================================
// Rotary knob — a juce::Slider styled by SerumLookAndFeel. The value readout is
// formatted by a user-provided function via getTextFromValue().
//
// While the knob is being dragged it also shows a small floating label near the
// mouse cursor with the live (formatted) value, giving immediate feedback
// without changing the slider's normal behaviour.
// ===========================================================================
class Knob : public juce::Slider
{
public:
explicit Knob (const juce::String& name,
std::function<juce::String (float)> formatter = {});
void setFormatter (std::function<juce::String (float)> f) { formatter = std::move (f); }
juce::String getTextFromValue (double value) override;
void mouseDown (const juce::MouseEvent& e) override;
void mouseDrag (const juce::MouseEvent& e) override;
void mouseUp (const juce::MouseEvent& e) override;
void mouseExit (const juce::MouseEvent& e) override;
private:
void showValuePopup (const juce::MouseEvent& e);
void hideValuePopup();
std::function<juce::String (float)> formatter;
std::unique_ptr<juce::Label> valuePopup;
};
} // namespace serum