From b6bbf5526b0120b3399b08954e0921b114f482ba Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 24 Jan 2017 20:40:23 +0100 Subject: [PATCH] Add ofxPiMapper::setNextSource() --- src/Application/Application.cpp | 11 +++++++++++ src/Application/Application.h | 1 + src/Application/Modes/ProjectionMappingMode.cpp | 9 +-------- src/Application/Modes/TextureMappingMode.cpp | 9 +-------- src/ofxPiMapper.cpp | 4 ++++ src/ofxPiMapper.h | 3 +++ 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 29d7363..fe845a3 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -358,5 +358,16 @@ void Application::duplicateSurface(){ } } +void Application::setNextSource(){ + if(getSurfaceManager()->getSelectedSurface() != 0){ + getCmdManager()->exec( + new SetNextSourceCmd( + getSurfaceManager()->getSelectedSurface(), + &Gui::instance()->getSourcesEditorWidget())); + }else{ + getCmdManager()->exec(new SelNextSurfaceCmd(getSurfaceManager())); + } +} + } // namespace piMapper } // namespace ofx diff --git a/src/Application/Application.h b/src/Application/Application.h index 5483f3e..9dcb000 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -79,6 +79,7 @@ class Application : public KeyListener { void moveLayerUp(); void moveLayerDown(); void duplicateSurface(); + void setNextSource(); void setPreset(unsigned int i); void setNextPreset(); diff --git a/src/Application/Modes/ProjectionMappingMode.cpp b/src/Application/Modes/ProjectionMappingMode.cpp index c6e6805..01585ef 100644 --- a/src/Application/Modes/ProjectionMappingMode.cpp +++ b/src/Application/Modes/ProjectionMappingMode.cpp @@ -210,14 +210,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg break; case OF_KEY_TAB: - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - app->getCmdManager()->exec( - new SetNextSourceCmd( - app->getSurfaceManager()->getSelectedSurface(), - &Gui::instance()->getSourcesEditorWidget())); - }else{ - app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager())); - } + app->setNextSource(); break; case 'd': diff --git a/src/Application/Modes/TextureMappingMode.cpp b/src/Application/Modes/TextureMappingMode.cpp index 1ce3238..3cddcbd 100644 --- a/src/Application/Modes/TextureMappingMode.cpp +++ b/src/Application/Modes/TextureMappingMode.cpp @@ -130,14 +130,7 @@ void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){ break; case OF_KEY_TAB: - if(app->getSurfaceManager()->getSelectedSurface() != 0){ - app->getCmdManager()->exec( - new SetNextSourceCmd( - app->getSurfaceManager()->getSelectedSurface(), - &Gui::instance()->getSourcesEditorWidget())); - }else{ - app->getCmdManager()->exec(new SelNextSurfaceCmd(app->getSurfaceManager())); - } + app->setNextSource(); break; case '0': // Next draw mode diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index 1d58784..108a574 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -134,6 +134,10 @@ void ofxPiMapper::eraseSurface(int i){ } } +void ofxPiMapper::setNextSource(){ + _application.setNextSource(); +} + void ofxPiMapper::saveProject(){ _application.saveProject(); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index b9959aa..d7bcea1 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -59,6 +59,9 @@ class ofxPiMapper { void moveSelection(ofVec2f by); void createSurface(ofx::piMapper::SurfaceType type); void eraseSurface(int i); + + // Sources, selected surface + void setNextSource(); private: ofx::piMapper::Application _application;