QuasarEngine
Cross-platform 3D engine and editor
Loading...
Searching...
No Matches
LayerStack.h
Go to the documentation of this file.
1#pragma once
2
7
8#include <quasar/core/Base.h>
9#include <quasar/core/Layer.h>
10#include <quasar/events/Event.h>
11
12#include <cstddef>
13#include <vector>
14
15namespace Quasar
16{
26 class LayerStack
27 {
28 public:
30 using Iterator = std::vector<Scope<Layer>>::iterator;
31
33 using ConstIterator = std::vector<Scope<Layer>>::const_iterator;
34
35 LayerStack() = default;
36
39
40 LayerStack(const LayerStack&) = delete;
41 LayerStack& operator=(const LayerStack&) = delete;
42 LayerStack(LayerStack&&) = delete;
43 LayerStack& operator=(LayerStack&&) = delete;
44
49
54
59
64
68 void OnEvent(Event& event);
69
71 void Clear();
72
74 std::size_t GetSize() const { return m_Layers.size(); }
75
77 Iterator begin() { return m_Layers.begin(); }
78
80 Iterator end() { return m_Layers.end(); }
81
83 ConstIterator begin() const { return m_Layers.begin(); }
84
86 ConstIterator end() const { return m_Layers.end(); }
87
88 private:
89 std::vector<Scope<Layer>> m_Layers;
90 std::size_t m_OverlayStart = 0;
91 };
92}
Contains the base definitions and utilities for the Quasar engine.
Base class of all events, with their types and categories.
Base class for every part of an application that is updated, rendered and receives events.
Base class of all events.
Definition Event.h:95
Scope< Layer > PopOverlay(Layer &overlay)
Detaches an overlay and removes it from the stack.
Iterator begin()
Returns an iterator to the bottom layer.
Definition LayerStack.h:77
void OnEvent(Event &event)
Sends an event to the layers, from the top to the bottom, until one of them handles it.
Scope< Layer > PopLayer(Layer &layer)
Detaches a regular layer and removes it from the stack.
void Clear()
Detaches every layer, from the top to the bottom, then removes and destroys them all.
std::size_t GetSize() const
Returns the number of layers and overlays in the stack.
Definition LayerStack.h:74
ConstIterator end() const
Returns an iterator past the top layer.
Definition LayerStack.h:86
std::vector< Scope< Layer > >::iterator Iterator
Iterator over the layers, from the bottom to the top.
Definition LayerStack.h:30
Layer & PushOverlay(Scope< Layer > overlay)
Adds an overlay above every layer and overlay, then attaches it.
~LayerStack()
Detaches every layer, from the top to the bottom, then destroys them.
Iterator end()
Returns an iterator past the top layer.
Definition LayerStack.h:80
ConstIterator begin() const
Returns an iterator to the bottom layer.
Definition LayerStack.h:83
Layer & PushLayer(Scope< Layer > layer)
Adds a regular layer above the other regular layers and below every overlay, then attaches it.
std::vector< Scope< Layer > >::const_iterator ConstIterator
Iterator over the layers, from the bottom to the top, without changing them.
Definition LayerStack.h:33
Part of an application that is updated, rendered and receives events.
Definition Layer.h:23
Contains all the engine code.
std::unique_ptr< T > Scope
Pointer with a single owner. Alias of std::unique_ptr.
Definition Base.h:23