|
|
@@ -58,6 +58,7 @@ struct Widget { |
|
|
|
|
|
|
|
Vec getAbsolutePos(); |
|
|
|
Rect getChildrenBoundingBox(); |
|
|
|
|
|
|
|
template <class T> |
|
|
|
T *getAncestorOfType() { |
|
|
|
if (!parent) return NULL; |
|
|
@@ -66,6 +67,17 @@ struct Widget { |
|
|
|
return parent->getAncestorOfType<T>(); |
|
|
|
} |
|
|
|
|
|
|
|
template <class T> |
|
|
|
T *getFirstDescendantOfType() { |
|
|
|
for (Widget *child : children) { |
|
|
|
T *c = dynamic_cast<T*>(child); |
|
|
|
if (c) return c; |
|
|
|
c = child->getFirstDescendantOfType<T>(); |
|
|
|
if (c) return c; |
|
|
|
} |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
/** Adds widget to list of children. |
|
|
|
Gives ownership of widget to this widget instance. |
|
|
|
*/ |
|
|
|