diff --git a/src/ofxSurfaceGui.cpp b/src/ofxSurfaceGui.cpp index 8fd9cbb..1d590a3 100644 --- a/src/ofxSurfaceGui.cpp +++ b/src/ofxSurfaceGui.cpp @@ -214,16 +214,51 @@ void ofxSurfaceGui::unselect() } bool ofxSurfaceGui::hitTest(float x, float y) +{ + if (mode == PROJECTION_MAPPING){ + return hitTestProjectionArea(x, y); + } else if (mode == TEXTURE_MAPPING) { + return hitTestTextureArea(x, y); + } +} + +bool ofxSurfaceGui::hitTestTextureArea(float x, float y) +{ + if ( textureAreaExists() ) { + if ( textureHitarea.inside(x, y) ) { + return true; + } else { + // are we hitting texture mapping joints? + for ( int i=0; i 2 ) { + return true; + } else { + return false; + } } \ No newline at end of file diff --git a/src/ofxSurfaceGui.h b/src/ofxSurfaceGui.h index 1f7b130..81c0bc6 100644 --- a/src/ofxSurfaceGui.h +++ b/src/ofxSurfaceGui.h @@ -27,6 +27,8 @@ public: void select(); void unselect(); bool hitTest(float x, float y); + bool hitTestTextureArea(float x, float y); + bool hitTestProjectionArea(float x, float y); bool isSelected(); editMode getMode(); @@ -50,6 +52,7 @@ private: bool isProjectionMappingJointSelected(); bool isTextureMappingJointSelected(); bool projectionAreaExists(); + bool textureAreaExists(); void addProjectionMappingJoint(); void addNumProjectionMappingJoints(int num); diff --git a/src/ofxSurfaceManager.cpp b/src/ofxSurfaceManager.cpp index d89d324..80359ec 100644 --- a/src/ofxSurfaceManager.cpp +++ b/src/ofxSurfaceManager.cpp @@ -67,9 +67,14 @@ void ofxSurfaceManager::mousePressed(int x, int y, int button) { bool bSurfaceSelected = false; for ( int i=0; ihitTest(x, y) ) { - selectSurface(i); - bSurfaceSelected = true; + // check only if in projection mapping mode + if ( surfaceGuis[i]->getMode() == ofxSurfaceGui::PROJECTION_MAPPING ) { + if ( surfaceGuis[i]->hitTest(x, y) ) { + selectSurface(i); + bSurfaceSelected = true; + } + } else { + bSurfaceSelected = true; // Hackish - we will need a lot of refractoring here later } surfaceGuis[i]->mousePressed(x, y, button); } diff --git a/src/ofxSurfaceManager.h b/src/ofxSurfaceManager.h index 5387dcb..9055c48 100644 --- a/src/ofxSurfaceManager.h +++ b/src/ofxSurfaceManager.h @@ -25,7 +25,6 @@ public: void selectSurface(int index); void unselectAllSurfaces(); int size(); - // TODO: add simple surface private: deque triangleSurfaces;