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.

28 lines
704B

  1. #include "ui/Tooltip.hpp"
  2. #include "app.hpp"
  3. #include "window.hpp"
  4. namespace rack {
  5. namespace ui {
  6. void Tooltip::step() {
  7. // Wrap size to contents
  8. box.size.x = bndLabelWidth(APP->window->vg, -1, text.c_str()) + 10.0;
  9. box.size.y = bndLabelHeight(APP->window->vg, -1, text.c_str(), INFINITY);
  10. // Position near cursor. This assumes that `this` is added to the root widget.
  11. box.pos = APP->window->mousePos.plus(math::Vec(15, 15));
  12. Widget::step();
  13. }
  14. void Tooltip::draw(const DrawArgs &args) {
  15. bndTooltipBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y);
  16. bndMenuLabel(args.vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str());
  17. Widget::draw(args);
  18. }
  19. } // namespace ui
  20. } // namespace rack