diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index c21639b..7c9579d 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -18,6 +18,7 @@ Application::Application(){ ofAddListener(Gui::instance()->event, this, &Application::onGuiEvent); ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); + ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed); } void Application::setup(){ @@ -131,6 +132,10 @@ void Application::onSurfacePressed(GuiSurfaceEvent & e){ _state->onSurfacePressed(this, e); } +void Application::onBackgroundPressed(GuiBackgroundEvent & e){ + _state->onBackgroundPressed(this, e); +} + void Application::addFboSource(FboSource & fboSource){ _mediaServer.addFboSource(fboSource); } diff --git a/src/Application/Application.h b/src/Application/Application.h index 896762c..8a94e80 100644 --- a/src/Application/Application.h +++ b/src/Application/Application.h @@ -48,6 +48,7 @@ class Application : public KeyListener { void onGuiEvent(GuiEvent & e); void onJointPressed(GuiJointEvent & e); void onSurfacePressed(GuiSurfaceEvent & e); + void onBackgroundPressed(GuiBackgroundEvent & e); // Every state should have it's own GUI layer void addFboSource(FboSource & fboSource); diff --git a/src/Application/ApplicationBaseState.h b/src/Application/ApplicationBaseState.h index 9d75f9a..4edbeaf 100644 --- a/src/Application/ApplicationBaseState.h +++ b/src/Application/ApplicationBaseState.h @@ -19,6 +19,7 @@ class ApplicationBaseState { virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){} virtual void onJointPressed(Application * app, GuiJointEvent & e){} virtual void onSurfacePressed(Application * app, GuiSurfaceEvent & e){} + virtual void onBackgroundPressed(Application * app, GuiBackgroundEvent & e){} }; diff --git a/src/Application/ProjectionMappingState.cpp b/src/Application/ProjectionMappingState.cpp index 128c23a..878b8e5 100644 --- a/src/Application/ProjectionMappingState.cpp +++ b/src/Application/ProjectionMappingState.cpp @@ -189,5 +189,9 @@ void ProjectionMappingState::onSurfacePressed(Application * app, GuiSurfaceEvent app->getCmdManager()->exec(new StartDragSurfaceCmd(e.surface)); } +void ProjectionMappingState::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){ + app->getCmdManager()->exec(new DeselectSurfaceCmd(app->getSurfaceManager())); +} + } // namespace piMapper } // namespace ofx \ No newline at end of file diff --git a/src/Application/ProjectionMappingState.h b/src/Application/ProjectionMappingState.h index 690247c..dc04c89 100644 --- a/src/Application/ProjectionMappingState.h +++ b/src/Application/ProjectionMappingState.h @@ -19,6 +19,7 @@ #include "MvSelectionCmd.h" #include "StartDragSurfaceCmd.h" #include "TogglePerspectiveCmd.h" +#include "DeselectSurfaceCmd.h" #include "SurfaceType.h" #include "Gui.h" @@ -33,6 +34,7 @@ class ProjectionMappingState : public ApplicationBaseState { void onKeyPressed(Application * app, ofKeyEventArgs & args); void onJointPressed(Application * app, GuiJointEvent & e); void onSurfacePressed(Application * app, GuiSurfaceEvent & e); + void onBackgroundPressed(Application * app, GuiBackgroundEvent & e); private: static ProjectionMappingState * _instance;