#ifndef LAYERSTACK_H #define LAYERSTACK_H #include "pch.hpp" #include "Layer.h" namespace Archimedes { class Layerstack { public: Layerstack() {} ~Layerstack() { while(!lstack.empty()) { pop(); } } void push(Layer* l) { if(l) { lstack.push_front(l); l->onAttach(); } } void pop() { Layer* l = lstack.front(); lstack.pop_front(); l->onDetach(); } void renderAll() { for(Layer* l : lstack) l->onRender(); } void sendEvent(const Event& e) { for(Layer* l : lstack) { if(l->onEvent(e)) { break; } } } private: std::list lstack; }; } #endif