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.

37 lines
748B

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