+ void push(LayerP layer)
+ {
+ ASSERT(layer && "cannot push null layer");
+ stack.push_front(layer);
+ logInfo(" push: %d", stack.size());
+ layer->pushed(interface);
+ }
+
+ LayerP pop()
+ {
+ bool fixIt = false;
+ if (stack.begin() == stackIt) fixIt = true;
+
+ LayerP popped = stack.front();
+ stack.pop_front();
+ logInfo(" pop: %d", stack.size());
+ popped->popped(interface);
+
+ if (fixIt) stackIt = --stack.begin();
+
+ return popped;
+ }
+
+ LayerP pop(Layer* layer)
+ {
+ bool fixIt = false;
+
+ std::list<LayerP> popped;
+
+ std::list<LayerP>::iterator it;
+ for (it = stack.begin(); it != stack.end(); ++it)
+ {
+ popped.push_back(*it);
+
+ if (it == stackIt) fixIt = true;
+
+ if ((*it).get() == layer)
+ {
+ ++it;
+ stack.erase(stack.begin(), it);
+
+ for (it = popped.begin(); it != popped.end(); ++it)
+ {
+ (*it)->popped(interface);
+ }
+
+ if (fixIt) stackIt = --stack.begin();
+
+ return popped.back();
+ }
+ }
+
+ return LayerP();
+ }
+
+ void clear()
+ {
+ stack.clear();
+ stackIt = stack.begin();
+ logInfo("clear: %d", stack.size());
+ }
+