You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
601B

  1. #pragma once
  2. #include <functional>
  3. #include <events.hpp>
  4. #include <ui.hpp>
  5. namespace DHE {
  6. struct BooleanOption : rack::MenuItem {
  7. template <typename Setter, typename Getter>
  8. BooleanOption(const std::string &name, const Setter &setter,
  9. const Getter &getter)
  10. : set{setter}, is_on{getter} {
  11. text = name;
  12. }
  13. void onAction(rack::EventAction &e) override { set(!is_on()); }
  14. void step() override {
  15. rightText = is_on() ? "✔" : "";
  16. rack::MenuItem::step();
  17. }
  18. const std::function<void(bool)> set;
  19. const std::function<bool()> is_on;
  20. };
  21. } // namespace DHE