| 27 | } |
| 28 | |
| 29 | void Menu::step() { |
| 30 | Widget::step(); |
| 31 | |
| 32 | // Set positions of children |
| 33 | box.size = math::Vec(0, 0); |
| 34 | for (widget::Widget* child : children) { |
| 35 | if (!child->visible) |
| 36 | continue; |
| 37 | // Increment height, set position of child |
| 38 | child->box.pos = math::Vec(0, box.size.y); |
| 39 | box.size.y += child->box.size.y; |
| 40 | // Increase width based on maximum width of child |
| 41 | if (child->box.size.x > box.size.x) { |
| 42 | box.size.x = child->box.size.x; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | // Set widths of all children to maximum width |
| 47 | for (widget::Widget* child : children) { |
| 48 | child->box.size.x = box.size.x; |
| 49 | } |
| 50 | |
| 51 | // Fit inside parent |
| 52 | assert(parent); |
| 53 | box = box.nudge(parent->box.zeroPos()); |
| 54 | } |
| 55 | |
| 56 | void Menu::draw(const DrawArgs& args) { |
| 57 | bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, cornerFlags); |