Totally refactored UILabel

This commit is contained in:
2023-03-05 23:42:15 -08:00
parent aeb5014a07
commit ee2dc931f2
15 changed files with 463 additions and 194 deletions

View File

@ -115,17 +115,24 @@ namespace Dawn {
return children;
}
/**
* Finds all children, and children of children, recursively that match
* the queried component.
*
* @tparam T Component Type to find.
* @return Array of pointers to matching children components.
*/
template<class T>
std::vector<T*> findChildrenDeep() {
std::vector<Transform*> itemsToCheck = this->transform.children;
std::vector<Transform*> transformsToCheck = this->transform.children;
std::vector<T*> itemsFound;
while(itemsToCheck.size() > 0) {
auto item = itemsToCheck.begin();
vectorAppend(&itemsToCheck, (*item)->children);
auto component = (*item)->item->getComponent<T>();
while(transformsToCheck.size() > 0) {
auto tras = transformsToCheck.begin();
vectorAppend(&transformsToCheck, (*tras)->children);
auto component = (*tras)->item->getComponent<T>();
if(component != nullptr) itemsFound.push_back(component);
itemsToCheck.erase(item);
transformsToCheck.erase(tras);
}
return itemsFound;