+ void pushLayer(LayerP layer)
+ {
+ ASSERT(layer && "cannot push null layer");
+ stack.push_front(layer);
+ layer->pushed(interface);
+ }
+
+ void popLayer()
+ {
+ bool fixIt = false;
+ if (stack.begin() == stackIt) fixIt = true;
+
+ LayerP popped = stack.front();
+ stack.pop_front();
+ popped->popped(interface);
+
+ if (fixIt) stackIt = --stack.begin();
+ }
+
+ void popLayer(Layer* layer)
+ {
+ bool fixIt = false;
+
+ std::list<LayerP>::iterator it;
+ for (it = stack.begin(); it != stack.end(); ++it)
+ {
+ if (it == stackIt) fixIt = true;
+
+ if ((*it).get() == layer)
+ {
+ ++it;
+ do
+ {
+ LayerP popped = stack.front();
+ stack.pop_front();
+ popped->popped(interface);
+ }
+ while (stack.begin() != it);
+
+ if (fixIt) stackIt = --stack.begin();
+ return;
+ }
+ }
+ }
+
+ void clearLayers()
+ {
+ stack.clear();
+ stackIt = stack.begin();
+ }
+
+
+ Engine& interface;
+
+ VideoP video;