|
QuasarEngine
Cross-platform 3D engine and editor
|
Owns the layers of an application and keeps them in order, from the bottom to the top. More...
#include <quasar/core/LayerStack.h>
Public Types | |
| using | Iterator = std::vector<Scope<Layer>>::iterator |
| Iterator over the layers, from the bottom to the top. | |
| using | ConstIterator = std::vector<Scope<Layer>>::const_iterator |
| Iterator over the layers, from the bottom to the top, without changing them. | |
Public Member Functions | |
| ~LayerStack () | |
| Detaches every layer, from the top to the bottom, then destroys them. | |
| LayerStack (const LayerStack &)=delete | |
| LayerStack & | operator= (const LayerStack &)=delete |
| LayerStack (LayerStack &&)=delete | |
| LayerStack & | operator= (LayerStack &&)=delete |
| Layer & | PushLayer (Scope< Layer > layer) |
| Adds a regular layer above the other regular layers and below every overlay, then attaches it. | |
| Layer & | PushOverlay (Scope< Layer > overlay) |
| Adds an overlay above every layer and overlay, then attaches it. | |
| Scope< Layer > | PopLayer (Layer &layer) |
| Detaches a regular layer and removes it from the stack. | |
| Scope< Layer > | PopOverlay (Layer &overlay) |
| Detaches an overlay and removes it from the stack. | |
| void | OnEvent (Event &event) |
| Sends an event to the layers, from the top to the bottom, until one of them handles it. | |
| 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. | |
| Iterator | begin () |
| Returns an iterator to the bottom layer. | |
| Iterator | end () |
| Returns an iterator past the top layer. | |
| ConstIterator | begin () const |
| Returns an iterator to the bottom layer. | |
| ConstIterator | end () const |
| Returns an iterator past the top layer. | |
Owns the layers of an application and keeps them in order, from the bottom to the top.
Regular layers, like the game scene, are at the bottom. Overlays, like the editor panels or a debug view, are always above every regular layer, whatever the order they were added in. Each kind keeps its own order: a new layer goes above the other layers, and a new overlay above the other overlays.
Iterating over the stack goes from the bottom to the top, which is the order for updating and rendering. Use std::views::reverse(stack) to go from the top to the bottom, which is the order for events. Do not add or remove layers while iterating.
Adds a regular layer above the other regular layers and below every overlay, then attaches it.
| layer | The layer to add. It must not be empty. |
Adds an overlay above every layer and overlay, then attaches it.
| overlay | The overlay to add. It must not be empty. |
Detaches a regular layer and removes it from the stack.
Detaches an overlay and removes it from the stack.
| void Quasar::LayerStack::OnEvent | ( | Event & | event | ) |
Sends an event to the layers, from the top to the bottom, until one of them handles it.
An event that is already handled is not sent to any layer.