diff --git a/doomsday/libdeng2/include/de/widgets/widget.h b/doomsday/libdeng2/include/de/widgets/widget.h index 451256fcf2..affb713b07 100644 --- a/doomsday/libdeng2/include/de/widgets/widget.h +++ b/doomsday/libdeng2/include/de/widgets/widget.h @@ -148,10 +148,15 @@ class DENG2_PUBLIC Widget // Utilities. String uniqueName(String const &name) const; - void notifyTree(void (Widget::*notifyFunc)(), - bool (Widget::*conditionFunc)() const = 0, - void (Widget::*preNotifyFunc)() = 0, - void (Widget::*postNotifyFunc)() = 0); + enum NotifyResult { + AbortNotify, + ContinueNotify + }; + NotifyResult notifyTree(void (Widget::*notifyFunc)(), + bool (Widget::*conditionFunc)() const = 0, + void (Widget::*preNotifyFunc)() = 0, + void (Widget::*postNotifyFunc)() = 0, + Widget *until = 0); void notifyTreeReversed(void (Widget::*notifyFunc)(), bool (Widget::*conditionFunc)() const = 0, void (Widget::*preNotifyFunc)() = 0, diff --git a/doomsday/libdeng2/src/widgets/widget.cpp b/doomsday/libdeng2/src/widgets/widget.cpp index c5d67fcd7c..3fc5876cc5 100644 --- a/doomsday/libdeng2/src/widgets/widget.cpp +++ b/doomsday/libdeng2/src/widgets/widget.cpp @@ -275,10 +275,11 @@ String Widget::uniqueName(String const &name) const return String("#%1.%2").arg(id().asInt64()).arg(name); } -void Widget::notifyTree(void (Widget::*notifyFunc)(), - bool (Widget::*conditionFunc)() const, - void (Widget::*preFunc)(), - void (Widget::*postFunc)()) +Widget::NotifyResult Widget::notifyTree(void (Widget::*notifyFunc)(), + bool (Widget::*conditionFunc)() const, + void (Widget::*preFunc)(), + void (Widget::*postFunc)(), + Widget *until) { if(preFunc) { @@ -287,17 +288,28 @@ void Widget::notifyTree(void (Widget::*notifyFunc)(), DENG2_FOR_EACH(Instance::Children, i, d->children) { + if(*i == until) + { + return AbortNotify; + } + if(conditionFunc && !((*i)->*conditionFunc)()) continue; // Skip this one. ((*i)->*notifyFunc)(); - (*i)->notifyTree(notifyFunc, conditionFunc, preFunc, postFunc); + + if((*i)->notifyTree(notifyFunc, conditionFunc, preFunc, postFunc, until) == AbortNotify) + { + return AbortNotify; + } } if(postFunc) { (this->*postFunc)(); } + + return ContinueNotify; } void Widget::notifyTreeReversed(void (Widget::*notifyFunc)(),