Browse Source

Add ofxCircleJoint

master
Krisjanis Rijnieks 11 years ago
parent
commit
88a01c05c1
  1. 18
      src/ofxBaseJoint.cpp
  2. 3
      src/ofxBaseJoint.h
  3. 16
      src/ofxCircleJoint.cpp
  4. 15
      src/ofxCircleJoint.h

18
src/ofxBaseJoint.cpp

@ -2,10 +2,24 @@
ofxBaseJoint::ofxBaseJoint()
{
registerMouseEvents();
}
ofxBaseJoint::~ofxBaseJoint()
{
unregisterMouseEvents();
}
void ofxBaseJoint::registerMouseEvents()
{
ofAddListener(ofEvents().mousePressed, this, &ofxBaseJoint::mousePressed);
ofAddListener(ofEvents().mouseReleased, this, &ofxBaseJoint::mouseReleased);
ofAddListener(ofEvents().mouseDragged, this, &ofxBaseJoint::mouseDragged);
}
void ofxBaseJoint::unregisterMouseEvents()
{
ofRemoveListener(ofEvents().mousePressed, this, &ofxBaseJoint::mousePressed);
ofRemoveListener(ofEvents().mouseReleased, this, &ofxBaseJoint::mouseReleased);
ofRemoveListener(ofEvents().mouseDragged, this, &ofxBaseJoint::mouseDragged);
}

3
src/ofxBaseJoint.h

@ -8,6 +8,9 @@ public:
ofxBaseJoint();
~ofxBaseJoint();
void registerMouseEvents();
void unregisterMouseEvents();
virtual void mousePressed(ofMouseEventArgs& args){};
virtual void mouseReleased(ofMouseEventArgs& args){};
virtual void mouseDragged(ofMouseEventArgs& args){};

16
src/ofxCircleJoint.cpp

@ -0,0 +1,16 @@
#include "ofxCircleJoint.h"
void ofxCircleJoint::mousePressed(ofMouseEventArgs &args)
{
cout << "mouse pressed" << endl;
}
void ofxCircleJoint::mouseReleased(ofMouseEventArgs &args)
{
cout << "mouse released" << endl;
}
void ofxCircleJoint::mouseDragged(ofMouseEventArgs &args)
{
cout << "mouse dragged" << endl;
}

15
src/ofxCircleJoint.h

@ -0,0 +1,15 @@
#ifndef H_OFX_CIRCLE_JOINT
#define H_OFX_CIRCLE_JOINT
#include "ofMain.h"
#include "ofxBaseJoint.h"
class ofxCircleJoint : public ofxBaseJoint
{
public:
void mousePressed(ofMouseEventArgs& args);
void mouseReleased(ofMouseEventArgs& args);
void mouseDragged(ofMouseEventArgs& args);
};
#endif
Loading…
Cancel
Save