Files
Archimedes/include/utils/Layers/Layerstack.h
2025-04-08 11:47:24 -05:00

50 lines
977 B
C++

#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) {
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<Layer*> lstack;
};
}
#endif