| 128 | |
| 129 | template <class T, typename F> |
| 130 | T* getFirstDescendantOfTypeWithCondition(widget::Widget* w, F f) { |
| 131 | T* t = dynamic_cast<T*>(w); |
| 132 | if (t && f(t)) |
| 133 | return t; |
| 134 | |
| 135 | for (widget::Widget* child : w->children) { |
| 136 | T* foundT = getFirstDescendantOfTypeWithCondition<T>(child, f); |
| 137 | if (foundT) |
| 138 | return foundT; |
| 139 | } |
| 140 | return NULL; |
| 141 | } |
| 142 | |
| 143 | ParamWidget* ModuleWidget::getParam(int paramId) { |
| 144 | return getFirstDescendantOfTypeWithCondition<ParamWidget>(this, [&](ParamWidget* pw) -> bool { |