Compare commits

...

4 Commits

4 changed files with 9 additions and 16 deletions

View File

@@ -84,6 +84,7 @@ public:
void SetRunningState(bool isRunning) { m_isRunning = isRunning; }
static Application &Get() { return *s_Instance; }
inline LayerStack &GetLayerStack() { return m_LayerStack; }
private:
bool m_isRunning;

View File

@@ -8,10 +8,7 @@ namespace SakuraVNE {
Layer::Layer(const std::string &name, bool isActive) : m_LayerName(name), m_isActive(isActive) {}
void Layer::QueueTransition(std::unique_ptr<Layer> toLayer) {
// TODO: redo this based on the event video
// basically handle it like the other layer stuff
// put it into a vector and go over the list at the end of the application loop
auto &layerStack = Application::Get().m_LayerStack;
auto &layerStack = Application::Get().GetLayerStack();
LayerCommand command;
command.action = LayerAction::Transition;
@@ -19,12 +16,5 @@ void Layer::QueueTransition(std::unique_ptr<Layer> toLayer) {
command.newLayer = std::move(toLayer);
layerStack.SubmitCommand(std::move(command));
// for (auto &layer : layerStack) {
// if (layer.get() == this) {
// layer = std::move(toLayer);
// return;
// }
// }
}
} // namespace SakuraVNE

View File

@@ -4,6 +4,12 @@
#include <vector>
namespace SakuraVNE {
LayerStack::LayerStack() {
m_LayerStack.reserve(3);
m_CommandQueue.reserve(10);
}
LayerStack::~LayerStack() {
for (auto &layer : m_LayerStack) {
layer->OnDetach();

View File

@@ -16,7 +16,7 @@ struct LayerCommand {
class LayerStack {
public:
LayerStack() = default;
LayerStack();
~LayerStack();
void PushLayer(std::unique_ptr<Layer> layer);
@@ -37,10 +37,6 @@ public:
void SubmitCommand(LayerCommand command);
void ProcessCommands();
#ifdef DEBUG
// this is only used for the tests for now, so it will be taken out of the release build
inline const std::vector<std::unique_ptr<Layer>> &GetLayers() const { return m_LayerStack; }
#endif
private:
std::vector<LayerCommand> m_CommandQueue;
std::vector<std::unique_ptr<Layer>> m_LayerStack;