Browse Source

Handle `backgroundPressedEvent` properly in the `Application`

master
Krisjanis Rijnieks 9 years ago
parent
commit
eda4f8ad1f
  1. 5
      src/Application/Application.cpp
  2. 1
      src/Application/Application.h
  3. 1
      src/Application/ApplicationBaseState.h
  4. 4
      src/Application/ProjectionMappingState.cpp
  5. 2
      src/Application/ProjectionMappingState.h

5
src/Application/Application.cpp

@ -18,6 +18,7 @@ Application::Application(){
ofAddListener(Gui::instance()->event, this, &Application::onGuiEvent); ofAddListener(Gui::instance()->event, this, &Application::onGuiEvent);
ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed);
ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed);
ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed);
} }
void Application::setup(){ void Application::setup(){
@ -131,6 +132,10 @@ void Application::onSurfacePressed(GuiSurfaceEvent & e){
_state->onSurfacePressed(this, e); _state->onSurfacePressed(this, e);
} }
void Application::onBackgroundPressed(GuiBackgroundEvent & e){
_state->onBackgroundPressed(this, e);
}
void Application::addFboSource(FboSource & fboSource){ void Application::addFboSource(FboSource & fboSource){
_mediaServer.addFboSource(fboSource); _mediaServer.addFboSource(fboSource);
} }

1
src/Application/Application.h

@ -48,6 +48,7 @@ class Application : public KeyListener {
void onGuiEvent(GuiEvent & e); void onGuiEvent(GuiEvent & e);
void onJointPressed(GuiJointEvent & e); void onJointPressed(GuiJointEvent & e);
void onSurfacePressed(GuiSurfaceEvent & e); void onSurfacePressed(GuiSurfaceEvent & e);
void onBackgroundPressed(GuiBackgroundEvent & e);
// Every state should have it's own GUI layer // Every state should have it's own GUI layer
void addFboSource(FboSource & fboSource); void addFboSource(FboSource & fboSource);

1
src/Application/ApplicationBaseState.h

@ -19,6 +19,7 @@ class ApplicationBaseState {
virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){} virtual void onKeyPressed(Application * app, ofKeyEventArgs & args){}
virtual void onJointPressed(Application * app, GuiJointEvent & e){} virtual void onJointPressed(Application * app, GuiJointEvent & e){}
virtual void onSurfacePressed(Application * app, GuiSurfaceEvent & e){} virtual void onSurfacePressed(Application * app, GuiSurfaceEvent & e){}
virtual void onBackgroundPressed(Application * app, GuiBackgroundEvent & e){}
}; };

4
src/Application/ProjectionMappingState.cpp

@ -189,5 +189,9 @@ void ProjectionMappingState::onSurfacePressed(Application * app, GuiSurfaceEvent
app->getCmdManager()->exec(new StartDragSurfaceCmd(e.surface)); app->getCmdManager()->exec(new StartDragSurfaceCmd(e.surface));
} }
void ProjectionMappingState::onBackgroundPressed(Application * app, GuiBackgroundEvent & e){
app->getCmdManager()->exec(new DeselectSurfaceCmd(app->getSurfaceManager()));
}
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

2
src/Application/ProjectionMappingState.h

@ -19,6 +19,7 @@
#include "MvSelectionCmd.h" #include "MvSelectionCmd.h"
#include "StartDragSurfaceCmd.h" #include "StartDragSurfaceCmd.h"
#include "TogglePerspectiveCmd.h" #include "TogglePerspectiveCmd.h"
#include "DeselectSurfaceCmd.h"
#include "SurfaceType.h" #include "SurfaceType.h"
#include "Gui.h" #include "Gui.h"
@ -33,6 +34,7 @@ class ProjectionMappingState : public ApplicationBaseState {
void onKeyPressed(Application * app, ofKeyEventArgs & args); void onKeyPressed(Application * app, ofKeyEventArgs & args);
void onJointPressed(Application * app, GuiJointEvent & e); void onJointPressed(Application * app, GuiJointEvent & e);
void onSurfacePressed(Application * app, GuiSurfaceEvent & e); void onSurfacePressed(Application * app, GuiSurfaceEvent & e);
void onBackgroundPressed(Application * app, GuiBackgroundEvent & e);
private: private:
static ProjectionMappingState * _instance; static ProjectionMappingState * _instance;

Loading…
Cancel
Save