From c3ebebd9f91d7377f043aa98534a551308fe53dc Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 31 Jan 2017 20:43:36 +0100 Subject: [PATCH] Add Application::togglePause() --- src/Application/Application.cpp | 13 +++++++++++++ src/Application/Application.h | 2 ++ src/Application/Modes/ProjectionMappingMode.cpp | 11 +---------- src/Application/Modes/ProjectionMappingMode.h | 1 - src/Application/Modes/TextureMappingMode.cpp | 11 +---------- src/Application/Modes/TextureMappingMode.h | 1 - src/ofxPiMapper.cpp | 4 ++++ src/ofxPiMapper.h | 1 + 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 7acba76..0351444 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -530,5 +530,18 @@ void Application::removeGridColumn(){ } } +void Application::togglePause(){ + if(getSurfaceManager()->getSelectedSurface() == 0){ + return; + } + + if(getSurfaceManager()->getSelectedSurface()->getSource()->getType() == + SourceType::SOURCE_TYPE_VIDEO){ + getCmdManager()->exec( + new ToggleAnimatedSourceCmd( + getSurfaceManager()->getSelectedSurface())); + } +} + } // namespace piMapper } // namespace ofx diff --git a/src/Application/Application.h b/src/Application/Application.h index ab387a5..41e15a7 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -34,6 +34,7 @@ #include "SelVertexCmd.h" #include "SelSurfaceCmd.h" #include "MvSelectionCmd.h" +#include "ToggleAnimatedSourceCmd.h" // Modes #include "ApplicationBaseMode.h" @@ -120,6 +121,7 @@ class Application : public KeyListener { void addGridColumn(); void removeGridRow(); void removeGridColumn(); + void togglePause(); void setPreset(unsigned int i); void setNextPreset(); diff --git a/src/Application/Modes/ProjectionMappingMode.cpp b/src/Application/Modes/ProjectionMappingMode.cpp index afe916b..39d4f5b 100644 --- a/src/Application/Modes/ProjectionMappingMode.cpp +++ b/src/Application/Modes/ProjectionMappingMode.cpp @@ -141,16 +141,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg break; case ' ': - if(app->getSurfaceManager()->getSelectedSurface() == 0){ - return; - } - - if(app->getSurfaceManager()->getSelectedSurface()->getSource()->getType() == - SourceType::SOURCE_TYPE_VIDEO){ - app->getCmdManager()->exec( - new ToggleAnimatedSourceCmd( - app->getSurfaceManager()->getSelectedSurface())); - } + app->togglePause(); break; case OF_KEY_TAB: diff --git a/src/Application/Modes/ProjectionMappingMode.h b/src/Application/Modes/ProjectionMappingMode.h index c739aec..1e10ca0 100644 --- a/src/Application/Modes/ProjectionMappingMode.h +++ b/src/Application/Modes/ProjectionMappingMode.h @@ -5,7 +5,6 @@ #include "ofGraphics.h" #include "StartDragSurfaceCmd.h" #include "DeselectSurfaceCmd.h" -#include "ToggleAnimatedSourceCmd.h" #include "MvSurfaceVertCmd.h" #include "SurfaceType.h" #include "Gui.h" diff --git a/src/Application/Modes/TextureMappingMode.cpp b/src/Application/Modes/TextureMappingMode.cpp index 3cddcbd..dfc96e4 100644 --- a/src/Application/Modes/TextureMappingMode.cpp +++ b/src/Application/Modes/TextureMappingMode.cpp @@ -117,16 +117,7 @@ void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){ break; case ' ': - if(app->getSurfaceManager()->getSelectedSurface() == 0){ - return; - } - - if(app->getSurfaceManager()->getSelectedSurface()->getSource()->getType() == - SourceType::SOURCE_TYPE_VIDEO){ - app->getCmdManager()->exec( - new ToggleAnimatedSourceCmd( - app->getSurfaceManager()->getSelectedSurface())); - } + app->togglePause(); break; case OF_KEY_TAB: diff --git a/src/Application/Modes/TextureMappingMode.h b/src/Application/Modes/TextureMappingMode.h index 5b26034..daeed2f 100644 --- a/src/Application/Modes/TextureMappingMode.h +++ b/src/Application/Modes/TextureMappingMode.h @@ -8,7 +8,6 @@ #include "SelPrevTexCoordCmd.h" #include "DeselectTexCoordCmd.h" #include "SelNextSurfaceCmd.h" -#include "ToggleAnimatedSourceCmd.h" #include "TranslateCanvasCmd.h" #include "SetTexMapDrawModeCmd.h" #include "MvTexCoordCmd.h" diff --git a/src/ofxPiMapper.cpp b/src/ofxPiMapper.cpp index b7b10b9..c7d0d44 100644 --- a/src/ofxPiMapper.cpp +++ b/src/ofxPiMapper.cpp @@ -131,6 +131,10 @@ void ofxPiMapper::togglePauseForSurface(unsigned int i){ } } +void ofxPiMapper::togglePause(){ + _application.togglePause(); +} + void ofxPiMapper::moveSelection(ofVec2f by){ _application.moveSelection(by); } diff --git a/src/ofxPiMapper.h b/src/ofxPiMapper.h index 47d9a33..0b33710 100644 --- a/src/ofxPiMapper.h +++ b/src/ofxPiMapper.h @@ -59,6 +59,7 @@ class ofxPiMapper { void scaleUp(); void scaleDown(); void togglePauseForSurface(unsigned int i); + void togglePause(); void moveSelection(ofVec2f by); void createSurface(ofx::piMapper::SurfaceType type); void eraseSurface(int i);