2025-07-05 13:28:41 +03:30
|
|
|
#include <engine/events/event.hpp>
|
|
|
|
#include <engine/events/keyboard.hpp>
|
|
|
|
#include <engine/events/mouse.hpp>
|
|
|
|
#include <engine/events/window.hpp>
|
|
|
|
#include <engine/layer/layer.hpp>
|
|
|
|
#include <engine/layer/layer_stack.hpp>
|
2021-05-27 10:41:32 +04:30
|
|
|
|
2021-05-23 18:10:11 +04:30
|
|
|
namespace Light {
|
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
LayerStack *LayerStack::s_Context = nullptr;
|
2022-03-07 21:57:00 +03:30
|
|
|
|
|
|
|
Scope<LayerStack> LayerStack::Create()
|
|
|
|
{
|
|
|
|
return MakeScope<LayerStack>(new LayerStack());
|
|
|
|
}
|
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
LayerStack::LayerStack(): m_Layers {}, m_Begin(), m_End()
|
2022-03-07 21:57:00 +03:30
|
|
|
{
|
|
|
|
ASSERT(!s_Context, "An instance of 'LayerStack' already exists, do not construct this class!")
|
|
|
|
s_Context = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerStack::~LayerStack()
|
|
|
|
{
|
2025-07-05 13:28:41 +03:30
|
|
|
for (Layer *layer : m_Layers)
|
2022-03-07 21:57:00 +03:30
|
|
|
delete layer;
|
|
|
|
}
|
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
void LayerStack::AttachLayerImpl(Layer *layer)
|
2022-03-07 21:57:00 +03:30
|
|
|
{
|
|
|
|
// #todo: handle attaching layer inside a for loop
|
|
|
|
m_Layers.push_back(layer);
|
|
|
|
m_Begin = m_Layers.begin();
|
2025-07-05 13:28:41 +03:30
|
|
|
m_End = m_Layers.end();
|
2022-03-07 21:57:00 +03:30
|
|
|
|
|
|
|
LOG(trace, "Attached [{}]", layer->GetName());
|
|
|
|
}
|
|
|
|
|
2025-07-05 13:28:41 +03:30
|
|
|
void LayerStack::DetachLayerImpl(Layer *layer)
|
2022-03-07 21:57:00 +03:30
|
|
|
{
|
|
|
|
// #todo: handle detaching layer inside a for loop
|
|
|
|
m_Layers.erase(std::find(m_Layers.begin(), m_Layers.end(), layer));
|
|
|
|
m_Begin = m_Layers.begin();
|
2025-07-05 13:28:41 +03:30
|
|
|
m_End = m_Layers.end();
|
2022-03-07 21:57:00 +03:30
|
|
|
|
|
|
|
LOG(trace, "Detached [{}]", layer->GetName());
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Light
|