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.

53 lines
1.6KB

  1. /*
  2. * ZamAudio plugins For Cardinal
  3. * Copyright (C) 2014-2019 Damien Zammit <damien@zamaudio.com>
  4. * Copyright (C) 2022 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * For a full copy of the GNU General Public License see the LICENSE file.
  17. */
  18. #pragma once
  19. #include "plugin.hpp"
  20. struct ZamAudioModuleWidget : ModuleWidget {
  21. };
  22. template<int size>
  23. struct FundamentalBlackKnob : RoundKnob {
  24. static constexpr const float kSize = size;
  25. static constexpr const float kHalfSize = size * 0.5f;
  26. float scale;
  27. FundamentalBlackKnob() {
  28. if (size <= 22) {
  29. setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/knob-marker-small.svg")));
  30. bg->setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/knob-small.svg")));
  31. } else {
  32. setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/knob-marker.svg")));
  33. bg->setSvg(Svg::load(asset::plugin(pluginInstance, "res/components/knob.svg")));
  34. }
  35. scale = size / sw->box.size.x;
  36. box.size = Vec(size, size);
  37. bg->box.size = Vec(size, size);
  38. }
  39. void draw(const DrawArgs& args) override {
  40. nvgSave(args.vg);
  41. nvgScale(args.vg, scale, scale);
  42. RoundKnob::draw(args);
  43. nvgRestore(args.vg);
  44. }
  45. };