From ce81e9e15daed2376cc31fc64ee20f45a438dd25 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Mon, 23 Jan 2017 16:16:29 +0100 Subject: [PATCH] Add moveLayerUp and ..Down methods to ofxPiMapper --- src/Application/Application.cpp | 29 +++++++++++++++++++ src/Application/Application.h | 4 +++ .../Modes/ProjectionMappingMode.cpp | 27 ++--------------- src/Application/Modes/ProjectionMappingMode.h | 2 -- src/ofxPiMapper.cpp | 8 +++++ src/ofxPiMapper.h | 2 ++ 6 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index cb2710a..41f8414 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -316,5 +316,34 @@ void Application::setSourceMode(){ this, SourceSelectionMode::instance())); } +void Application::moveLayerUp(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + if(getSurfaceManager()->getSelectedSurface() == + getSurfaceManager()->getActivePreset()->at( + getSurfaceManager()->getActivePreset()->size() - 1)){ + return; + } + + getCmdManager()->exec( + new MvLayerUpCmd( + getSurfaceManager()->getActivePreset(), + getSurfaceManager()->getSelectedSurface())); + } +} + +void Application::moveLayerDown(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + if(getSurfaceManager()->getSelectedSurface() == + getSurfaceManager()->getActivePreset()->at(0)){ + return; + } + + getCmdManager()->exec( + new MvLayerDnCmd( + getSurfaceManager()->getActivePreset(), + getSurfaceManager()->getSelectedSurface())); + } +} + } // namespace piMapper } // namespace ofx diff --git a/src/Application/Application.h b/src/Application/Application.h index f121947..5662c56 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -7,6 +7,8 @@ #include "SetPresetCmd.h" #include "AddSurfaceCmd.h" #include "RmSurfaceCmd.h" +#include "MvLayerUpCmd.h" +#include "MvLayerDnCmd.h" #include "ApplicationBaseMode.h" #include "PresentationMode.h" #include "ProjectionMappingMode.h" @@ -73,6 +75,8 @@ class Application : public KeyListener { void setTextureMode(); void setProjectionMode(); void setSourceMode(); + void moveLayerUp(); + void moveLayerDown(); void setPreset(unsigned int i); void setNextPreset(); diff --git a/src/Application/Modes/ProjectionMappingMode.cpp b/src/Application/Modes/ProjectionMappingMode.cpp index 0a34324..01ef353 100644 --- a/src/Application/Modes/ProjectionMappingMode.cpp +++ b/src/Application/Modes/ProjectionMappingMode.cpp @@ -230,34 +230,11 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg break; case '0': // Move selected surface up the layer stack - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - if(app->getSurfaceManager()->getSelectedSurface() == - app->getSurfaceManager()->getActivePreset()->at( - app->getSurfaceManager()->getActivePreset()->size() - 1)){ - return; - } - - app->getCmdManager()->exec( - new MvLayerUpCmd( - app->getSurfaceManager()->getActivePreset(), - app->getSurfaceManager()->getSelectedSurface()) - ); - } + app->moveLayerUp(); break; case '9': // Move selected surface down the layer stack - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - if(app->getSurfaceManager()->getSelectedSurface() == - app->getSurfaceManager()->getActivePreset()->at(0)){ - return; - } - - app->getCmdManager()->exec( - new MvLayerDnCmd( - app->getSurfaceManager()->getActivePreset(), - app->getSurfaceManager()->getSelectedSurface()) - ); - } + app->moveLayerDown(); break; case '+': // Scale surface up diff --git a/src/Application/Modes/ProjectionMappingMode.h b/src/Application/Modes/ProjectionMappingMode.h index 2ca4214..c71ed72 100644 --- a/src/Application/Modes/ProjectionMappingMode.h +++ b/src/Application/Modes/ProjectionMappingMode.h @@ -23,8 +23,6 @@ #include "SetNextSourceCmd.h" #include "DuplicateSurfaceCmd.h" #include "ToggleAnimatedSourceCmd.h" -#include "MvLayerUpCmd.h" -#include "MvLayerDnCmd.h" #include "ScaleSurfaceFromToCmd.h" #include "MvSurfaceVertCmd.h" #include "SurfaceType.h" diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index b56a89d..e93d65d 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -99,6 +99,14 @@ void ofxPiMapper::selectPrevVertex(){ _application.getState()->selectPrevVertex(&_application); } +void ofxPiMapper::moveLayerUp(){ + _application.moveLayerUp(); +} + +void ofxPiMapper::moveLayerDown(){ + _application.moveLayerDown(); +} + void ofxPiMapper::togglePauseForSurface(unsigned int i){ ofx::piMapper::BaseSource * s = _application.getSurfaceManager()->getActivePreset()->getSurfaces().at(i)->getSource(); diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index d298d47..170264c 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -51,6 +51,8 @@ class ofxPiMapper { void selectPrevSurface(); void selectNextVertex(); void selectPrevVertex(); + void moveLayerUp(); + void moveLayerDown(); void togglePauseForSurface(unsigned int i); void moveSelection(ofVec2f by); void createSurface(ofx::piMapper::SurfaceType type);