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.

32 lines
785B

  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. // Fit inside parent
  13. assert(parent);
  14. box = box.nudge(parent->box.zeroPos());
  15. Widget::step();
  16. }
  17. void Tooltip::draw(const DrawArgs& args) {
  18. bndTooltipBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y);
  19. bndMenuLabel(args.vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str());
  20. Widget::draw(args);
  21. }
  22. } // namespace ui
  23. } // namespace rack