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.

52 lines
1.3KB

  1. #include <sstream>
  2. #include <iomanip>
  3. namespace rack_plugin_Alikins {
  4. // From AS DelayPlus.cpp https://github.com/AScustomWorks/AS
  5. struct MsDisplayWidget : TransparentWidget {
  6. float *value;
  7. std::shared_ptr<Font> font;
  8. MsDisplayWidget() {
  9. font = Font::load(assetPlugin(plugin, "res/Segment7Standard.ttf"));
  10. }
  11. void draw(NVGcontext *vg) override {
  12. // Background
  13. // these go to...
  14. NVGcolor backgroundColor = nvgRGB(0x11, 0x11, 0x11);
  15. NVGcolor borderColor = nvgRGB(0xff, 0xff, 0xff);
  16. nvgBeginPath(vg);
  17. nvgRoundedRect(vg, 0.0, 0.0, box.size.x, box.size.y, 3.0);
  18. nvgFillColor(vg, backgroundColor);
  19. nvgFill(vg);
  20. nvgStrokeWidth(vg, 1.0f);
  21. nvgStrokeColor(vg, borderColor);
  22. nvgStroke(vg);
  23. // text
  24. nvgFontSize(vg, 14);
  25. nvgFontFaceId(vg, font->handle);
  26. nvgTextLetterSpacing(vg, 2.5);
  27. std::stringstream to_display;
  28. // to_display << std::setiosflags(std::ios::fixed) << std::right << std::setw(5) << std::setprecision(4) << *value;
  29. to_display << std::setiosflags(std::ios::fixed) << std::left << std::setprecision(4) << *value;
  30. Vec textPos = Vec(1.0f, 19.0f);
  31. NVGcolor textColor = nvgRGB(0x65, 0xf6, 0x78);
  32. nvgFillColor(vg, textColor);
  33. nvgText(vg, textPos.x, textPos.y, to_display.str().c_str(), NULL);
  34. }
  35. };
  36. } // namespace rack_plugin_Alikins