#pragma once #include #include #include #include "display/controls.h" #include "display/menus.h" namespace DHE { template class Control { public: std::function notify{[](T) {}}; }; template class Knob : public Control, public rack::RoundKnob { public: explicit Knob(const std::string &size) { static const auto prefix = std::string{"knob-"}; setSVG(P::svg(prefix + size)); shadow->opacity = 0.f; } void onChange(rack::EventChange &e) override { rack::RoundKnob::onChange(e); notify(this->value); } }; template class LargeKnob : public Knob

{ public: LargeKnob() : Knob

("large") {} }; template class MediumKnob : public Knob

{ public: MediumKnob() : Knob

("medium") {} }; template class SmallKnob : public Knob

{ public: SmallKnob() : Knob

("small") {} }; template class TinyKnob : public Knob

{ public: TinyKnob() : Knob

("tiny") {} }; template class Button : public Control, public rack::SVGSwitch, public rack::MomentarySwitch { public: explicit Button(const std::string &name = "button") { addFrame(P::svg(name + "-1")); addFrame(P::svg(name + "-2")); } void onChange(rack::EventChange &e) override { rack::SVGSwitch::onChange(e); notify(this->value > 0.5f); } }; template class ReverseButton : public Button

{ public: ReverseButton() : Button

("button-reversed") {} }; template class Toggle : public Control, public rack::SVGSwitch, public rack::ToggleSwitch { public: explicit Toggle(const std::string &name = "toggle-" + std::to_string(N)) { auto base = name + "-"; for (int position = 1; position <= size; position++) { addFrame(P::svg(base + std::to_string(position))); } } void onChange(rack::EventChange &e) override { rack::SVGSwitch::onChange(e); notify(static_cast(this->value)); } static constexpr auto size = N; }; } // namespace DHE