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.

31 lines
794B

  1. #include "TextDisplay.hpp"
  2. #include "src/Simple.hpp" // for plugin TODO: remove this relative reference
  3. TextDisplay::TextDisplay() :
  4. m_font(rack::Font::load(rack::assetPlugin(plugin, "res/fonts/Sudo.ttf")))
  5. {
  6. }
  7. void TextDisplay::draw(NVGcontext* vg)
  8. {
  9. nvgSave(vg);
  10. nvgFillColor(vg, nvgRGBA(0x30, 0x33, 0x32, 0xFF));
  11. nvgBeginPath(vg);
  12. nvgRoundedRect(vg, 0.f, 0.f, box.size.x, box.size.y, 2.5f);
  13. nvgFill(vg);
  14. nvgFillColor(vg, nvgRGBA(220,220,220,160));
  15. nvgFontSize(vg, m_fontSize);
  16. nvgTextBox(vg, 2.f, box.size.y - (box.size.y - m_fontSize), std::numeric_limits<float>::max(), m_displayedText.c_str(), nullptr);
  17. nvgRestore(vg);
  18. }
  19. void TextDisplay::setText(std::string const& text)
  20. {
  21. m_displayedText = text;
  22. }
  23. void TextDisplay::setFontSize(float const size)
  24. {
  25. m_fontSize = size;
  26. }