Browse Source

Fix unwanted surface deselects while in texture mode

master
Krisjanis Rijnieks 11 years ago
parent
commit
4318b947ea
  1. 46
      src/ofxSurfaceGui.cpp
  2. 3
      src/ofxSurfaceGui.h
  3. 11
      src/ofxSurfaceManager.cpp
  4. 1
      src/ofxSurfaceManager.h

46
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<textureMappingJoints.size(); i++ ) {
if ( textureMappingJoints[i].hitTest(ofVec2f(x, y)) ) {
return true;
}
}
return false;
}
} else {
return false;
} // textureAreaExists()
}
bool ofxSurfaceGui::hitTestProjectionArea(float x, float y)
{
if ( projectionAreaExists() ) {
if ( projectionHitarea.inside(x, y) ) {
return true;
} else {
// hitting one of the projection mappting joints also counts,
// so let's check that
for ( int i=0; i<projectionMappingJoints.size(); i++ ) {
if ( projectionMappingJoints[i].hitTest(ofVec2f(x, y)) ) {
return true;
}
}
return false;
}
} else {
return false;
}
} // projectionAreaExists()
}
bool ofxSurfaceGui::isSelected()
@ -316,4 +351,13 @@ bool ofxSurfaceGui::projectionAreaExists()
} else {
return false;
}
}
bool ofxSurfaceGui::textureAreaExists()
{
if ( textureHitarea.size() > 2 ) {
return true;
} else {
return false;
}
}

3
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);

11
src/ofxSurfaceManager.cpp

@ -67,9 +67,14 @@ void ofxSurfaceManager::mousePressed(int x, int y, int button)
{
bool bSurfaceSelected = false;
for ( int i=0; i<surfaceGuis.size(); i++ ) {
if ( surfaceGuis[i]->hitTest(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);
}

1
src/ofxSurfaceManager.h

@ -25,7 +25,6 @@ public:
void selectSurface(int index);
void unselectAllSurfaces();
int size();
// TODO: add simple surface
private:
deque<ofxTriangleSurface*> triangleSurfaces;

Loading…
Cancel
Save