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.

35 lines
694B

  1. #include "ui/Label.hpp"
  2. namespace rack {
  3. Label::Label() {
  4. box.size.y = BND_WIDGET_HEIGHT;
  5. fontSize = 13;
  6. color = bndGetTheme()->regularTheme.textColor;
  7. }
  8. void Label::draw(NVGcontext *vg) {
  9. // TODO
  10. // Custom font sizes do not work with right or center alignment
  11. float x;
  12. switch (alignment) {
  13. default:
  14. case LEFT_ALIGNMENT: {
  15. x = 0.0;
  16. } break;
  17. case RIGHT_ALIGNMENT: {
  18. x = box.size.x - bndLabelWidth(vg, -1, text.c_str());
  19. } break;
  20. case CENTER_ALIGNMENT: {
  21. x = (box.size.x - bndLabelWidth(vg, -1, text.c_str())) / 2.0;
  22. } break;
  23. }
  24. bndIconLabelValue(vg, x, 0.0, box.size.x, box.size.y, -1, color, BND_LEFT, fontSize, text.c_str(), NULL);
  25. }
  26. } // namespace rack