Layers and Events
This commit is contained in:
15
include/utils/Layers/Layer.h
Normal file
15
include/utils/Layers/Layer.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "pch.hpp"
|
||||
#include "utils/Events/Event.h"
|
||||
|
||||
class Layer {
|
||||
|
||||
virtual ~Layer() {}
|
||||
|
||||
virtual void onRender() = 0;
|
||||
|
||||
virtual void onAttach() = 0;
|
||||
|
||||
virtual void onDetach() = 0;
|
||||
|
||||
virtual bool onEvent(const Event&) = 0;
|
||||
};
|
||||
31
include/utils/Layers/Layerstack.h
Normal file
31
include/utils/Layers/Layerstack.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "pch.hpp"
|
||||
#include "Layer.h"
|
||||
|
||||
class Layerstack {
|
||||
|
||||
public:
|
||||
Layerstack() {}
|
||||
|
||||
~Layerstack() {
|
||||
while(!lstack.empty()) {
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
||||
void push(Layer* l) { lstack.push_front(l); }
|
||||
|
||||
void pop() {
|
||||
Layer* l = lstack.front();
|
||||
lstack.pop_front();
|
||||
delete l;
|
||||
}
|
||||
|
||||
void renderAll() {
|
||||
for(Layer* l : lstack)
|
||||
l->onRender();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::list<Layer*> lstack;
|
||||
};
|
||||
Reference in New Issue
Block a user