diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/States/ProjectionMappingState.cpp index a8eb605..a15db1a 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/States/ProjectionMappingState.cpp @@ -283,14 +283,17 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMousePressed(args); + app->getGui()->mousePressed(args); } void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseReleased(args); + app->getGui()->mouseReleased(args); } void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseDragged(args); + app->getGui()->mouseDragged(args); } void ProjectionMappingState::onJointPressed(Application * app, GuiJointEvent & e){ diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index fd5339a..ec0fea9 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -163,16 +163,23 @@ void SurfaceManagerGui::mouseReleased(ofMouseEventArgs & args){ } void SurfaceManagerGui::mouseDragged(ofMouseEventArgs & args){ - textureEditor.mouseDragged(args); + if(guiMode == GuiMode::TEXTURE_MAPPING){ + textureEditor.mouseDragged(args); + }else if(guiMode == GuiMode::PROJECTION_MAPPING){ + projectionEditor.mouseDragged(args); + } if(bDrag){ ofVec2f mousePosition = ofVec2f(args.x, args.y); ofVec2f distance = mousePosition - clickPosition; if(guiMode == GuiMode::PROJECTION_MAPPING){ - // add this distance to all vertices in surface + + // Moves the selected surface on drag projectionEditor.moveSelectedSurface(distance); }else if(guiMode == GuiMode::TEXTURE_MAPPING){ + + // Moves the crop area of the texture textureEditor.moveTexCoords(distance); } clickPosition = mousePosition; diff --git a/src/UserInterface/ProjectionEditor.cpp b/src/UserInterface/ProjectionEditor.cpp index a22fa2b..4f0274a 100644 --- a/src/UserInterface/ProjectionEditor.cpp +++ b/src/UserInterface/ProjectionEditor.cpp @@ -78,6 +78,12 @@ void ProjectionEditor::draw(){ } void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){ + + // Pass args to joint mouse events + for(unsigned int i = 0; i < joints.size(); ++i){ + joints[i]->mouseDragged(args); + } + ofVec2f mousePosition = ofVec2f(args.x, args.y); // Collect all vertices of the projection surfaces