Browse Source

Add passing mouse events instead of registering to them

master
Krisjanis Rijnieks 9 years ago
parent
commit
038c408919
  1. 3
      src/Application/Application.cpp
  2. 4
      src/Surfaces/BaseSurface.cpp
  3. 3
      src/Surfaces/BaseSurface.h
  4. 24
      src/ofxPiMapper.cpp
  5. 4
      src/ofxPiMapper.h

3
src/Application/Application.cpp

@ -16,9 +16,12 @@ Application::Application(){
// TODO: Get rid of listeners, pipe application events from the example app // TODO: Get rid of listeners, pipe application events from the example app
ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed);
ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased); ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased);
/*
ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed); ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed);
ofAddListener(ofEvents().mouseReleased, this, &Application::onMouseReleased); ofAddListener(ofEvents().mouseReleased, this, &Application::onMouseReleased);
ofAddListener(ofEvents().mouseDragged, this, &Application::onMouseDragged); ofAddListener(ofEvents().mouseDragged, this, &Application::onMouseDragged);
*/
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);

4
src/Surfaces/BaseSurface.cpp

@ -112,6 +112,10 @@ bool BaseSurface::getMoved(){
return _moved; return _moved;
} }
float BaseSurface::getScale(){
return _scale;
}
ofMesh & BaseSurface::getMesh(){ ofMesh & BaseSurface::getMesh(){
return mesh; return mesh;
} }

3
src/Surfaces/BaseSurface.h

@ -44,8 +44,7 @@ class BaseSurface {
BaseSource * getDefaultSource(); BaseSource * getDefaultSource();
bool getMoved(); bool getMoved();
float getScale();
float getScale(){ return _scale; }
ofMesh & getMesh(); ofMesh & getMesh();
ofRectangle & getBoundingBox(); ofRectangle & getBoundingBox();

24
src/ofxPiMapper.cpp

@ -14,6 +14,30 @@ void ofxPiMapper::draw(){
_application.draw(); _application.draw();
} }
void ofxPiMapper::mousePressed(int x, int y, int button){
ofMouseEventArgs args;
args.x = x;
args.y = y;
args.button = button;
_application.onMousePressed(args);
}
void ofxPiMapper::mouseReleased(int x, int y, int button){
ofMouseEventArgs args;
args.x = x;
args.y = y;
args.button = button;
_application.onMouseReleased(args);
}
void ofxPiMapper::mouseDragged(int x, int y, int button){
ofMouseEventArgs args;
args.x = x;
args.y = y;
args.button = button;
_application.onMouseDragged(args);
}
void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){ void ofxPiMapper::registerFboSource(ofx::piMapper::FboSource & fboSource){
_application.addFboSource(fboSource); _application.addFboSource(fboSource);
} }

4
src/ofxPiMapper.h

@ -39,6 +39,10 @@ class ofxPiMapper {
void update(); void update();
void draw(); void draw();
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseDragged(int x, int y, int button);
void registerFboSource(ofx::piMapper::FboSource & fboSource); void registerFboSource(ofx::piMapper::FboSource & fboSource);
void registerFboSource(ofx::piMapper::FboSource * fboSource); void registerFboSource(ofx::piMapper::FboSource * fboSource);

Loading…
Cancel
Save