You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
#include "MvLayerUpCmd.h"
|
|
|
|
namespace ofx {
|
|
namespace piMapper {
|
|
|
|
MvLayerUpCmd::MvLayerUpCmd(BaseSurface * selectedSurface){
|
|
_selectedSurface = selectedSurface;
|
|
_selectedSurfaceIndex = -1;
|
|
}
|
|
|
|
void MvLayerUpCmd::exec(){
|
|
ofLogNotice("MvLayerUpCmd", "exec");
|
|
|
|
// Find selected surface index in SurfaceStack.
|
|
for(int i = 0; i < SurfaceStack::instance()->size(); ++i){
|
|
if(_selectedSurface == SurfaceStack::instance()->at(i)){
|
|
_selectedSurfaceIndex = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(_selectedSurfaceIndex == -1){
|
|
throw runtime_error("MvLayerUpCmd used with no surface selected");
|
|
}
|
|
|
|
if(_selectedSurfaceIndex == SurfaceStack::instance()->size() - 1){
|
|
throw runtime_error("Check if selected surface is not top before using MvLayerUpCmd");
|
|
}
|
|
|
|
if(SurfaceStack::instance()->size() <= 1){
|
|
throw runtime_error("Check if there is more than one surface before using MvLayerUpCmd");
|
|
}
|
|
|
|
// Swap it with the next surface
|
|
SurfaceStack::instance()->swap(_selectedSurfaceIndex, _selectedSurfaceIndex + 1);
|
|
}
|
|
|
|
void MvLayerUpCmd::undo(){
|
|
ofLogNotice("MvLayerUoCmd", "undo");
|
|
SurfaceStack::instance()->swap(_selectedSurfaceIndex, _selectedSurfaceIndex + 1);
|
|
}
|
|
|
|
} // namespace piMapper
|
|
} // namespace ofx
|
|
|
|
|