From d65e498623a2576661958854c9f5fb282d16847a Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 20 Sep 2016 12:09:43 +0200 Subject: [PATCH] Move related mousePressed() part to ProjectionMappingState::mousePressed() --- .../States/ProjectionMappingState.cpp | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/States/ProjectionMappingState.cpp index 7904df7..c043d24 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/States/ProjectionMappingState.cpp @@ -286,7 +286,42 @@ void ProjectionMappingState::onKeyPressed(Application * app, ofKeyEventArgs & ar void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMousePressed(args); - app->getGui()->mousePressed(args); + + CircleJoint * hitJoint = 0; + int hitJointIndex = -1; + BaseSurface * hitSurface = 0; + + hitJoint = app->getGui()->getProjectionEditor()->hitTestJoints(ofVec2f(args.x, args.y)); + + if(hitJoint){ + for(int i = app->getGui()->getProjectionEditor()->getJoints()->size() - 1; i >= 0 ; --i){ + if((*app->getGui()->getProjectionEditor()->getJoints())[i] == hitJoint){ + hitJointIndex = i; + break; + } + } + }else{ + for(int i = app->getSurfaceManager()->size() - 1; i >= 0; --i){ + if(app->getSurfaceManager()->getSurface(i)->hitTest(ofVec2f(args.x, args.y))){ + hitSurface = app->getSurfaceManager()->getSurface(i); + break; + } + } + } + + if(Gui::instance()->getScaleWidget().inside(args.x, args.y)){ + // + }else if(hitJoint){ + hitJoint->select(); + hitJoint->startDrag(); + Gui::instance()->notifyJointPressed(args, hitJointIndex); + }else if(hitSurface){ + app->getGui()->clickPosition = ofVec2f(args.x, args.y); + app->getGui()->startDrag(); // TODO: Should be something like `hitSurface->startDrag()` + Gui::instance()->notifySurfacePressed(args, hitSurface); + }else{ + Gui::instance()->notifyBackgroundPressed(args); + } } void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){