From 6a552eae6f045ff3e87b04bc993a6f751bb3ae53 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Mon, 24 Jun 2019 22:17:08 +0930 Subject: [PATCH] Nudge tooltips to fit within the window --- src/ui/Tooltip.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/Tooltip.cpp b/src/ui/Tooltip.cpp index 7e734875..07f1bdcc 100644 --- a/src/ui/Tooltip.cpp +++ b/src/ui/Tooltip.cpp @@ -1,5 +1,6 @@ #include #include +#include #include @@ -13,6 +14,8 @@ void Tooltip::step() { box.size.y = bndLabelHeight(APP->window->vg, -1, text.c_str(), INFINITY); // Position near cursor. This assumes that `this` is added to the root widget. box.pos = APP->window->mousePos.plus(math::Vec(15, 15)); + // Ensure that it fits within the window. + box = box.nudge(APP->scene->box); Widget::step(); }