-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f426c5e
commit 5ddee61
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "LayerStack.h" | ||
|
||
LayerStack::LayerStack() | ||
{ | ||
m_LayerInsert = m_Layers.begin(); | ||
} | ||
|
||
LayerStack::~LayerStack() | ||
{ | ||
for(Layer* layer : m_Layers) | ||
delete layer; | ||
} | ||
|
||
void LayerStack::pushLayer(Layer* layer) | ||
{ | ||
m_LayerInsert = m_Layers.emplace(m_LayerInsert, layer); | ||
} | ||
|
||
void LayerStack::popLayer(Layer* layer) | ||
{ | ||
auto iterator = std::find(m_Layers.begin(), m_Layers.end(), layer); | ||
if(iterator != m_Layers.end()) | ||
{ | ||
m_Layers.erase(iterator); | ||
m_LayerInsert--; | ||
} | ||
} | ||
|
||
void LayerStack::pushOverlay(Layer* overlay) | ||
{ | ||
m_Layers.emplace_back(overlay); | ||
} | ||
|
||
void LayerStack::popOverlay(Layer* overlay) | ||
{ | ||
auto iterator = std::find(m_Layers.begin(), m_Layers.end(), overlay); | ||
if(iterator != m_Layers.end()) | ||
{ | ||
m_Layers.erase(iterator); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "Layer.h" | ||
|
||
class LayerStack | ||
{ | ||
public: | ||
LayerStack(); | ||
~LayerStack(); | ||
|
||
void pushLayer(Layer* layer); | ||
void popLayer(Layer* layer); | ||
|
||
void pushOverlay(Layer* layer); | ||
void popOverlay(Layer* layer); | ||
|
||
std::vector<Layer*>::iterator begin() { return m_Layers.begin(); }; | ||
std::vector<Layer*>::iterator end() { return m_Layers.end(); }; | ||
|
||
private: | ||
std::vector<Layer*> m_Layers; | ||
std::vector<Layer*>::iterator m_LayerInsert; | ||
|
||
}; |