| 545 | } |
| 546 | |
| 547 | void Widget::_forcePick(Widget* _widget) |
| 548 | { |
| 549 | if (mWidgetClient != nullptr) |
| 550 | { |
| 551 | mWidgetClient->_forcePick(_widget); |
| 552 | return; |
| 553 | } |
| 554 | |
| 555 | auto iter = std::find(mWidgetChild.begin(), mWidgetChild.end(), _widget); |
| 556 | if (iter == mWidgetChild.end()) |
| 557 | return; |
| 558 | |
| 559 | for (auto& widget : mWidgetChild) |
| 560 | { |
| 561 | if (widget == _widget) |
| 562 | widget->mDepth = -1; |
| 563 | else if (widget->getDepth() == -1) |
| 564 | widget->mDepth = 0; |
| 565 | } |
| 566 | // code below is an optimized way to setDepth for multiple widgets |
| 567 | // without calling slow Windget::_updateChilds multiple times |
| 568 | std::stable_sort( |
| 569 | mWidgetChild.begin(), |
| 570 | mWidgetChild.end(), |
| 571 | [](Widget* lhs, Widget* rhs) { return lhs->getDepth() > rhs->getDepth(); }); |
| 572 | _updateChilds(); |
| 573 | } |
| 574 | |
| 575 | Widget* Widget::findWidget(std::string_view _name) |
| 576 | { |
no test coverage detected