1#include <zen/layer/ZEN_LayerList.h>
4 LayerList::~LayerList() {
5 for (
auto &l : m_layers) {
13 void LayerList::pushLayer(
Layer *layer) { pushLayer(std::unique_ptr<Layer>(layer)); }
15 void LayerList::pushOverlay(
Layer *overlay) { pushOverlay(std::unique_ptr<Layer>(overlay)); }
17 void LayerList::pushLayer(std::unique_ptr<Layer> layer) {
18 const int priority = layer->getPriority();
20 auto start = m_layers.begin();
21 auto end = m_layers.begin() + m_layerInsertIndex;
24 std::upper_bound(start, end, priority, [](
int i,
const std::unique_ptr<Layer> &l) {
25 return i < l->getPriority();
27 m_layers.insert(position, std::move(layer));
31 void LayerList::pushOverlay(std::unique_ptr<Layer> overlay) {
32 m_layers.emplace_back(std::move(overlay));
35 void LayerList::popLayer(
Layer *layer) {
40 auto start = m_layers.begin();
41 auto end = m_layers.begin() + m_layerInsertIndex;
43 auto it = std::find_if(start, end, [layer](
const std::unique_ptr<Layer> &l) {
44 return l.get() == layer;
47 if (it != m_layers.begin() + m_layerInsertIndex) {
53 void LayerList::popOverlay(
Layer *overlay) {
57 auto start = m_layers.begin() + m_layerInsertIndex;
58 auto end = m_layers.end();
60 auto it = std::find_if(start, end, [overlay](
const std::unique_ptr<Layer> &l) {
61 return l.get() == overlay;
64 if (it != m_layers.end()) {