Browse Source

Make Tooltip fit inside parent.

tags/v1.1.0
Andrew Belt 5 years ago
parent
commit
4f2a21e325
3 changed files with 8 additions and 5 deletions
  1. +4
    -0
      src/ui/Menu.cpp
  2. +0
    -5
      src/ui/MenuOverlay.cpp
  3. +4
    -0
      src/ui/Tooltip.cpp

+ 4
- 0
src/ui/Menu.cpp View File

@@ -46,6 +46,10 @@ void Menu::step() {
for (widget::Widget *child : children) { for (widget::Widget *child : children) {
child->box.size.x = box.size.x; child->box.size.x = box.size.x;
} }

// Fit inside parent
assert(parent);
box = box.nudge(parent->box.zeroPos());
} }


void Menu::draw(const DrawArgs &args) { void Menu::draw(const DrawArgs &args) {


+ 0
- 5
src/ui/MenuOverlay.cpp View File

@@ -9,11 +9,6 @@ void MenuOverlay::step() {
// Adopt parent's size // Adopt parent's size
box.size = parent->box.size; box.size = parent->box.size;


// Fit all children in the box
for (widget::Widget *child : children) {
child->box = child->box.nudge(box.zeroPos());
}

Widget::step(); Widget::step();
} }




+ 4
- 0
src/ui/Tooltip.cpp View File

@@ -13,6 +13,10 @@ void Tooltip::step() {
box.size.y = bndLabelHeight(APP->window->vg, -1, text.c_str(), INFINITY); 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. // Position near cursor. This assumes that `this` is added to the root widget.
box.pos = APP->window->mousePos.plus(math::Vec(15, 15)); box.pos = APP->window->mousePos.plus(math::Vec(15, 15));
// Fit inside parent
assert(parent);
box = box.nudge(parent->box.zeroPos());

Widget::step(); Widget::step();
} }




Loading…
Cancel
Save