From 789342b320400055aa1261f56b85a8908ec35fac Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Sun, 3 Jan 2016 19:13:28 +0000 Subject: [PATCH] Add `SurfaceStack` class untested yet --- src/Surfaces/SurfaceStack.cpp | 31 +++++++++++++++++++++++++++++++ src/Surfaces/SurfaceStack.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/Surfaces/SurfaceStack.cpp create mode 100644 src/Surfaces/SurfaceStack.h diff --git a/src/Surfaces/SurfaceStack.cpp b/src/Surfaces/SurfaceStack.cpp new file mode 100644 index 0000000..47a5329 --- /dev/null +++ b/src/Surfaces/SurfaceStack.cpp @@ -0,0 +1,31 @@ +#include "SurfaceStack.h" + +namespace ofx { +namespace piMapper { + +SurfaceStack::SurfaceStack(){} + +void SurfaceStack::push_back(ofx::piMapper::BaseSurface & s){ + _surfaces.push_back(s); +} + +void SurfaceStack::pop_back(){ + if(_surfaces.size() > 0){ + _surfaces.pop_back(); + } +} + +int SurfaceStack::size(){ + return _surfaces.size(); +} + +void SurfaceStack::erase(int pos){ + _surfaces.erase(_surfaces.begin() + pos); +} + +void SurfaceStack::swap(ofx::piMapper::BaseSurface * a, ofx::piMapper::BaseSurface * b){ + std::swap(a, b); +} + +} // namespace piMapper +} // namespace ofx \ No newline at end of file diff --git a/src/Surfaces/SurfaceStack.h b/src/Surfaces/SurfaceStack.h new file mode 100644 index 0000000..13f45ff --- /dev/null +++ b/src/Surfaces/SurfaceStack.h @@ -0,0 +1,29 @@ +#pragma once + +#include "ofMain.h" +#include "BaseSurface.h" + +namespace ofx { +namespace piMapper { + +// One can imagine this as a layers panel in an image editor +class SurfaceStack { + public: + SurfaceStack(); + + void push_back(BaseSurface & s); + void pop_back(); + void erase(int pos); + void swap(BaseSurface * a, BaseSurface * b); + void draw(); + + int size(); + + BaseSurface * at(int pos); + + private: + vector _surfaces; +}; + +} // namespace piMapper +} // namespace ofx \ No newline at end of file